Ask Your Question
3

In sagetex, how to avoid italic font for sagecommandline environment within an italic example environment?

asked 2025-05-23 10:42:21 +0100

Sébastien gravatar image

updated 2025-05-23 10:46:02 +0100

I am using sagecommandline environment of sagetex and I love it. I currently have an issue illustrated in the example below:

\documentclass{article}
\newtheorem{example}{Example}
\usepackage{sagetex}

\begin{document}
This is in the text:
\begin{sagecommandline}
    sage: matrix(3,range(9))
\end{sagecommandline}

\begin{example}
    This is an example:
\begin{sagecommandline}
    sage: matrix(3,range(9))
\end{sagecommandline}
\end{example}
\end{document}

output is:

image description

I would like the sagecommandline code to never be in italic, even inside an environment which is in italic.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2025-07-02 22:41:11 +0100

dsejas gravatar image

The problem is your definition of the example environment, not sagecommandline itself. In order to correct it, you can use the more standard definition that uses the amsthm package:

\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{example}{Example}

However, if you really want to keep your current definition, your can surround any part of the text (the sage output, for example) with \bgroup\normalfont and \egroup; however, this is less elegant.

My suggestion is to use amsthm. You can fine-tune every aspect for your environments, and even define new style for common ones. I hope this helps!

edit flag offensive delete link more

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: 2025-05-23 10:42:21 +0100

Seen: 228 times

Last updated: Jul 02