# Create and depict hole punch holes on every page of a document

I know this is probably one of the weirdest requests on this forum, but I am just not getting anywhere on my own. I use latex to write my worksheets for my students. I often use the margins for tips and hints or small graphics. Unfortunately, the problem arises that the students obviously often want to print the sheets and then the hole punch holes hit those little graphics. I would like to get around that. Is there any chance to define a tikz picture or something else, which depicts the two hole punch holes on all pages while I write on the worksheets to place the margins entries appropriately?

I literally have no idea on how to even get started.

You can avoid atbegshi using the \AddToHook command. Here is a MWE, taking the tikz code by Dr. Manuel Kuehner. The output is the same:

\documentclass{article}
\usepackage{tikz}
\usepackage{blindtext}

\begin{tikzpicture}[overlay,remember picture,every node/.style={circle, minimum height=5mm,minimum width=5mm,draw, xshift = 6mm}]
\draw (current page.west) node[yshift = 30mm]{};
\draw (current page.west) node[yshift = -30mm]{};
\end{tikzpicture}%
}

\begin{document}

\blindtext[6]

\end{document}


### EDIT

SebGlav's observation is quite right. In a two-sided document, holes cannot be placed on the left on every page, but left on odd pages and right on even pages. There are two solutions: 1) leave the even pages blank; 2) draw the holes on the right in the even pages

Solution 1) Holes only on odd pages:

\AddToHook{shipout/background}{%
\ifodd\value{page}
\begin{tikzpicture}[overlay,remember picture,every node/.style={circle, minimum height=5mm,minimum width=5mm,draw, xshift = 6mm}]
\draw (current page.west) node[yshift = 30mm]{};
\draw (current page.west) node[yshift = -30mm]{};
\end{tikzpicture}%
\fi
}


Solution 2) Holes on the left and right, respectively, in the odd and even pages:

\AddToHook{shipout/background}{%
\ifodd\value{page}
\begin{tikzpicture}[overlay,remember picture,every node/.style={circle, minimum height=5mm,minimum width=5mm,draw, xshift = 6mm}]
\draw (current page.west) node[yshift = 30mm]{};
\draw (current page.west) node[yshift = -30mm]{};
\end{tikzpicture}%
\else
\begin{tikzpicture}[overlay,remember picture,every node/.style={circle, minimum height=5mm,minimum width=5mm,draw, xshift = -6mm}]
\draw (current page.east) node[yshift = 30mm]{};
\draw (current page.east) node[yshift = -30mm]{};
\end{tikzpicture}%
\fi
}


Solution 2bis) Like above, but saving a few lines of code:

\newcommand{\printholes}[2]{%
\begin{tikzpicture}[overlay,remember picture,every node/.style={circle, minimum height=5mm,minimum width=5mm,draw, xshift = #1}]
\draw (current page.#2) node[yshift = 30mm]{};
\draw (current page.#2) node[yshift = -30mm]{};
\end{tikzpicture}%
}
\ifodd\value{page}
\printholes{6mm}{west}
\else
\printholes{-6mm}{east}
\fi
}

• Very nice and customizable. And if one has to print 2-sided documents? Mar 21, 2021 at 20:25
• @SebGlav Maybe one can use this texfaq.org/FAQ-oddpage within the \AddToHook. Or see tex.stackexchange.com/questions/154256 (\ifodd\value{page}). Mar 21, 2021 at 22:23
• @SebGlav Thanks for the suggestion. You are right. I did not think about it, I edited the answer.
– Ivan
Mar 21, 2021 at 23:12
• I am unable to have this compile. ... Undefined control sequence \AddToHook{...}. TexLive 2020 with pdfTeX. Mar 21, 2021 at 23:24
• Is your TeX Live distribution updated?
– Ivan
Mar 21, 2021 at 23:52

\documentclass[]{article}
\usepackage{tikz}
\usepackage{blindtext}
\usepackage{atbegshi} % https://www.ctan.org/pkg/atbegshi

\newcommand\myPunchHole{%
\begin{tikzpicture}[remember picture,overlay]
\draw (current page.west) node[circle, minimum size=5mm, draw, xshift = 6mm, yshift = 30mm]{};
\draw (current page.west) node[circle, minimum size=5mm, draw, xshift = 6mm, yshift = -30mm]{};
\end{tikzpicture}%
}

\AtBeginShipout{\myPunchHole}
\AtBeginShipoutFirst{\myPunchHole}

\begin{document}

\blindtext[6]

\end{document}


Related

• Just to be clear, this requires two cycles of compilation to print the holes, right? Mar 21, 2021 at 23:27
• @Jeffrey J Weimer Yes. Mar 21, 2021 at 23:39
• @JeffreyJWeimer Yes (my last comment was done on my smartphone where the autocomplete for "@" does not work) Mar 22, 2021 at 18:17
• Thank you for the response. Mar 22, 2021 at 20:06