2

I want to place a tikzpicture in landscape mode in the center of an A4 page. However, I can't use the \textwidth and \textheight commands because this will result in overfull \hbox... or overfull \vbox... errors and an empty first page. I assume there is some tiny margin or indentation somewhere somehow?

I've looked at a couple of threads here, but nothing worked so far. MWE:

\documentclass[a4paper,landscape]{minimal}

\usepackage[margin=1cm]{geometry}
\usepackage{tikz}

\begin{document}
\begin{center}
\begin{tikzpicture}
  \draw (0, 0) rectangle (0.999\textwidth,0.999\textheight);

  % this will give "overfull \hbox..." or "overfull \vbox..." errors
  % and create an empty first page
  % \draw (0, 0) rectangle (\textwidth,\textheight);
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

Thank you!

4

Welcome! You need to take into account the line width. (I switched to article, as suggested by fractal.) On each end, the bounding box will be increased by \pgflinewidth/2, so you need to correct for that.

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}

\begin{document}
%\begin{center} %<- not needed
\noindent\begin{tikzpicture}
  \draw (0, 0) rectangle (\textwidth-\pgflinewidth,\textheight-\pgflinewidth);
\end{tikzpicture}
%\end{center}
\end{document}
|improve this answer|||||

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.