Ask Your Question
0

Does sagemath move asterisks down?

asked 2019-11-03 18:47:06 +0100

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-11-07 21:37:21 +0100

Emmanuel Charpentier gravatar image

updated 2019-11-07 21:50:12 +0100

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...

edit flag offensive delete link more

Comments

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?

kcrisman gravatar imagekcrisman ( 2019-11-08 03:20:56 +0100 )edit

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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-11-08 08:11:26 +0100 )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.)

James Hefferon gravatar imageJames Hefferon ( 2019-11-08 23:35:24 +0100 )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.

kcrisman gravatar imagekcrisman ( 2019-11-22 03:37:48 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-11-03 18:47:06 +0100

Seen: 333 times

Last updated: Nov 07 '19