3

I'm using tikzpicture with includegraphics to put a picture on a document. I would like to make the image bigger than usual, but if I do so, a blank page appears. I searched "remove blank pages" and found several questions and answers, but no one apparently fits with my problem.

Example of code

\documentclass{article}
\usepackage{tikz}
\usepackage[papersize={18.9cm,24.61cm}]{geometry}

\begin{document} \begin{center} \begin{tikzpicture}[x=1mm,y=1mm] \draw(0,0) rectangle (135,200); \end{tikzpicture} \end{center} \end{document}

If the rectangle is smaller, then no blank page apppear. I tried also to put the tikzpicture in a figure environment, but then the figure is "postponed" with respect where I want (even if I use the float position [h])

So, how can I remove the extra blank page? (or, alternatively, how can I force a figure to stay where I put?)

2 Answers2

3

Tex warns you

 Overfull \vbox (79.29863pt too high) has occurred while \output is active

so you have to save 80pt somewhere to make this fit. You could make the page bigger, but that isn't always an option, so you need to make a judgement on how much you want to overlap the top or bottom margin.

You also get

Overfull \hbox (8.08199pt too wide) in paragraph at lines 10--11

so may want to make similar horizontal adjustments as well.

Here I raise it up so it just clears the page number which you can just about do as there is no page heading.

You could lower the page number or use \thispagestyle{empty} to remove the number on this page, which would let you move it up less. There is no general fix, you need to adjust it by eye to what looks best for you.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage[papersize={18.9cm,24.61cm}]{geometry}

\begin{document} \begin{center} \vspace{-90pt} \hspace{-4pt}\begin{tikzpicture}[x=1mm,y=1mm] \draw(0,0) rectangle (135,200); \end{tikzpicture}\hspace*{-4pt}

\vspace*{-20pt} \end{center} \end{document}

David Carlisle
  • 757,742
  • I Just would like to remove the extra blank page, without touching margins or everything else – user126154 Jan 30 '21 at 14:03
  • @user126154 you have to overlap the margins one way or another as the tikz picture is bigger than the page, so this does answer your requirement exactly, it does not change the declared margin at all it just makes the image overlap, you choose how much it overlaps at top or bottom. – David Carlisle Jan 30 '21 at 14:07
  • Could you explain why I have to put \hspace*{-4} also after the picture. Thanks – user126154 Jan 30 '21 at 14:13
  • @user126154 it is 8pt too wide so you want to hide 8pt while keeping it centred so remove 4 from each side. – David Carlisle Jan 30 '21 at 14:16
  • Ok, that's a kind of patch, but still, if Ia have overfull, a blank page appears. I would like just to get ride off that blank page – user126154 Jan 30 '21 at 14:56
  • @user126154 that would require far reaching changes of LaTeX's output routine that would almost certainly clash with something. It might be possible but too big a change to post as an answer here. – David Carlisle Jan 30 '21 at 15:05
  • @user126154 better/simpler would be to not make the page over full, you can typeset the tikz to a box and measure it and if it is too big then scale or or add the negative vspaces as here. If you measure the tikz and you know the box is 50pt taller than the page you can add a negative space of 50pt and latex will never know it was too big – David Carlisle Jan 30 '21 at 15:07
  • you're right, but the whole thing probably just means that I'm not an experienced enough "LaTeXer" :) – user126154 Jan 30 '21 at 15:13
3

You could make the picture zero height and zero width.

\documentclass{article}
\usepackage{tikz}
\usepackage[papersize={18.9cm,24.61cm}]{geometry}
\begin{document}
\begin{center}
  \makebox[0pt]{\raisebox{-190mm}[0pt][0pt]{%
    \begin{tikzpicture}[x=1mm,y=1mm]
      \draw(0,0) rectangle (135,200);
    \end{tikzpicture}%
  }}
\end{center}
\end{document}

enter image description here

gernot
  • 49,614
  • This seems to work pretty well. This will be ok for printing purposes, or the pdf I create will cause problem because pictures are sized to zero? – user126154 Jan 31 '21 at 11:01
  • 1
    @user126154 The PDF doesn't care, it is just about tweaking TeX to position things the way you want. – gernot Jan 31 '21 at 11:16