0

I have a document with a large tikz image. To display this image using pdflatex, I've created macros to switch papersize, and I'm using the pdflscape package to rotate the pages when displayed in the pdf viewer. Using this technique, I'm able to display the figure as desired on a rotated larger-size page, but the following page is missing the page number in the footer (and without a manual \clearpage, text doesn't properly break to the next page, instead it continues through the footer and into the invisible abyss beyond). At the second page following the figure, the page number returns.

The minimum working example below demonstrates this phenomenon:

\documentclass{article}
\usepackage{tikz}
\usepackage{pdflscape}

\usetikzlibrary{shapes}

% Macros for changing paper size
\newcommand{\startPaperSizeB}{%
  \begingroup
  \clearpage
  \setlength{\pdfpagewidth}{11in}
  \setlength{\pdfpageheight}{17in}
  \setlength{\paperwidth}{\pdfpagewidth}
  \setlength{\paperheight}{\pdfpageheight}
  \setlength{\oddsidemargin}{0pt}
  \setlength{\textwidth}{650pt}
  \setlength{\topmargin}{0pt}
  \setlength{\headheight}{0pt}
  \setlength{\headsep}{0pt}
  \setlength{\textheight}{1084pt}
  }

\newcommand{\stopPaperSizeB}{\endgroup \clearpage}

\begin{document}

Some text on the first page.

\startPaperSizeB
\begin{landscape}

\begin{figure}
  \centering
    \begin{tikzpicture}[]
    \node [draw, rectangle, minimum height=625pt, minimum width=1000pt] (1) {};
  \end{tikzpicture}  
  \caption{Caption for the large size figure}
\end{figure}

\end{landscape}
\stopPaperSizeB

Missing page number on this page?

\clearpage

Now the page number is back!

\end{document}

I recently asked a very similar question, execpt I left the figure out of the MWE. This question was answered, but the solution doesn't work when inserting a tikzpicture on the larger landscape page - instead, there is no larger landscape page and no figure - they just disappear. I get a warning about an overfull box, but no figure. The MWE below demonstrates this:

\documentclass{article}
\usepackage{tikz}
\usepackage{pdflscape}

\usetikzlibrary{shapes}

% Macros for changing paper size
\newcommand{\startPaperSizeB}{%
  \setlength{\pdfpagewidth}{11in}
  \setlength{\pdfpageheight}{17in}
  \setlength{\paperwidth}{\pdfpagewidth}
  \setlength{\paperheight}{\pdfpageheight}
  \setlength{\oddsidemargin}{0pt}
  \setlength{\textwidth}{650pt}
  \setlength{\topmargin}{0pt}
  \setlength{\headheight}{0pt}
  \setlength{\headsep}{0pt}
  \setlength{\textheight}{1084pt}
  }

\newcommand{\stopPaperSizeB}{}

\begin{document}

Some text on the first page.

\begin{landscape}
\startPaperSizeB

\begin{figure}
  \centering
    \begin{tikzpicture}[]
    \node [draw, rectangle, minimum height=625pt, minimum width=1000pt] (1) {};
  \end{tikzpicture}  
  \caption{Caption for the large size figure}
\end{figure}

\stopPaperSizeB
\end{landscape}

The page number is here, but the figure is not.

\end{document}

If the size of the rectangle is reduced enough (to 525 by 550, for example), then the figure appears on a page at the end of the document, although the page is a normal size and the figure runs off the page. This led me to try the [H] option from the float package, which seems to be getting me closer, but I'm still not there. Any ideas?

1 Answer 1

1

I've found an acceptable answer using the geometry package to adjust the size of the text area (the geometry package on its own doesn't allow for mid-document papersize changes). It is important to set the textwidth and textheight using the \newgeometry command (there are odd effect when setting these without using the geometry package, and to do this prior to beginning the landscape environment. Also, \restoregeometry must be called after leaving the landscape environment.

The example below fixes both the page numbering issue as well as the disappearing tikz figure issue.

\documentclass{article}
\usepackage{tikz}
\usepackage{pdflscape}
\usepackage[papersize={8.5in,11in}]{geometry}
\usepackage{lipsum}

\usetikzlibrary{shapes}

% Macros for changing paper size
\newcommand{\startBSizeLandscape}{%
  \newgeometry{textwidth=614pt, textheight=1084pt}
  \begin{landscape}
  \setlength{\pdfpagewidth}{11in}
  \setlength{\pdfpageheight}{17in}
  \setlength{\paperwidth}{\pdfpagewidth}
  \setlength{\paperheight}{\pdfpageheight}
  \setlength{\oddsidemargin}{0pt}
  \setlength{\evensidemargin}{0pt}
  \setlength{\marginparwidth}{0pt}
  \setlength{\topmargin}{0pt}
  \setlength{\headheight}{0pt}
  \setlength{\headsep}{0pt}
  }

\newcommand{\stopBSizeLandscape}{%
  \end{landscape}
  \restoregeometry
  }

\begin{document}

\lipsum

\startBSizeLandscape

\begin{figure}
  \centering
    \begin{tikzpicture}[]
    \node [draw, rectangle, minimum height=589pt, minimum width=1000pt] {};
  \end{tikzpicture}  
  \caption{Caption for the large size figure}
\end{figure}

\stopBSizeLandscape

\lipsum

\end{document}

Compiling this does result in a warning: 'tmargin' and 'bmargin' result in NEGATIVE (-289.03001pt). 'height' should be shortened in length. Of course, reducing the textheight does prevent this warning, but instead generates an overfull box warning. A better solution would be warning-free.

You must log in to answer this question.

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