\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[inner sep=0,draw,text width=40mm]
{ \parbox{\hsize}
{ \parshape 4 0mm 40mm 5mm 35mm 10mm 30mm 15mm 25mm
\fboxrule0.1pt
\fboxsep0pt
\fbox{hello world}\newline
\fbox{hello world}\newline
\fbox{hello world}
\vspace{-\lineskip} % WHY AFTER THE PICTURE THAT FOLLOWS, NOT BEFORE?
\begin{tikzpicture}
\path node[draw,text width=24mm]
{ \parbox{\hsize}
{ \begin{gather*}
2+2=4
\end{gather*}
}
};
\end{tikzpicture}
}
};
\end{tikzpicture}
\end{document}
Asked
Active
Viewed 427 times
4
2 Answers
6
It is unrelated to tikz, if you use \vspace in horizontal mode it is inserted after linebreaking.
aaa\vspace{1cm}bbb
adds the space after bbb
You possibly wanted to have blank line before the \vspace so that the space is added in vertical mode at the point it appears in the source.
David Carlisle
- 757,742
5
The third line is split because it doesn't fit. But every \vspace material in a paragraph will be inserted after the line in which the command happens to fall (it uses \vadjust).
Just add \newline. And don't overcomplicate things.
\documentclass[border=2]{standalone}
\usepackage{amsmath}
\setlength{\fboxrule}{0.1pt}
\setlength{\fboxsep}{0pt}
\begin{document}
\fbox{%
\parbox{40mm}{
\parshape 4 0mm 40mm 5mm 35mm 10mm 30mm 15mm 25mm
\fbox{hello world}\newline
\fbox{hello world}\newline
\fbox{hello world}
\vspace{-\lineskip}\newline
\fbox{%
\parbox{24mm}{
\begin{gather*}
2+2=4
\end{gather*}
}%
}
}
}
\end{document}
egreg
- 1,121,712

\saveboxes to properly nesttikzpictures, see https://tex.stackexchange.com/q/47377/121799. – Jun 10 '19 at 18:31\parshapeif you are in vertical mode, as you are in a tikz node if you specify thetext widthkey.standaloneclass does not change that. – David Carlisle Jun 10 '19 at 19:44gatherhere which is a vertical mode display environment, but you do not need\parboxbasically if you usetext widthon a node it is a parbox already (actually it is aminipagebut that is almost the same thing, mostly using the same code.) – David Carlisle Jun 10 '19 at 20:24\parboxinside a node throws away information about top and bottom baselines of text in the node? – bp2017 Jun 10 '19 at 23:31text widthwithout\parboxfor vertical-mode math just now. Vertical spacing of the equation becomes uneven on the bottom compared to when\parboxis used. With\parboxthe equation's top and bottom spacing is even (without\parboxit's not). I guess that's one of the reasons I use\parbox. (I have to think of other reasons, nothing comes to mind yet.) But it's interesting that\parboxmakes information about vertical spacing to be lost inside the node. – bp2017 Jun 10 '19 at 23:34\strutin an earlier question – David Carlisle Jun 10 '19 at 23:36text widthdoesn't make\parshapework inside the node. (I am posting the code in the next comment.) – bp2017 Jun 12 '19 at 05:24\usepackage{tikz}
\begin{document} \begin{tikzpicture} \path node [ draw=blue, inner sep=0pt, line width=1.5pt, text width=40mm ] { \parshape 4 0mm 40mm 5mm 35mm 10mm 30mm 15mm 25mm \fboxrule0.1pt \fboxsep0pt \fbox{hello world}\newline \fbox{hello world}\newline \fbox{hello world} }; \end{tikzpicture} \end{document}
– bp2017 Jun 12 '19 at 05:24}I get indented boxes when I added linebreaks to your code from the comment, not really tikz, you would get the same from any group. – David Carlisle Jun 12 '19 at 06:59