4
\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}
12
  • 1
    You can use \saveboxes to properly nest tikzpictures, see tex.stackexchange.com/q/47377/121799. – user121799 Jun 10 '19 at 18:31
  • why have you got those parboxes there at all?, you can remove both of them. – David Carlisle Jun 10 '19 at 19:23
  • 1
    @bp2017 you are using gather here which is a vertical mode display environment, but you do not need \parbox basically if you use text width on a node it is a parbox already (actually it is a minipage but that is almost the same thing, mostly using the same code.) – David Carlisle Jun 10 '19 at 20:24
  • 1
    @bp2017 yes if course, a parbox only has a single reference point, by default in its vertical centre, so there is only one baseline as far as the node can see. If you put a paragraph directly in the node then it can be aligned on the top or bottom baseline or the vertical center, that was why you had to use \strut in an earlier question – David Carlisle Jun 10 '19 at 23:36
  • 1
    @bp2017 hard to tell with comment formatting but you are probably missing a blank line at the end of the paragraph before the } 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 6:59
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}

enter image description here

0
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.

0

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.