I am using a document class that sets up some headers (using fancyhdr), and I would like to modify (not overwrite) these headers. For example:

The document class creates a right-side header saying "Default Text." I would like to change this to say "Default Text. My Text."

In my tex file, if I write:

\fancyhead[R]{My Text.}

then the text that was previously included in the right-side header gets erased and only "My Text." appears.

Is there some way to retrieve the contents of the header, such that I can reuse that content in my modified header? Something like:

\fancyhead[R]{\fetchRightHeader My Text.}

which (ideally) would result in the right-side header saying "Default Text. My Text."

In case it matters: I need to modify the right-side header on even pages and the left-side header on odd pages. The document class includes different text on the left and right side.

Bonus question: Is there a way to modify a fancypagestyle defined by the document class? The document class sets up a different style for the first page in order to use different headers for that page. I would like to modify these first page headers too.



As suggested by Andrew, here is a minimal working example.



% Another file defines a header, which I want to modify.
  \fancyhead[R]{Default Text.}

% This line overwrites the previously defined header,
% whereas I would like to keep the previous contents
% and also add my own.
\fancyhead[R]{My Text.}

\section{Section 1}
Foo bar baz.

Here is the resulting PDF output from the above example:

Actual output from the example

For reference, here is my desired output:

Desired output

  • 3
    Welcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Currently we have to guess how you are defining your headers etc this makes it really hard to help you. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. It is really difficult to help you without more information.
    – user30471
    May 12, 2019 at 6:35
  • Thank you for the suggestion, @Andrew! I edited my post to include a minimal working example. May 12, 2019 at 20:01
  • To (re-) text, put it into a newcommand, first: ˋ\newcommand\mine[0]{my trxt}ˋ and call ˋ\mine{}ˋ .
    – MS-SPO
    Aug 4, 2023 at 10:28

2 Answers 2


For me worked doing

 % header contents
 % specific page header content

For clarification, I created a general header using \fancyhf[H]{} and then created a specific page header using \fancypagestyle{}{}, I cannot say when this feature was implemented and if this answer is worth anything, but I'll leave it here for people who could stumble here like I had.


You can also save contents in macros, then use other macros to modify:

\edef\versoheadtext{Starting Verso Header}
\edef\rectoheadtext{Starting Recto Header}
\changerectohead{ ..darker}
\changeversohead{ ..stormier}

You must log in to answer this question.

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