Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It seems that the tikzpicture environment always leaves vertical mode, even when the overlay option is given (and thus the picture doesn't actually take any space). This can cause unexpected behaviour.

Is there a way to prevent TeX from leaving vertical mode?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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 \vboxes 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)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.