【问题标题】:Rmarkdown: Paragraph ended before \Gin@ii was completeRmarkdown:段落在 \\Gin@ii 完成之前结束
【发布时间】:2022-12-07 04:50:43
【问题描述】:

我收到以下错误

! Paragraph ended before \Gin@ii was complete.
<to be read again> 
\par 
l.398 

当尝试将 Rstudio 中的以下 Rmarkdown 编织成 pdf 时,它涉及定义 \includegraphics 的变体。

---
title: "Test"
output:
  pdf_document: 
    latex_engine: lualatex
    keep_tex: yes
  html_document: default
date: "2022-12-06"
header-include:
  - usepackage{graphicx}
---

\newcommand\IG[1]{\includegraphics[width = \textwidth]{#1}}

\IG{test.png}

奇怪的是,当我通过 lulatex 执行时,tex 输出编译正确外部Rstudio 的(是的,我必须在这里使用 lualatex)。

该错误似乎与https://tex.stackexchange.com/questions/37650/paragraph-ended-before-giniii-was-complete-while-inserting-image-with-incluRmarkdown Error: "! Paragraph ended before \@fileswith@ptions was complete" 有关,但那里的解决方案都没有帮助,我无法弄清楚我的情况出了什么问题。

编辑:奇怪的是,错误似乎来来去去。我有时会得到它,但其他人不会(我只是重新运行上面的代码,这次它通过了)。

【问题讨论】:

    标签: pdf r-markdown rstudio knitr


    【解决方案1】:

    ewcommand 添加到 YAML 标头,即

    ---
    title: "Test"
    output:
      pdf_document: 
        latex_engine: lualatex
        keep_tex: yes
      html_document: default
    date: "2022-12-06"
    header-include:
      - usepackage{graphicx}
      - 
    ewcommandIG[1]{includegraphics[width = 	extwidth]{#1}}
    ---
    

    【讨论】:

    • 谢谢。没有办法在文档正文中定义新命令吗?我应该将它包含在问题中(或者可能会问一个新问题),但我正在考虑使用变量作为新命令定义的一部分。类似于 ewcommandIG[1]{includegraphics[width = [SOME R VARIABLE]* extwidth]{#1}},这就是为什么我在文档中而不是在 YAML 标头中定义命令的原因。
    猜你喜欢
    • 2016-02-07
    • 1970-01-01
    • 2018-08-05
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多