Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 962745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:33:24+00:00 2026-05-16T01:33:24+00:00

I am generating an automatically generated periodical report with Sweave. In order to create

  • 0

I am generating an automatically generated periodical report with Sweave. In order to create a nice header I use the fancyhdr package which works really well so far. Now, since my report is periodical I want to change the header dynamically without passing an argument to the function. That’s why I wrote a little R function that just checks which period is the latest.
Based on this a Header String is generated in R.

Long story short, I know that there is \today in LaTeX but I need to use the specific information coming from R, not just the date.

Here’s my code:

   \usepackage{fancyhdr}
 \pagestyle{fancy}

\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\thesection\ #1}}
\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's `E' option without twoside option is use
less on input line 23.

This is exactly the line where my TexHeader is placed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:33:25+00:00Added an answer on May 16, 2026 at 1:33 am

    For one-sided documents you can use \fancyhead[L]{...} and \fancyhead[R]{...}.

    Furthermore, in this case, it’s better to use <<results=tex, echo=FALSE>>=.
    Here’s an example:

    \documentclass[a4paper]{report}
    \usepackage{fancyhdr}
    \usepackage{lipsum}
    \pagestyle{fancy}
    \renewcommand{\chaptermark}[1]{%
    \markboth{#1}{}}
    \renewcommand{\sectionmark}[1]{%
    \markright{\thesection\ #1}}
    \fancyhf{}
    \fancyhead[R]{\bfseries\thepage}
    \fancyhead[L]{\rightmark{%
    <<results=tex, echo=FALSE>>=
    TexHeader <- format(Sys.time(), "%c")
    cat(TexHeader)
    @
    }}
    \renewcommand{\headrulewidth}{0.5pt}
    \renewcommand{\footrulewidth}{0pt}
    \addtolength{\headheight}{0.5pt}
    \fancypagestyle{plain}{%
    \fancyhead{}
    \renewcommand{\headrulewidth}{0pt}}
    
    \begin{document}
    \lipsum
    \end{document}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with generating an XML that needs to be generated automatically
When i want to create a java class it is generating automatically a file
I'm trying to use Sweave and R to report the results of my statistical
Datagrid headers are automatically generated if we use class like public Class student{ public
I have an xml schema (generated automatically using trang) which keeps changing. These changes
Is there any way generating automatically a jax-rs client with HttpUrlConnection or third party
when generating python wrappers with swig the python wrapper classes in the generated python
I am currently watching the 80 minute ASP.NET MVC introduction. Automatically generating views from
Is there a way to force the MVC automatically generated code to follow the
I have generated a XML file automatically from the below code. if (isset($_POST[song])&& $_POST['song']

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.