代码之家  ›  专栏  ›  技术社区  ›  Matt Bannert

如何在fancyhdr中使用swave(R)代码?

  •  3
  • Matt Bannert  · 技术社区  · 14 年前

    基于此,在R中生成头字符串。

    长话短说,我知道乳胶中有今天,但我需要使用来自R的具体信息,而不仅仅是日期。

    这是我的密码:

       \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}}
    

    从而导致以下错误:

    Package Fancyhdr Warning: \fancyhead's `E' option without twoside option is use
    less on input line 23.
    

    这正是我的头像所在的行。

    2 回复  |  直到 7 年前
        1
  •  2
  •   rcs    14 年前

    \fancyhead[L]{...} \fancyhead[R]{...} .

    此外,在这种情况下,最好使用 <<results=tex, echo=FALSE>>= 举个例子:

    \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}
    
        2
  •  1
  •   second    14 年前

    这只是一个警告,不是一个错误。警告是关于您已经为偶数页添加了格式这一事实,这仅在您使用双面输出时才相关,在文档类中使用“twoside”选项激活。否则,fancyhdr会将所有页面视为奇数