TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm typesetting a book using the memoir document class. The overall layout comes with a background image. This image incorporates space for the page numbers in the footer which looks like a slot machine. This means that there exists an individual space for each number (up to three) with a fixed width and height.

I've already customized the \footskip and the overall size of header and footer to match the design. However, it is hard to get the numbers to fit exactly in the different "slots" of the slot machine background.

Is there a way to tell LaTeX how much space it should use for a glyph so that the page number fits the background image exactly?

share|improve this question
Welcome to TeX.sx! No need to add thanks, simply upvote any good replies you may receive. – Peter Jansson Feb 11 '13 at 23:48
Thanks for the warm welcome! I've successfully implemented David Carlisle's answer and extended it for odd/even pages. I'd like to post the addition to give something back --- where would I do that? The comments do not provide sufficient space for the code. – Technaton Feb 12 '13 at 15:58
You can self answer. You can even unaccept my solution and accept yours if you like, I'm not too desperate for the 15 points:-) – David Carlisle Feb 12 '13 at 16:29
Ok, I did that (answering my own question). Accepting my own answer would be rude, I guess, since without your answer I would never have been able to come up with the odd/even page numbers extension. Honour where honour's due. :-) – Technaton Feb 12 '13 at 18:25
up vote 6 down vote accepted

enter image description here

You probably don't want the \fbox and can adjust the coordinates to fit...


  \ifnum\value{page}<10 0\fi
  \ifnum\value{page}<100 0\fi








share|improve this answer

This is an extension of David Carlisle's answer which takes odd/even page numbers into account. It uses the offset parameter of the picture environment to place the picture box:


\def\evenpageslots#1#2#3{% \begin{picture}(46,20)(-32,-1) \put(0,0){\huge\textbf{#1}}% \put(16,0){\huge\textbf{#2}}% \put(31,0){\huge\textbf{#3}}% \end{picture}}

\def\pageslots{% \edef\tmp{% \ifnum\value{page}<10 0\fi \ifnum\value{page}<100 0\fi \arabic{page}}% \ifthenelse{\isodd{\value{page}}}% {\expandafter\oddpageslots\tmp}% {\expandafter\evenpageslots\tmp}}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.