I am creating an automatically generated periodic report with Sweave. To create a good header, I use the fancyhdr package, which has worked very well so far. Now, since my report is periodic, I want to dynamically change the header without passing an argument to the function. This is why I wrote a little R function that simply checks which period is the last. Based on this, the title bar is generated in R.
In short, I know that LaTeX has \ today, but I need to use the specific information coming from R, not just the date.
Here is my code:
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{
\renewcommand{\sectionmark}[1]{%
\markright{\thesection\
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\rightmark{
<<>>=
print(TexHeader)@
}}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt}
\fancypagestyle{plain}{%
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}}
which causes the following error:
Package Fancyhdr Warning: \fancyhead `E' option without twoside option is use
less on input line 23.
This is exactly the line where my TexHeader is located.