多次使用 \tcbinputlisting 后出现一些损坏

多次使用 \tcbinputlisting 后出现一些损坏

我无法制作比以下更小的 MWE。我注意到在文档中的随机位置,列表出现损坏,然后一段时间内恢复正常,然后又变坏了。

我基本上使用tcolorboxwithlisting来格式化许多小代码片段。使用相同的代码生成列表,一些随机列表显示 PDF 文件中有损坏。要么是缺少行,要么是某些文本变黑,要么是显示一半,要么是出现一些黑条。

以下是典型的输出

Mathematica 图形

几次复制后,它可以改变大小

Mathematica 图形

有时列表会在随机位置出现黑条

Mathematica 图形

我在下面使用了一个生成一个列表的示例代码片段。我试图找到一种方法来自动复制它以使其小 MWE,但做不到,因为它Verbatim里面有。所以我不得不手动制作大约 10 份副本才能显示问题。

没有编译错误。只是 PDF 出现了这些错误列表。

我想我会删除tcolorbox并返回到基本列表的使用。太多问题我自己都搞不清楚。再次为冗长的 MWE 感到抱歉。它实际上是相同的代码(一个表格有 2 个单元格)一个单元格是列表,下一个单元格是小Verbatim文本。但同样,我不知道如何制作一个循环来复制它。如果您不喜欢手动复制所有这些代码,我将这段代码放在下面,并在我的 Linux 机器上生成 PDF 文件此文件夹在我的网站上

\begin{filecontents*}{\jobname.txt}
clear all;
s   = tf('s');
sys = ( s+1 )/(s^2  + s  +  1);
[num,den]=tfdata(sys,'v');
%convert to state space
[A,B,C,D] = tf2ss(num,den)
\end{filecontents*}

\documentclass[12pt]{scrbook}% 
\IfFileExists{luatex85.sty}
{
\usepackage{luatex85}
}
{}
\usepackage{longtable}
\usepackage{listings}
\usepackage{color}
\definecolor{bg}{RGB}{240,240,240}
\usepackage{upquote} %to fix string quotes
\usepackage[most]{tcolorbox}
\tcbuselibrary{listings}
\usepackage{matlab-prettifier}
\usepackage{amsmath}
\usepackage{fancyvrb}
\usepackage{pgffor}
\usepackage{fancyvrb}

\begin{document} 


\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}


\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}

\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}


\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}


\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}


\begin{tabular}[c]{|p{0.6\textwidth}|p{0.4\textwidth}|}\hline
\textbf {Matlab}\vspace {10pt} {\newboxarray {mylisting} 
\tcbinputlisting {nobeforeafter,enhanced,listing only,hbox, listing file={\jobname .txt}, size=small,
store to box array=mylisting,listing options={numbers=left, numberstyle=\scriptsize ,
basicstyle=\ttfamily \normalsize , breaklines = false,showspaces=false}} 
\boxarraygetwidth [mylisting]{\mylistingwidth }{1} 
\tcbinputlisting{nobeforeafter,enhanced,listing only, width=\mylistingwidth ,left skip=7pt, 
breakable,listing file={\jobname .txt},size=small, listing options={style=Matlab-editor,numbers=left, 
numberstyle=\scriptsize ,basicstyle=\ttfamily \normalsize ,
breaklines = false,escapechar=`,showspaces=false,mlshowsectionrules = true}} }
&
\begin{verbatim}
dfklajdflkjdsf
\end{verbatim}
\\ \hline
\end{tabular}
\end{document}

lualatex 于 TL 2016。

答案1

breakable内部tabular似乎不太健康,因为tcolorbox很可能根本无法中断。中断的框显然会中断之前使用过的框,这要么是一个错误,要么tcolorbox总结了一些页面目标。

相关内容