允许在虚线框中分页

允许在虚线框中分页

我使用 tikzpicture 作为虚线框,但是当内部文本太长时,该框会跳转到新页面:

在此处输入图片描述

这是我的.tex:

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}               
\usetikzlibrary{calc}

\begin{document}
\lipsum[1-2]
\begin{center}
\begin{tikzpicture}
\tikzstyle{information text}=[draw=red, dashed, inner sep=1.5ex]
\node[text width=0.95\textwidth , information text]
{\begin{enumerate}           
    \item my item。
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item。
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
\end{enumerate}};
\end{tikzpicture}
\end{center}
\end{document}

我希望我的长虚线框可以像长表一样在多页中延续,我该怎么做?

答案1

使用软件包的解决方案mdframed

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[framemethod=tikz]{mdframed}

\mdfsetup{tikzsetting={draw=red,line width=3pt,dashed,dash pattern= on 10pt off 3pt},linecolor=none}

\begin{document}
\lipsum[1-2]
\centering
\begin{mdframed}

{\begin{enumerate}
    \item my item。
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item。
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
\end{enumerate}}
\end{mdframed}
\end{document}

如果希望分页符前后有完整的框架,请使用everyline=true

\mdfsetup{tikzsetting={draw=red,line width=3pt,dashed,dash pattern= on 10pt off 3pt},linecolor=none,everyline=true}

在此处输入图片描述

答案2

这是解决方案default tcolorbox

\documentclass{article}
\usepackage[most]{tcolorbox}               
\usepackage{lipsum}

\begin{document}
\lipsum[1-2]
\begin{tcolorbox}[enhanced,breakable]
\begin{enumerate}           
    \item my item。
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item。
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
\end{enumerate}
\end{tcolorbox}
\end{document}

在此处输入图片描述

更新:并具有所需的外观(所有片段周围都有红色虚线边框)

\documentclass{article}
\usepackage[most]{tcolorbox}               
\usepackage{lipsum}

\newtcolorbox{mybox}{empty, breakable, enhanced, colback=white, colframe=white,
overlay unbroken ={\draw[red, dashed, thick] (frame.north west) rectangle (frame.south east);},
overlay broken={\draw[red, dashed, thick] (frame.north west) rectangle (frame.south east);}}

\begin{document}
\lipsum[1]
\begin{mybox}
\begin{enumerate}           
    \item my item
    \item my item
    \item my item
    \item my item
\end{enumerate}
\end{mybox}

\lipsum[2]
\begin{mybox}
\begin{enumerate}           
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
    \item my item
\end{enumerate}
\end{mybox}
\end{document}

在此处输入图片描述

相关内容