[Tex/LaTex] How to move header and footer on left or right

fancyhdrheader-footer

I have a really nasty problem. I have to move page body OR header and footer on left or right on few pages in mid document, but I cant use a lot of useful stuff:

  • geometry package
  • \textwidth options
  • cant change margins – this makes footer and header move to the left border
    becouse it makes issues to the rest of figures in document.

The solution is quite obvious:

  1. move header, footer in left/right
  2. move only page body.

Best Answer

Try this code. What we need is edit:

\fancyheadoffset[LO,RE]{<dim>}
\fancyheadoffset[RO,LE]{-<dim>}

Here the complete example

\documentclass{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}



\renewcommand{\headrulewidth}{1pt}
\fancyhead[C]{\textbf{page \thepage}} 
\fancyhead[L]{\leftmark}
\fancyhead[R]{machin}

\renewcommand{\footrulewidth}{1pt}
\fancyfoot[C]{\textbf{page \thepage}} 
\fancyfoot[L]{truc}
\fancyfoot[R]{\leftmark}
\begin{document}
\lipsum[1-15]
\section{Test}
\lipsum[1-15]

\fancyheadoffset[LO,RE]{2cm}
\fancyheadoffset[RO,LE]{-2cm}

\section{and test}
\lipsum[1-15]
\end{document}
Related Question