3

I figured out a strange behavior of my Latex document and can't explain it. The following code illustrates that. I have text and want to illustrate it with a complex tikz picture, which I shifted to another file because it needs very much space. Now if I create a pdf out of it I get three pages even though all contents fit to one page. I can't explain why that happens. Does anybody of you know?

Main File:

\documentclass{book}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{shapes,external}
\tikzexternalize
\usepackage{lipsum}
\tikzset{naming/.style={align=center,font=\footnotesize}}
\tikzset{area/.style = {draw, shape = regular polygon, regular polygon sides = 6, thick, minimum width = 5cm}}
\begin{document}
\lipsum[2]

\include{tikzcode}

\lipsum[2]
\end{document}

Simplified tikz file:

\begin{figure}[htb]
\centering
\begin{tikzpicture}[font=\footnotesize]
\node [area] at (0,0) (cell1) {};
\end{tikzpicture}
\caption{test}
\label{fig:test}
\end{figure}

If I include the tikz picture into the main file I get the one-sided pdf I want to have. But due to the fact that the picture is very extensive it would lead to a very confusing long document, because I have several pictures I want to include in that way and always the same happens.

Thank you very much for your help. Martin

4
  • 2
    Try to use \input instead of \include.
    – Jürgen
    Mar 29, 2017 at 7:21
  • 3
    \include starts a new page, while \input doesn't.
    – Ignasi
    Mar 29, 2017 at 7:24
  • For an explanation of the differences between these two commands eg. see here tex.stackexchange.com/questions/246/…
    – Jürgen
    Mar 29, 2017 at 7:28
  • Thank you for the link and the help, it works now and I'm happy. Mar 29, 2017 at 7:58

1 Answer 1

4

So, the answer should simply be: Change \include to \input.

\documentclass{book}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{shapes,external}
\tikzexternalize
\usepackage{lipsum}
\tikzset{naming/.style={align=center,font=\footnotesize}}
\tikzset{area/.style = {draw, shape = regular polygon, regular polygon sides = 6, thick, minimum width = 5cm}}
\begin{document}
\lipsum[2]

\input{tikzcode} % that does not insert page breaks

\lipsum[2]
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .