来自R-Markdown / LaTeX模板

时间:2017-06-05 16:34:59

标签: r templates rstudio r-markdown pandoc

我正在尝试基于BioMed Central LaTeX模板(bmc-article.tex)创建R-Markdown模板。

这里可以下载bmc模板文件,不用说,它们工作得很好:https://www.biomedcentral.com/authors/tex

特别是,作者,地址和注释定义起作用并产生预期的结果。

我已将bmc-article.tex文件中的示例作者,地址和注释定义替换为将其用作tex模板。我还删除了该文件中的大部分示例内容。

bmc-article.tex中的定义示例,我已替换为:

$for(author)$
  \author[%
    addressref={$author.addressref$}, %
    $if(author.corref)$corref={$author.corref$}, $endif$ %
    $if(author.noteref)$noteref={$author.noteref$}, $endif$ %
    email={$author.email$} %
  ]{\inits{$author.inits$}\fnm{$author.fnm$} \snm{$author.snm$}}
  $endfor$

  $for(address)$
  \address[id=$address.id$]{ %
    $if(address.orgname)$ \orgname{$address.orgname$}, $endif$ %
    $if(address.street)$ \street{$address.street$}, $endif$ %
    $if(address.postcode)$ \postcode{$address.postcode$}, $endif$ %
    $if(address.city)$ \city{$address.city$}, $endif$ %
    $if(address.cny)$ \cny{$address.cny$}$endif$ %
  }
  $endfor$

  \begin{artnotes}
    $for(notes)$
      \note[id=$notes.id$]{$notes.text$} % note, connected to author
    $endfor$
  \end{artnotes}

当'编织Rmd文件时,它(据我所知)转换为meningful tex,并且我一遍又一遍地查看生成的tex文件,查找tex错误,但没有找到。

E.g:

author:
- fnm: "Soren"
  snm: "ONeill"
  inits: "S"
  addressref: "aff1"
  email: "sorens mail"
  corref: "aff1"
  noteref: "n1"

..变为:

\author[%
    addressref={aff1}, %
    corref={aff1},  %
    noteref={n1},  %
    email={sorens mail} %
]{\inits{S}\fnm{Soren} \snm{ONeill}}

但是生成的pdf文件不正确。将姓名与地址相关联的上标数字显示为问号,文章末尾的作者详细信息完全丢失。

我没有看到pandoc(基于我的Rmd文件)创建的tex文件与原始bmx模板tex文件之间存在任何显着差异。

我知道以下内容相当冗长。

Rmd示例文件

title: "Template testing"
author:
  - fnm: "Soren"
    snm: "ONeill"
    inits: "S"
    addressref: "aff1"
    email: "sorens mail"
    corref: "aff1"
    noteref: "n1"
  - fnm: "Lotte"
    snm: "ONeill"
    inits: "L"
    addressref: "aff2"
    email: "lottes mail"
address:
  - id: "aff1"
    orgname: "University of Southern Denmark"
    street: "Campusvej 55"
    postcode: "DK 5500"
    city: "Odense M"
    cny: "Denmark"
  - id: "aff2"
    orgname: "University of Southern Denmark"
    street: "Campusvej 55"
    postcode: "DK 5500"
    city: "Odense M"
    cny: "Denmark"
notes:
  - id: "n1"
    text: "Equal contributor"

date: "2 jun 2017"
output: 
  pdf_document:
    template: template.tex
    keep_tex: TRUE
---

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see rmarkdown.rstudio.com.

这是template.tex文件,我从下载的bmc-article.tex文件改编而来

%% BioMed_Central_Tex_Template_v1.06
\documentclass{bmcart}
\usepackage[utf8]{inputenc} %unicode support
\def\includegraphic{}
\def\includegraphics{}

\begin{document}
  \begin{frontmatter}

    \begin{fmbox}
      \dochead{Research}
      \title{$title$}

      $for(author)$
      \author[%
        addressref={$author.addressref$}, %
        $if(author.corref)$corref={$author.corref$}, $endif$ %
        $if(author.noteref)$noteref={$author.noteref$}, $endif$ %
        email={$author.email$} %
      ]{\inits{$author.inits$}\fnm{$author.fnm$} \snm{$author.snm$}}
      $endfor$

      $for(address)$
      \address[id=$address.id$]{ %
        $if(address.orgname)$ \orgname{$address.orgname$}, $endif$ %
        $if(address.street)$ \street{$address.street$}, $endif$ %
        $if(address.postcode)$ \postcode{$address.postcode$}, $endif$ %
        $if(address.city)$ \city{$address.city$}, $endif$ %
        $if(address.cny)$ \cny{$address.cny$}$endif$ %
      }
      $endfor$

      \begin{artnotes}
        $for(notes)$
          \note[id=$notes.id$]{$notes.text$} % note, connected to author
        $endfor$
      \end{artnotes}

    \end{fmbox}% comment this for two column layout

    \begin{abstractbox}

      \begin{abstract} % abstract
      \parttitle{First part title} %if any
        Text for this section.

      \parttitle{Second part title} %if any
        Text for this section.
      \end{abstract}

      \begin{keyword}
        \kwd{sample}
        \kwd{article}
        \kwd{author}
      \end{keyword}

    \end{abstractbox}

  \end{frontmatter}

  %$body$

  \begin{backmatter}

  \section*{Competing interests}
    The authors declare that they have no competing interests.

  \section*{Author's contributions}
      Text for this section \ldots

  \section*{Acknowledgements}
    Text for this section \ldots

  \bibliographystyle{bmc-mathphys} % Style BST file (bmc-mathphys, vancouver, spbasic).
  \bibliography{bmc_article}      % Bibliography file (usually '*.bib' )

  \end{backmatter}
\end{document}

这会生成以下tex文件(我已指示RStudio / pandoc保留tex文件):

%% BioMed_Central_Tex_Template_v1.06
\documentclass{bmcart}
\usepackage[utf8]{inputenc} %unicode support
\def\includegraphic{}
\def\includegraphics{}

\begin{document}
  \begin{frontmatter}

    \begin{fmbox}
      \dochead{Research}
      \title{Template testing}

            \author[%
        addressref={aff1}, %
        corref={aff1},  %
        noteref={n1},  %
        email={sorens mail} %
      ]{\inits{S}\fnm{Soren} \snm{ONeill}}
            \author[%
        addressref={aff2}, %
         %
         %
        email={lottes mail} %
      ]{\inits{L}\fnm{Lotte} \snm{ONeill}}

            \address[id=aff1]{ %
         \orgname{University of Southern Denmark},  %
         \street{Campusvej 55},  %
         \postcode{DK 5500},  %
         \city{Odense M},  %
         \cny{Denmark} %
      }
            \address[id=aff2]{ %
         \orgname{University of Southern Denmark},  %
         \street{Campusvej 55},  %
         \postcode{DK 5500},  %
         \city{Odense M},  %
         \cny{Denmark} %
      }

      \begin{artnotes}
                  \note[id=n1]{Equal contributor} % note, connected to author
              \end{artnotes}

    \end{fmbox}% comment this for two column layout

    \begin{abstractbox}

      \begin{abstract} % abstract
      \parttitle{First part title} %if any
        Text for this section.

      \parttitle{Second part title} %if any
        Text for this section.
      \end{abstract}

      \begin{keyword}
        \kwd{sample}
        \kwd{article}
        \kwd{author}
      \end{keyword}

    \end{abstractbox}

  \end{frontmatter}

  %\subsection{R Markdown}\label{r-markdown}

This is an R Markdown document. Markdown is a simple formatting syntax
for authoring HTML, PDF, and MS Word documents. For more details on
using R Markdown see rmarkdown.rstudio.com.

  \begin{backmatter}

  \section*{Competing interests}
    The authors declare that they have no competing interests.

  \section*{Author's contributions}
      Text for this section \ldots

  \section*{Acknowledgements}
    Text for this section \ldots

  \bibliographystyle{bmc-mathphys} % Style BST file (bmc-mathphys, vancouver, spbasic).
  \bibliography{bmc_article}      % Bibliography file (usually '*.bib' )

  \end{backmatter}
\end{document}

乳胶日志文件相当冗长(很多关于Unicode char等的东西),但这可能有用

LaTeX Warning: Reference `aff1thanks' on page 1 undefined on input line 19.

LaTeX Font Info:    Try loading font information for OMS+cmss on input line 19.

LaTeX Font Info:    No file OMScmss.fd. on input line 19.

LaTeX Font Warning: Font shape `OMS/cmss/m/n' undefined
(Font)              using `OMS/cmsy/m/n' instead
(Font)              for symbol `textdagger' on input line 19.


LaTeX Warning: Reference `aff2thanks' on page 1 undefined on input line 25.

\address@aff1=\toks21
\address@aff2=\toks22
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 46.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 46.

LaTeX Warning: Reference `aff1thanks' on page 1 undefined on input line 46.

No file template_test_1.bbl.

AED: lastpage setting LastPage

LaTeX Font Warning: Font shape `OT1/cmss/m/it' in size <8> not available
(Font)              Font shape `OT1/cmss/m/sl' tried instead on input line 89.


Overfull \hbox (1.0pt too wide) has occurred while \output is active
 [] 
 []

[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}

] (./template_test_1.aux)

LaTeX Font Warning: Size substitutions with differences
(Font)              up to 1.0pt have occurred.


LaTeX Font Warning: Some font shapes were not available, defaults substituted.


LaTeX Warning: There were undefined references.

当然,我已经注意到关于&#34;参考`aff2thanks&#39;&#34;的警告,但在原版bmx-article.tex中找不到这样的参考

同样,我知道这很长 - 我为此道歉。我希望有人可以提出建议......

0 个答案:

没有答案