2

I use tikzpicture for my dashed box, but the box breaks to a newpage when the inside text is too long:

enter image description here

Here is my .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}

I want my long dashed box can be continued in multi-page just like the longtable, how I can do that?

  • 2
    With tcolorbox this is quite simple. you only need to select option breakable ... – Zarko Jun 27 '16 at 14:10
4

Solution with the mdframed package:

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

If you want a complete frame before and after the page break, use everyline=true.

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

enter image description here

  • Thank you very much. But it may miss the footline and headline with mdframed solution. – Steven Shen Jun 27 '16 at 14:54
  • @StevenShen So you want two complete frames with four edges each? – Stefan Braun Jun 27 '16 at 14:57
  • @StevenShen does the second version satisfy your needs? – Stefan Braun Jun 27 '16 at 22:51
  • Thanks a lot. Yes, the two complete frames with four edges each is what I want.I use everyline=true ,in my win10 there is something wrong with xelatex :! Package keyval Error:everyline undefined., but it will be ok in my linux with texlive2015. – Steven Shen Jun 28 '16 at 1:51
4

And this is the solution with the 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}

enter image description here

Update: And with desired aspect (red, dashed border around all fragments)

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

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.