I think the problem is not that TeX leaves vertical mode - if you capture the content into a \vbox
, the "leave vertical mode" command is restricted locally to that box.
The problem is how TeX appends vertical boxes to each other: it does so by inserted interlineskip.
I have experimented a little bit using three \vbox
es which are put above each other -- trying to eliminate the size of the box in the middle. I succeeded when I used \nointerlineskip
in front of it.
Here is my example:
\documentclass{article}
\usepackage{tikz}
\begin{document}
Without Text:
\vbox{A vertical box}%
\vbox{A vertical box}%
\vskip3cm
With Text:
%\offinterlineskip
\vbox{A vertical box}%
\nointerlineskip
\vbox to 0pt{%
hallo
}%
%\begin{tikzpicture}[overlay]
%\draw (0,0) circle(1cm);
%\end{tikzpicture}%
\vbox{A vertical box}%
\vskip3cm
With Picture instead of text (should be the same):
%\offinterlineskip
\vbox{A vertical box}%
\nointerlineskip
\vbox to 0pt{%
\tikz \draw (0,0) circle(1cm);
}%
\vbox{A vertical box}%
\end{document}
The \offinterlineskip
would disable interline skip for all boxes, whereas \nointerlineskip
deactivates it only for the next.
I hope that this actually captures the problem (but perhaps I got it all wrong)