0

I'm trying to typeset a book in which the only content on every page is a TikZ diagram. I want the diagram to fill all of the available page space, so I'm using custom margins via the geometry package. The first page of the document looks about like I want and I expected the second page to look like a mirror image, but that's not what I get. The first page has a much larger left margin than right margin, but the second page's left and right margins look about equal.

Below is my code, stripped down to the bare essentials to illustrate the problem. To keep the code brief, I've just shaded where the diagram would be rather than including the whole of the diagram.

\documentclass[letterpaper]{book}
\usepackage[top=0.1cm, bottom=0.1cm, inner=0.6cm, outer=0.106cm]{geometry}
\usepackage{tikz}

\newcommand\picturewidth{580pt}
\newcommand\pictureheight{788pt}
\definecolor{mygray}{gray}{0.8}

\begin{document}
\begin{tikzpicture}
\path (0pt,0pt);
\fill [mygray](0pt,0pt) rectangle (\picturewidth,\pictureheight);
\end{tikzpicture}


\begin{tikzpicture}
\path (0pt,0pt);
\fill [mygray](0pt,0pt) rectangle (\picturewidth,\pictureheight);
\end{tikzpicture}
\end{document}
2
  • 1
    Welcome! Does putting \centering after \begin{document} give you what you want? – user194703 Apr 22 '20 at 0:10
  • Thanks for the quick response! it got me 90% of the way to where I was trying to go, but John Kormylo's response really got me all the way there. – nruegs Apr 22 '20 at 13:08
1

It is easier to overlap the margins than change them. Don't forget to run twice.

If you are going to put these in floats, you need to use the ifoddpage package, as \value{page} is not reliable.

\documentclass[letterpaper]{book}
%\usepackage[top=0.1cm, bottom=0.1cm, inner=0.6cm, outer=0.106cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}

\definecolor{mygray}{gray}{0.8}

\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture, overlay]
\ifodd\value{page}
  \fill [mygray] ($(current page.south west)+(0.6cm,0.1cm)$) rectangle
    ($(current page.north east)+(-0.106cm,-0.1cm)$);
\else
  \fill [mygray] ($(current page.south west)+(0.106cm,0.1cm)$) rectangle
    ($(current page.north east)+(-0.6cm,-0.1cm)$);
\fi
\end{tikzpicture}
\newpage

\thispagestyle{empty}
\begin{tikzpicture}[remember picture, overlay]
\ifodd\value{page}
  \fill [mygray] ($(current page.south west)+(0.6cm,0.1cm)$) rectangle
    ($(current page.north east)+(-0.106cm,-0.1cm)$);
\else
  \fill [mygray] ($(current page.south west)+(0.106cm,0.1cm)$) rectangle
    ($(current page.north east)+(-0.6cm,-0.1cm)$);
\fi
\end{tikzpicture}
\end{document}
1
  • That looks like it solved it, thanks a lot! – nruegs Apr 22 '20 at 13:09

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.