【问题标题】:Shiny + knitr does not load latex packages when compiling the documentsShiny + knitr 编译文档时不加载latex包
【发布时间】:2016-08-29 12:38:18
【问题描述】:

关于我最近发现的 knitr 的一般问题,我有更多未解决的问题。 当我通过闪亮编译文档时,只需:

output$report = downloadHandler(
    filename = reactive({paste0(input$filename,'.pdf')}),

    content = function(file) {
      out = knit2pdf(input = 'pdf_shell.Rnw')
      file.rename(out, file)
    },

    contentType = 'application/pdf'
  )

eso-pichyperref 等某些乳胶包无法正常工作并导致错误 Running ' texi2div ' on ' pdf_shell.tex ' failed。将compiler = 'xelatex' 包含在knit2pdf有助于某些功能,但会破坏其他功能(例如,\TextField 功能不起作用并覆盖文本)。

因此,我的问题是,有谁知道我如何使用默认编译器 pdflatex 编译 PDF,而不会出现上述错误?或者您可能有任何可以以不同方式解决问题的专业提示。非常感谢任何意见。

编辑:我必须提到,当我通过 R Studio 运行应用程序时,一切正常。当我将应用程序功能(和乳胶包)上传到 shinyapps.io 时会中断

编辑 2: 我发现当我在 .Rnw 文件中包含额外的反斜杠时,文件编译正确。所以版本不工作:

\begin{Form}
\begin{tabularx}{\textwidth}{p{8cm}}
Description \\
\TextField[name=1, multiline=true, width=\linewidth,height=0.6in, bordercolor = 1 1 1, charsize=0pt]{} \\
\end{tabularx}
\end{Form}

有效的版本:

\begin{Form}
    \begin{tabularx}{\textwidth}{p{8cm}}
    Description \\\
    \TextField[name=1, multiline=true, width=\linewidth,height=0.6in, bordercolor = 1 1 1, charsize=0pt]{} \\\
    \end{tabularx}
    \end{Form}

有人能解释我为什么会这样吗?

【问题讨论】:

    标签: r shiny knitr pdflatex xelatex


    【解决方案1】:

    经过一番研究,我发现一些像hyperref (TextFields) 这样的包在使用xelatex (proof) 编译时通常可能不适用于普通表,但应该在 p 列中编译,比如这个:

    \begin{Form}
    \begin{tabularx}{\textwidth}{p{8cm}}
    Description \\
    \TextField[name=1, multiline=true, width=\linewidth,height=0.6in, bordercolor = 1 1 1, charsize=0pt]{} \\
    \end{tabularx}
    \end{Form}
    

    但是,它并不能解决 Shiny 内部的问题。为了使它工作,我必须在行之间拆分时再添加一个反斜杠(不知道为什么)。 所以如果你想让它工作,你必须添加额外的反斜杠,结果代码应该是这样的:

    \begin{Form}
        \begin{tabularx}{\textwidth}{p{8cm}}
        Description \\\
        \TextField[name=1, multiline=true, width=\linewidth,height=0.6in, bordercolor = 1 1 1, charsize=0pt]{} \\\
        \end{tabularx}
        \end{Form}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多