I am writing a class template for some documents and would like the \rhead{...} to be right aligned (as it normally is).

However with the setup i currently have, the header not on the far right; it is similar to the problem of this question, but I already set the page geometry before initializing the header.

\ProvidesClass{docu}[2020 v1.0 Documentation]


\geometry{ a4paper
         , portrait
         , top    = 4cm
         , bottom = 3.5cm
         , left   = 6cm
         , right  = 3cm }


    \tikzstyle{line} = [draw,thick, draw=maroon]
            \path [line] (-2,0) -- (-2,0.5);
            \path [line] (-2,0.5) -- ({#1},0.5);



\title{Hello, World!}





    \newgeometry{ a4paper
                 , portrait
                 , top    = 3cm
                 , bottom = 3.5cm
                 , left   = 3cm
                 , right  = 3cm }




        \hspace{-0.51cm}\tikzstyle{line} = [draw,thick, draw=maroon]
            \path [line] (-0.06,0.5) -- (-15.5,0.5);
            \path [line] (-15.5,0.5) -- (-15.5,0);
        % \hrule width \hsize \kern 1mm \hrule width \hsize height 2pt 




I have enabled the frames to find the problem but was unable to do so until now: The right header as well as the footer are not aligned with the text itself although I create the fancyhdr after i initialize a new geometry.

what it looks like

Is this due to some kind of package conflict? How can I fix it?

my main.tex:


\title{My Program Name}
\version{Final Version}


\section{test section}
\subsection{test subsection}
\lipsum\footnote{This is a test footnote}


  • i added my main.tex; the first page has a different page size; (more left indent) the rest should have the standard 3.5cm from the left; Commented Feb 5, 2020 at 10:28
  • well the first geometry is used for the first page; then I set a new geometry for the table of contents and the rest of the document Commented Feb 5, 2020 at 11:09
  • isnt the \geometry at the top used for the title page and thereafter the newgeometry for the next pages? the titlepage corresponds to the geometry specified after the usepackages and the next pge (containing the toc) uses the geometry specified by the newgeometry; at least in the pdf compiled with xelatex in my machine Commented Feb 5, 2020 at 14:32
  • sorry I misread the code (it's somewhat unusual to have a multipage \maketitle :-) But my comments were wrong so i deleted them sorry. I'll trace what's happening this evening if no one answered by then, can't look now Commented Feb 5, 2020 at 14:35

1 Answer 1


You are not setting the geometry before initializing the headers. You have


in two places in your code.

You can reset the headwidth after the \newgeometry by calling this command:

    \newgeometry{ %a4paper    %unused anyway
                  %, portrait %unused anyway
                 , top    = 3cm
                 , bottom = 3.5cm
                 , left   = 3cm
                 , right  = 3cm }
  • i deleted the second \pagestyle...cyhf{} now and added the command you mentioned; where can i find documentation on the \f@nch@setoffs command? Commented Feb 7, 2020 at 23:33

You must log in to answer this question.

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