Unfortunately this doesn't work. Picture environments (picture
, tikzpicture
, ...) are (horizontal) boxes on their own and LaTeX doesn't break these. You would need to do this by yourself.
If you are able to detect it once your picture is too long (longer than max. \textheight
or calculate the rest of the current page) you could insert some code like <global save settings>\end{picture}\begin{picture}<restore settings>
to close the current picture and open a new one. I do similar things with TikZ's \path
in tikz-timing
where I have to start a new path to change the colour and style but want to keep certain settings and the position. It's, however, a little tricky, especially for whole pictures, I guess.
Another possibility would be to draw the whole picture as long it turns out to be, but inside a savebox, i.e. you store it first but don't typeset it directly. Then you can measure its height (\ht\yourboxmacro
) and if it is too high you can clip it using my adjustbox
package. The idea would be to insert it twice: once clipped to the size of the first page and then again on the next page with the first part clipped. Using a loop you could, of course, support more than two pages.
Here some example code. I used tikzpicture
here because I know its syntax but not the one of picture
very well. It will work with that as well of course. (Note that there is a bug in the current version of adjustbox
. I fixed it for the example image below, but the top is still clipped incorrectly. I have to have a closer look at it. However, the basic idea is sound and works.)
\documentclass{article}
\usepackage{tikz}
\usepackage{adjustbox}
\newsavebox{\mysavebox}
\newlength{\myrest}
\begin{document}
\begin{lrbox}{\mysavebox}%
\begin{tikzpicture}[red,thick]
\draw (0,0) rectangle (-.9\textwidth,-2.8\textheight);
\draw (0,0) -- (-.9\textwidth,-2.8\textheight);
\draw (-.9\textwidth,0) -- (0,-2.8\textheight);
\path (-1mm,-1mm);
\path (current bounding box.north east) +(1mm,1mm);
\end{tikzpicture}%
\end{lrbox}%
%
\ifdim\ht\mysavebox>\textheight
\setlength{\myrest}{\ht\mysavebox}%
\loop\ifdim\myrest>\textheight
\newpage\par\noindent
\clipbox{0 {\myrest-\textheight} 0 {\ht\mysavebox-\myrest}}{\usebox{\mysavebox}}%
\addtolength{\myrest}{-\textheight}%
\repeat
\newpage\par\noindent
\clipbox{0 0 0 {\ht\mysavebox-\myrest}}{\usebox{\mysavebox}}%
\else
\usebox{\mysavebox}%
\fi
\end{document}
![Result](https://i.stack.imgur.com/lBkXe.png)
Here is a quick setup with tcolorbox
, using the \newtcbtheorem
macro, but it can done with a normal \newtcolorbox
macro as well. The special title setup requires the skin
library, which is included using most
option.
I applied a \newtcolorbox
approach as well, to show how the options of the boxes can be changed, contrary to \newtcbtheorem
.
\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbtheorem{Summary}{\bfseries Summary}{enhanced,drop shadow={black!50!white},
coltitle=black,
top=0.3in,
attach boxed title to top left=
{xshift=1.5em,yshift=-\tcboxedtitleheight/2},
boxed title style={size=small,colback=pink}
}{summary}
\newtcolorbox[auto counter]{summary}[1][]{title={\bfseries Summary~\thetcbcounter},enhanced,drop shadow={black!50!white},
coltitle=black,
top=0.3in,
attach boxed title to top left=
{xshift=1.5em,yshift=-\tcboxedtitleheight/2},
boxed title style={size=small,colback=pink},#1}
\begin{document}
\begin{Summary}{}{firstsummary}
Brontosaurs are thin at one end, thick in the middle and thin again on the other end
\end{Summary}
\begin{summary}[boxed title style={colback=yellow},colback=green]
Everything needed to decrypt the drive data is stored on the drive itself. No secret is
present in the enclosure.
$\Rightarrow$ The attacker should be able to brute-force the PIN or extract the encryption key
only in software.
\end{summary}
\end{document}
![enter image description here](https://i.stack.imgur.com/3Srgu.jpg)
Best Answer
Here is a short example using the
mdframed
package that is capable of breaking a boxed environment across a page:See the
mdframed
documentation for more information on how themdframed
environment can be used. In the above example,lipsum
was used to generate dummy text, Lorem Ipsum style.