As part of a layout for a home made recipe book, I'm trying to lay out a series of text boxes at absolute positions on a page. I'm using eso-pic
to put a background image on the page which has openings for the text I'm trying to lay out such as ingredients and directions.
I'm currently using the eso-pic
AddToShipoutPictureFg
to handle each block of text which resides in a rotated minipage. If I understand correctly, the arguments to AddToShipoutPicture
will only get expanded at the end of the page. This is creating problems when I'm using a changing definition such as a counter inside the AddToShipoutPicture
macro.
Here is an example showing the method I'm using for multiple rotated text boxes.
\documentclass[twoside,openright,letterpaper,11pt]{memoir}
\usepackage{rotating}
\usepackage{eso-pic}
\newcounter{mycounter}
\setcounter{mycounter}{1}
\begin{document}
% First chunk of angled boxed text.
\AddToShipoutPictureFG*{
\setlength{\unitlength}{1in}
\put(2,6){% Or in my document \put(Xcoord,Ycoord)
\begin{rotate}{45}
\begin{minipage}[t]{1in}
This is some text. I expect
the counter to be 1, counter is \themycounter.
\end{minipage}
\end{rotate}
}
}
\stepcounter{mycounter}
% Or in my document:
% \renewcommand{\Xcoord}{calculated X position}
% \renewcommand{\Ycoord}{calculated Y position}
% Second chunk of angled boxed text.
\AddToShipoutPictureFG*{
\setlength{\unitlength}{1in}
\put(2,8){% Or in my document \put(Xcoord,Ycoord)
\begin{rotate}{-30}
\begin{minipage}[t]{1in}
This is some more text. I expect
the counter to be 2, counter is \themycounter.
\end{minipage}
\end{rotate}
}
}
\null
\end{document}
This is the result, showing that the counter's value is always at the last value set:
How can the expansion of the counter's value be forced at the time AddToShipoutPictureFG
appears in the source text so that the output at the red arrow shows 1
rather than 2
?
NOTE 1: I'm a newbie using pdflatex. If there's an easier way to get multiple rotated, absolute positioned text boxes on the page please advise. I tried using the rotating
package with textpos
environment but they don't appear to play nice together – rotation occurs about a point in the text block that I can't determine.
NOTE 2: I've used a counter for the purposes of this example to illustrate a changing definition between AddToShipoutPictureFG
calls. What I have in my document in place of \stepcounter{mycounter}
is a macro which redefines an X, Y coordinate pair for the following text box which is used inside the next AddToShipoutPictureFG
call. Of course the X, Y definitions at page end are the last X,Y set and so the text boxes always appear on top of each other rather than at the X,Y coordinate set before each AddToShipoutPictureFG
call.
Best Answer
put
immediately after the
\themycounter
so it is incremented after it is used. As is you are incrementing it on the main flow but using it twice in the output routine