# Does sagemath move asterisks down?

I am using sagemath.sty. The multiplication asterisks that are shown in the sagecommandline environment are far too low. How can I adjust them?

I am bringing in a TrueType font using fontspec. This is a coding font so the asterisks are lower than in many other fonts. That I can tell, sagemath is moving them vertically and the result is that they fall into the baseline.

Here is my file try.tex. Below I have links to two images showing the output for the two fonts listed. (The coding font ProggyClean.ttf is from a web site called http://proggyfonts.net but I included the images so you needn't download it to see what I mean.)

% -*- coding: utf-8 -*-
\documentclass{article}
\usepackage{xcolor}
\definecolor{pythoncolor}{HTML}{BCD4CE}
\usepackage[T1]{fontenc}
\usepackage{fontspec}

\newfontface\listingsfont[Path=../fonts/,
Scale=1.05,Color=blue]{ProggyClean.ttf}
% \newfontface\listingsfont[
%                           Color=red]{Charis SIL}

\usepackage{sagetex}

\RequirePackage{listings}
\lstset{basicstyle=\listingsfont,
columns=flexible,
}

% Copied and modified from sagetex
\lstdefinestyle{SageInput}{basicstyle=\listingsfont,
}
\lstdefinestyle{SageOutput}{basicstyle=\listingsfont,
}

% Test how it looks under regular verbatim style
\makeatletter
\newcommand{\verbatimfont}[1]{\def\verbatim@font{#1}}%
\makeatother

\begin{document}
% Text in the listings font
{\listingsfont abc**def "jklm" 'nopq'}

% Test under regular verbatim
\verbatimfont{\listingsfont}
\begin{verbatim}
xyz**xyz
\end{verbatim}

% Text under Sage
\begin{sagecommandline}
sage: 4**3+16
sage: 2-3/4*5
\end{sagecommandline}
\end{document}


The result of using ProggyClean is at i.imgur.com/EcbAtMN.png (I lack the karma to post links) and gives asterisks in the baseline. The result of uncommenting the text font Charis SIL is at i.imgur.com/ltFkamq.png and looks much better, I think because its asterisks started out higher.

How can I adjust the height of these myself? Thank you.

edit retag close merge delete

Sort by » oldest newest most voted

I don't have your font. But I can reproduce your problem while using the "Inconsolata" mono font.

OTOH, I obtain correct results by using minted instead of listings (up to the specialization of the font: see below). Which I do routinely anyway, since listings doesn't support easily anything else than US "english", which is an excruciating pain in the * for about 96% of this planet's population...

(while I'm sure that they exist, I didn't take the time to look up the necessary idioms to set the font options you desire for your listings. I'll do that if/when I have the time...).

So:

1. It is possibly a bug of listings when used in/triggered by Sagetex.

2. Using a modern alternative (i. e. listings) solves the problem (with the obvious drawback to have to allow -shell-escape, which is a nice security hole...).

It might be worthy to open an issue on the Sagetex Github page...

As for fixing that up yourself, well... First look if listings used alone (i. e. by typesetting a Sage snippet with \lstinputlisting, IIRC) gives you correct results or not.

If so, the problem is in SageTeX, in which case you have now a reasonable chance to get your patch in a future version of SageTeX, now that the Sage core team can act on it.

If not, the problem is in listings. Then ... good luck to get a fix: the authors of listings seem to be unreacheable, and about 15 years of pleas to get support for no-US-ASCII have been ignored...

more

Yes, I agree that this should be put on the ST page if it can be confirmed. By the way, did you mean minted in your option 2?

( 2019-11-08 03:20:56 +0200 )edit

Yes, I meant minted.My bloody aging neurons...

( 2019-11-08 08:11:26 +0200 )edit
1

Thank you for the help. Like you, I prefer to do code with the fancyvrb package, as minted does, in my case because of copy-and-pastability (although it doesn't include an option for background color, so that is a downside). But sagemath uses listings so there I am. (I am quite keen on sagemath's wonderful sagecommandline environment since I am writing a lab manual and I want to show code and response.)

I'm very glad to hear you can confirm the bug. I had a look at the code and I have to admit that fixing it is beyond my abilities. I'll put reporting that bug on my todo list and see if I can get that done soon. Thanks again. (I apologize but I lack the karma to upvote you.)

( 2019-11-08 23:35:24 +0200 )edit

Jim, as you know another possibility would be to write this in PreTeXt which has some people developing it who are actively thinking about the listings and other packages and font issues. If you are at the NES/MAA meeting this weekend I will be glad to chat briefly. Unfortunately I agree with Emmanuel that some very useful LaTeX packages end up sort of in limbo.

( 2019-11-22 03:37:48 +0200 )edit