[Tex/LaTex] setting header inside document for some pages

fancyhdrheader-footer

How can I set different header for different sections. In this example I am looking for replacement of \SomeCommand

\documentclass{article}
\begin{document}

\SomeCommand{Header 1 define here} %this sets header for all pages until another \SomeCommand found

This is multi-page text
\newpage

\SomeCommand{Header 2 define here} %this changes the header to new 

This is multi-page text
\end{document}

My document is NOT arranged in \section and not a book. It is just plane text.

Best Answer

If there are no special layout requirements you can use the pagestyle myheadings. Then \SomeCommand has to set \markright{<text>} or maybe better \markboth{<text>}{<text>}. The second works also if your document is twoside.

\documentclass{article}
\pagestyle{myheadings}
\newcommand*\SomeCommand[1]{\markboth{#1}{#1}}

\usepackage{lipsum}% dummy text
\begin{document}
\SomeCommand{Header 1 define here}
\lipsum
\clearpage
\SomeCommand{Header 2 define here}
\lipsum
\end{document}
Related Question