sagetex 换行符

sagetex 换行符

当使用 sagetex 环境sagecommandline输出长数字时,如何实现自动换行?我已经尝试更改 sagetex.sty(放在breaklines=true几个地方),但没有任何变化。这是我的最小示例:

\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}

答案1

是的,我可以...我自己找到了一个解决方案:

\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}

相关内容