The documents I am working with produce very large Tikz pictures (using Forest package) that span multiple horizontal and vertical pages in PDF.
These pictures need to have titles, compbined of text, regular JPG images (logos) and PST pictures (QR code).
When using standalone class, Forest is produced fine, but any text/tables prior to it appear on its left. Using varwidth
parameter to standalone I can put them above Forest, but it will no longer span multiple pages.
How can I get the best of both worlds: put the title above Forest and let it take as much space as it needs at the same time? Also need to put copyright notice below the Forest.
That must have something to do with the calculation of \textwidth
but what?
\documentclass[varwidth=true,border=10pt]{standalone}
%\documentclass[border=10pt]{standalone}
\usepackage{forest}
\usepackage{adjustbox}
\usepackage{pst-barcode}
\usepackage[crop=off]{auto-pst-pdf}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\begin{document}
\begin{tabular*}{\textwidth}{@{}l @{\extracolsep{\fill}} r@{}}
\begin{tabular}[t]{@{}l@{}}
Title\\ Text
\end{tabular} &
\begin{adjustbox}{valign=t}
\begin{pspicture}(0.7in,0.7in)
\psbarcode{http://www.ctan.org}{}{qrcode}
\end{pspicture}
\end{adjustbox}
\end{tabular*}
\begin{forest}
for tree={
draw=black, align=center, l sep=4ex, parent anchor=south, child anchor=north,
node options={font=\footnotesize, minimum width=14em, minimum height=10ex, rounded corners=1ex},
edge path={
\noexpand\path[\forestoption{edge}]
(!u.parent anchor) -- +(0,-2ex) -| (.child anchor)\forestoption{edge label};
},
where n children=0{
child anchor=west,
edge path={
\noexpand\path[\forestoption{edge}]
([xshift=-6em]!u.parent anchor) |- (.child anchor)\forestoption{edge label};
},
draw=red,for parent={
parent anchor=south, l sep=-12em, grow'=east, calign=child edge, draw=blue
}
}{}
}
[Parent,name=Parent
[Child1
[,phantom]
[Child11]
[Child12]
]
[Child3
[,phantom]
[Child31]
[Child32]
]
[Child3
[,phantom]
[Child31]
[Child32]
]
[Child3
[,phantom]
[Child31]
[Child32]
]
[Child3
[,phantom]
[Child31]
[Child32]
]
[Child3
[,phantom]
[Child31]
[Child32]
]
[Child3
[,phantom]
[Child31]
[Child32]
]
[Child3
[,phantom]
[Child31]
[Child32]
]
]
% <===== Insert below snippet with \node here =====
\end{forest}
\begin{tiny}Copyright \textcopyright Myself, 2014\end{tiny}
\end{document}
If Child1 and Child3 nodes were left, it would render just fine, but including the duplicates of Child3 clips the Forest.
Edit:
One of the workarounds I can think of would be including the necessary content into a \node
inside the forest. But when I am trying to move the tabular*
environment into a node as follows and to a line indicated by a comment above, it does not seem to be able to calculate the total width of the forest correctly:
\node(title) at (0,35ex){
\begin{tabular*}{\textwidth}{@{}l @{\extracolsep{\fill}} r@{}}
\begin{tabular}[t]{@{}l@{}}
Title\\Subtitle\\\begin{tiny}as of June 20, 2014\end{tiny}
\end{tabular} &
\begin{adjustbox}{valign=t}
\begin{pspicture}(0.7in,0.7in)
\psbarcode{http://www.ctan.org}{}{qrcode}
\end{pspicture}
\end{adjustbox}
\end{tabular*}
}[];
The end result of the MWE is a clipped forest with correctly placed Title and QR Code picture:
If the tabular*
environment at the top of the document was moved to the commented line and varwidth
option removed from the document class, it would look like below with Title and QRCode in the middle of the page, instead of at left and right side respectively:
Edit:
Tried to implement John's savebox
tip from the comment, but the contents of savebox
are rendered side by side with the tabular*
environment, not above it. They are equal width though, which is good.
\documentclass[border=10pt]{standalone}
\begin{document}
\newsavebox{\forestbox}
\sbox{\forestbox}{
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
}
\newlength{\forestboxlen}
\settowidth{\forestboxlen}{\usebox{\forestbox}}
\begin{tabular*}{\forestboxlen}{@{}l @{\extracolsep{\fill}} r@{}}
\begin{tabular}[t]{@{}l@{}}
Title\\ Text
\end{tabular} &
\begin{adjustbox}{valign=t}
\begin{pspicture}(0.7in,0.7in)
\psbarcode{http://www.ctan.org}{}{qrcode}
\end{pspicture}
\end{adjustbox}
\end{tabular*}
\usebox{\forestbox}
\end{document}
savebox
width beforesavebox
itself was rendered. 2. When I tried to put Forest intosavebox
it no longer rendered. Actually, nothing in thesavebox
is rendering, so I am doing something wrong...\usebox{\forestbox}
! Thanks for the tip, but is it possible to put savebox contents under the title/picture, not side by side?