1

I am working on slides in beamer with a modified version of the Torino theme. When drawing with TikZ, the absolute positioning seems to not work as expected. In particular, when I have two tikzpicture environments and I reference back to the previous one from the latter, the coordinates are off.

\begin{frame}
  \begin{tikzpicture}[overlay, remember picture]
    \coordinate (topcorner) at (0,0);
    \coordinate (rightcorner) at (5,-2);
    \coordinate (bottomcorner) at (3,-2);
    \draw (topcorner) -- (rightcorner);
  \end{tikzpicture}%

  \begin{tikzpicture}[overlay, remember picture]
    \draw (topcorner) -- (bottomcorner);
  \end{tikzpicture}
\end{frame}

Specifically, the line in the second tikzpicture is drawn lower than it should be, corresponding with the spacing for the paragraph between the tikzpicture environments. The first line is drawn on (0,0) -- (5,-2) whereas the second line more or less corresponds with (0.95,0) -- (3.95,-2). If there is no paragraph or newline between the environments, then the problem does not occur.

Furthermore, the problem does not occur in a blank LaTeX document (i.e. there does not appear to be anything at fault with the above code), nor does it occur when I revert to the clean Torino theme. Apparently, some of the alterations that I have made seem to have an effect on the absolute positioning of TikZ. However, even after considerable effort, I am not able to create a minimally working example. This makes it hard to pinpoint whether some package, option, custom command ... is at fault. Hence my question:

Which settings/packages/options/ ... might affect the absolute positioning in TikZ from not working as expected? Any plausible causes? I seem to remember having the very same problem a couple of years ago, though I fail to remember whether the problem was ever resolved back then.

edit with an MWE

After solving the problem, finding an MWE is trivial. To keep my slides nice and clean, I tend to use a large auxiliary file that loads the required packages, defines some useful commands ... . The structure is as follows:

I have a file preamble.tex containing

\documentclass{beamer}
\usepackage{tikz}

Furthermore, the actual file (e.g. slides.tex) has the following lines:

\include{preamble}

\begin{document}
  ... (the frame defined above)
\end{document}

This does not work however and causes the absolute positioning of TikZ to fail.

  • I have the same (correct) result in beamer as well as in article. But what is \drawhelp? Please post a full minimal working example (MWE)! – Qrrbrbirlbel Aug 13 '13 at 22:09
  • \drawhelp was used during debugging and is of no importance (it has been removed). I would post a MWE if I could. Chances are that finding this MWE will solve the question, which in turn will hopefully help others who have similar issues. – kvaruni Aug 14 '13 at 6:16
  • That was quick. I have isolated the issue, and it has everything to do with a very, very bad use of input. I will update the question accordingly and formulate an answer. – kvaruni Aug 14 '13 at 6:34
1

The problem has to do with how the auxiliary file is included in slides.tex. Specifically, the use of include{preamble} should be avoided at all costs and writing input{preamble} instead solves the issue. The problem with \include{..} is that a \clearpage is added before and after this command and some magic also happens in terms of writing to additional .aux files. This has some profound implications, and one of those implications is that \include{..} should never be used in the preamble as it may result in some odd behaviour (as is seen in this problem). More information of the distinction between \input and \include can be found here: When should I use \input vs. \include? .

So, essentially: use \input{file} instead of \include{file} and the absolutely positioning of TikZ works like a charm!

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.