Ask Your Question
1

sagetex linebreak

asked 2020-08-16 14:11:31 +0200

dantetante gravatar image

When using the environment sagecommandline of sagetex with long number output, how can I get automatic line breaks? I already tried to change sagetex.sty (putting breaklines=true at several places), but nothing changed. Here is my minimal example: (p.s. I asked the same question also on tex.stackexchange)

\documentclass[
a6paper, 11pt, oneside,
english,ngerman]{scrartcl} 

% !TEX TS-program = sage
% !TEX encoding = UTF-8 Unicode

\usepackage[headsep=0cm,footskip=1.5em,includeheadfoot=true,
top=0cm,bottom=0cm,left=.5cm,right=.5cm,]{geometry}
\usepackage{sagetex}

\lstdefinestyle{SageOutput}{style=DefaultSageOutput,breaklines=true}

\begin{document}
\begin{sagecommandline}
sage: factorial(100)+1
sage: factorial(50)+1
sage: factorial(10)
\end{sagecommandline}
\end{document}
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-08-17 01:34:50 +0200

Emmanuel Charpentier gravatar image

updated 2020-08-17 01:56:40 +0200

That's more of a $\LaTeX$ than a Sage question, and could get a better answer in a (mailing list|newsgroup|forum|site) dedicated to $\LaTeX$...

My two cents :

  • Some $\LaTeX$ packages help with "long equations" ; breqn comes to mind, but there are probably others.

  • You may typeset manually : convert your "long" numerical output in a string, then chop it up in conveniently sized chunks, arrange them in a list, then generate in Sage a string representing a convenient $\LaTeX$ packaging of this list. See the example.tex in the $SAGE_LOCAL/share/texmf/tex/latex/sagetex/ directory of your distribution for inspiration (I'm thinking of the Pascal's triangle example).

But you should also reconsider the need for printing your "long number output". If you need a bedsheet to print it, ask yourself if your reader shall read said bedsheet ? Or are you attempting bragging ?

HTH,

edit flag offensive delete link more

Comments

I really need long number output, because I work with cryptography and number theory stuff and people want to copy and paste.

dantetante gravatar imagedantetante ( 2020-08-20 18:22:48 +0200 )edit
0

answered 2020-08-20 18:20:59 +0200

dantetante gravatar image

updated 2020-09-03 07:26:14 +0200

I found a solution myself (and already posted it on tex.stackexchange). Here it is:

\documentclass[ DIV=16, a6paper, 11pt]{scrartcl} 
% arara: lualatex
% arara: sagetex
% arara: lualatex
% !TEX TS-program = sage
% !TEX encoding = UTF-8 Unicode
\usepackage{seqsplit}
\usepackage{sagetex}
\lstset{
literate=
{1}{1\allowbreak}1
{2}{2\allowbreak}1
{3}{3\allowbreak}1
{4}{4\allowbreak}1
{5}{5\allowbreak}1
{6}{6\allowbreak}1
{7}{7\allowbreak}1
{8}{8\allowbreak}1
{9}{9\allowbreak}1
{0}{0\allowbreak}1,
breaklines=true}
\begin{document}
\begin{sagecommandline}
sage: factorial(50)
\end{sagecommandline}
\seqsplit{%
30414093201713378043612608166064768844377641568960512000000000000}
\end{document}
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

2 followers

Stats

Asked: 2020-08-16 14:11:31 +0200

Seen: 622 times

Last updated: Sep 03 '20