I have a latex document of class book, with several chapters and a table of content. In the end, I add still a few pdf files using the includepdf command. The tricky part, however, is now to add still a black box with 'I' respective 'II' written in it, depending on the running index of the pdf. For the first pdf the black box should be in the upper right corner and only on the odd pages, for the second pdf the box should be under the first one and also only on the odd pages. What I have so far is
\documentclass[b5paper]{book}
\usepackage[final]{pdfpages}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\chapter{First Chapter}
\lipsum \lipsum
\newpage
\ifodd\value{page}
\AddToShipoutPictureBG{
\begin{tikzpicture}[remember picture,overlay]
\node[minimum width=2cm, minimum height=2cm, font=\Huge, rotate=90,
rectangle, opacity=1, fill=black, text=white]
at (current page.north east) {I};
\end{tikzpicture}
}
\fi
% Some pdf with several pages
%\includepdf[pages=-,pagecommand={},width=\textwidth]{1.pdf}
\lipsum
\newpage
\ifodd\value{page}
\AddToShipoutPictureBG{
\begin{tikzpicture}[remember picture,overlay]
\node[minimum width=2cm, minimum height=2cm, font=\Huge, rotate=90,
rectangle, opacity=1, fill=black, text=white]
at (current page.north east) {II};
\end{tikzpicture}
}
\fi
%\includepdf[pages=-,pagecommand={},width=\textwidth]{2.pdf}
\lipsum
\end{document}
(I commented the includepdf parts out, as I cannot add here any for a running example, hence some libpsum text instead...)
My problems are
- that the
ifoddcommand is not recognized - how to tell Latex to put the tikz figure only for those pages pages that are created with the next
inputpdfcommand - how to add an offset to the
atlocation part in the tikz figure.
EDIT:
Just for completeness, this is the fully functional block how I use it now (after accepting the answer) in front of each inputpdf and there I just adjust the coordinates by hand.
\AddEverypageHook{
\ifnum\value{page}>120
\ifnum\value{page}<137
{\ifodd\value{page}
\begin{tikzpicture}[remember picture,overlay]
\node[minimum width=2cm, minimum height=2cm, font=\Huge, rotate=90,
rectangle, opacity=1, fill=black, text=white]
at (14.2,-2) {II};
\end{tikzpicture}
\fi}
\fi
\fi}
current page.north eastthe black box is too far in the corner, so I would need to move it slightly to the left and down. Unfortunately thecalclibrary seems to collide with theinputpdflibrary and throws an error. Maybe the other option is to use only coordinates and figure it out by hand, where to place it. – Daniel Fischer Dec 04 '16 at 07:36