# sagetex linebreak

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

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

Sort by » oldest newest most voted

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,

more

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

( 2020-08-20 18:22:48 +0200 )edit

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}

more