【问题标题】:How to configure arara to post process .Rnw files in statet / Eclipse如何配置 arara 在 statet / Eclipse 中发布处理 .Rnw 文件
【发布时间】:2018-01-02 10:37:47
【问题描述】:

我想使用arara 对从 R 中的 Sweave (.Rnw) 文档生成的 .tex 文件进行后期处理,并使用它在报告中构建词汇表或参考书目。您如何将其集成到statet eclipse 插件中?

arara 头文件放在 .Rmd 文件的顶部,将被处理为 .tex 文件,如下所示。

% arara: pdflatex:  { action: nonstopmode, synctex: True }
% !arara: bibtex
% arara: makeglossaries
% !arara: pdflatex: {action: nonstopmode, synctex: True }
% !arara: pdflatex: {action: nonstopmode, synctex: True }
\documentclass{article}
\usepackage{glossaries}
\newglossaryentry{salmon}{name={salmon},description={Anadromous migratory fish}}
\newglossaryentry{eel}{name={eel},description={Catadromous fish of the genus
anguilla}}
\makeglossaries
\begin{document}
An example for \gls{salmon} and \gls{eel}
\printglossary[numberedsection]
\end{document}

这样我就可以运行 bibtex 和 makeglossaries 命令。现在我想将该命令集成到 statet IDE 中。

【问题讨论】:

    标签: r eclipse knitr tex statet


    【解决方案1】:

    为 Eclipse 配置 Arara。

    转到工具按钮(见下文)> 外部工具配置

    然后点击程序 > 新建

    并配置arara如下:

    然后创建一个示例代码。您的 .Rnw 文件或乳胶文件的第一行必须包含 % arara: 和命令。下面我首先使用 pdflatex 构建文件,然后使用 bibtexmakeglossary,最后我重新运行 pdflatex 两次以获得完整的文档。您只需输入!arara:即可避免一步。

    这是一个示例,它使用\gls{}commands 来表示词汇表,\cite{} 命令用于 bibtex。 R 代码只是为了表明这是一个 .Rnw 文档。

    % arara: pdflatex:  { action: nonstopmode, synctex: True }
    % arara: bibtex
    % arara: makeglossaries
    % arara: pdflatex: {action: nonstopmode, synctex: True }
    % arara: pdflatex: {action: nonstopmode, synctex: True }
    

    arara.Rnw:

    % arara: pdflatex:  { action: nonstopmode, synctex: True }
    % arara: bibtex
    % arara: makeglossaries
    % arara: pdflatex: {action: nonstopmode, synctex: True }
    % arara: pdflatex: {action: nonstopmode, synctex: True }
    \documentclass{article}
    \usepackage{glossaries}
    \newglossaryentry{knitr}{name={Knitr},description={A package for reproducible
    research}} 
    \newglossaryentry{latex}{name={Latex},description={A typesetting program}}
    \newglossaryentry{arara}{name={Arara},description={TeX automation tool based on
    rules and directives.}}
    \makeglossaries
    \begin{document}
    
    <<get_citation, echo=FALSE, eval=FALSE >>=
    print(citation("knitr"),bibtex=TRUE)
    @
    
    This short reproducible example demonstrates how to use the \gls{arara}
    \gls{latex} tool with a \textbf{Sweave} document, using eclipse and \gls{knitr}. 
    For demonstration we will  include a bibliography using \cite{knitr_2017} and
    \cite{knitr_2015}.
    
    \printglossary[numberedsection]
    \bibliographystyle{plain}
    \bibliography{arara}
    \end{document}
    

    arara.bib:

    @Book{knitr_2015,
        title = {Dynamic Documents with {R} and knitr},
        author = {Yihui Xie},
        publisher = {Chapman and Hall/CRC},
        address = {Boca Raton, Florida},
        year = {2015},
        edition = {2nd},
        note = {ISBN 978-1498716963},
        url = {https://yihui.name/knitr/},
      }  
    
    @Manual{knitr_2017,
        title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
        author = {Yihui Xie},
        year = {2017},
        note = {R package version 1.17},
        url = {https://yihui.name/knitr/},
      }
    

    第一次运行 .Rmd 时,不会构建参考书目和词汇表。

    所以你要做的就是移动 LATEX 文件并点击 cmd 按钮 arara

    最后你得到了用参考书目和词汇表构建的文档,如果你需要更新参考书目和词汇表,重新运行 arara 过程,否则只需运行 knitr 命令,就会构建 pdf。

    【讨论】:

      猜你喜欢
      • 2016-09-05
      • 2012-10-04
      • 2017-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 2014-12-15
      相关资源
      最近更新 更多