# Modifying content of existing headers

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.

Thanks!

Edit:

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

\documentclass{article}

\usepackage{fancyhdr}
\usepackage{filecontents}

% Another file defines a header, which I want to modify.
\begin{filecontents*}{style.cls}
\pagestyle{fancy}
\end{filecontents*}
\input{style.cls}

% This line overwrites the previously defined header,
% whereas I would like to keep the previous contents
% and also add my own.

• 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. – Andrew May 12 '19 at 6:35