I've been playing with the design of a letterhead class for our department. We want two pictures on the header, with a line under it; and the address on the footer, with a line over it. Here is a MWE that works OK:


% Class declaration
\ProcessOptions \relax

% Packages

% Colors

% Change width and color of the lines under header and over footer
\renewcommand{\headrule}{\hbox to\headwidth{\color{xLine}\leaders\hrule height \headrulewidth\hfill}}
\renewcommand{\footrule}{\hbox to\headwidth{\color{xLine}\leaders\hrule height \footrulewidth\hfill}}

  Our Department\\
  Our University\\
  Our Address -- a longer line\\
  Our phone number -- Our e-mail}


I've added some images to the header, just in case here they are: logo1 logo2


\begin{Large}Yay, a document!\end{Large}

Two runs with pdflatex gives this:


Looking good! But now I want to add a number to each page. I could add a \thepage in any position on the footer, but I'd rather have the number on the right side of the footer:

where I want it

Based on TikZ full page with absolute node positioning I've tried to define a tikz figure with

\begin{tikzpicture}[remember picture,overlay]
 \node[anchor=north,minimum height=0.7cm, minimum width=2cm] (names)
   at ([xshift=8.5cm,yshift=3cm]current page.south) {\color{xLine}\Large\thepage};

and this to the definition of \fancypagestyle

  \chead{\mypagenumber} % Why not? as long as it appears on every page

(added these to mwe.cls)

Results are almost what I want: pages 1-9 looks OK:

enter image description here

But as soon as I get two digits on the number page alignment gets bad:

enter image description here

Finally, here are the questions:

  1. How can I define my tikzpicture so the number will be right-aligned with the horizontal line over the footer, even if I change the text size or font?
  2. Is it possible to define the values (anchors, shifts, etc.) in tikzpicture in such a way that if I change the page margins or paper size I don't need to change these values? E.g. is it possible to make the tikzpicture position relative to the line over the footer?
  3. It works but it seems a ugly hack, is there a better/simpler/more robust way?


Here's something that works (based on a different tikz issue in Left and right align inside one TiKZ rectangular node):

\begin{tikzpicture}[remember picture,overlay]
 \node[fill=gray!20,anchor=north,minimum height=0.7cm, 
       text width=3cm,align=flush right] (names)
   at ([xshift=6.97cm,yshift=3cm]current page.south) 

There is a gray background to help visualize the alignment:

enter image description here enter image description here

Still questions 2 and 3 remain, I had to adjust the xshift parameter until I got the results I wanted -- not sure it is robust. Any help appreciated.

Thanks, Rafael

  • 1
    Does adding left to \node[anchor=north,...] help?
    – user31729
    Commented Feb 4, 2018 at 21:12
  • 1
    Change anchor=north to anchor=north east. However, this probably isn't the best way to do it. (I mean, this method generally.)
    – cfr
    Commented Feb 4, 2018 at 21:19
  • @ChristianHupfer: adding just a "left" changed the position of the text. I've fixed it through the xshift and yshift parameters but the problem is still there: the page numbers are not aligned to the right. Commented Feb 4, 2018 at 22:25
  • @cfr : results still not aligned. Commented Feb 4, 2018 at 22:28
  • @RafaelSantos: Did you try cfr's suggestion then?
    – user31729
    Commented Feb 4, 2018 at 22:28

1 Answer 1


What about this:

        \begin{tikzpicture}[remember picture,overlay]
        \node[fill=gray!20,anchor=east,minimum height=0.7cm, 
        text width=3cm,align=flush right] (names)
        at (current page footer area.south east) 
     \begin{Large}Yay, a document!\end{Large}

When compiling the original first, I got an error message; it seems that


appears twice in mwe.cls.

  • Much better, got rid of the {x,y}shifts! Thanks! Commented Feb 5, 2018 at 22:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .