Rmd 到 PDF 编译错误:包几何 \paperwidth (0.0pt) 太短

2023-12-01

我正在用 R markdown 写一篇论文,需要将其格式化这个 .cls 文件由学术期刊提供。

最小的 .tex 文件可以与上面的 cls 文件完美编译。

我的 .tex 文件(在 ShareLaTeX 上编译为clv3.cls保存在同一目录中):

\documentclass[shortpaper]{clv3}
\usepackage[utf8]{inputenc}

\title{Paper title}
\author{Name Surname}
\date{May 2018}

\begin{document}

\maketitle

\section{Introduction}

Some text.

\end{document}

然而,使用相同 cls 文件的 R markdown 中的类似最小文档无法在 Rstudio 中编译,并出现以下错误:! Package geometry Error: \paperwidth (0.0pt) too short.

我的 Rmd 文件(带有clv3.cls文件保存在同一目录中):

---
title: "Paper title"
author: "Name Surname"
documentclass: clv3
classoption: shortpaper
output: pdf_document
---

# Introduction

Some text.

当我尝试将此类文件与 R markdown 文档一起使用时,为什么会引发此错误?我该如何修复它?

我尝试在 YAML 标头中手动指定页宽设置,但我真的不知道我在做什么。无论如何,这似乎是不可取的,因为普通的 LaTeX 文档在没有它的情况下也可以正常工作(当然页面宽度应该由期刊指定,而不是由作者手动覆盖)。


我不知道具体在哪里clv3.cls类和默认值pandoc模板冲突。然而,该模板做了很多事情,在使用特定样式编写时没有意义,最好使用您自己的模板。使用clv3-template.tex

\documentclass[shortpaper]{clv3}
\usepackage[utf8]{inputenc}

$if(title)$
  \title{$title$}
$else$
  \title{}
$endif$
$if(author)$
  \author{$for(author)$$author$$sep$ \\ $endfor$}
$else$
  \author{}
$endif$

\begin{document}

$if(title)$
\maketitle
$endif$

$body$

\end{document}

和...一起

---
title: "Paper title"
author: "Name Surname"
output: 
  pdf_document:
    template:
      clv3-template.tex
---

# Introduction

Some text.

应该是一个很好的起点。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Rmd 到 PDF 编译错误:包几何 \paperwidth (0.0pt) 太短 的相关文章

随机推荐