Rmd to PDF 编译错误:Package geometry paperwidth (0.0pt) too short [英] Rmd to PDF compiling error: Package geometry paperwidth (0.0pt) too short
问题描述
我正在用 R markdown 写一篇论文,需要用 这个 .cls 文件 由学术期刊提供.
I am writing a paper in R markdown and need to format it with this .cls file supplied by an academic journal.
一个最小的 .tex 文件可以与上述 cls 文件完美地编译.
A minimal .tex file compiles perfectly well with the above cls file.
我的 .tex 文件(在 ShareLaTeX 上编译,clv3.cls
保存在同一目录中):
My .tex file (compiled on ShareLaTeX with clv3.cls
saved in same directory):
documentclass[shortpaper]{clv3}
usepackage[utf8]{inputenc}
itle{Paper title}
author{Name Surname}
date{May 2018}
egin{document}
maketitle
section{Introduction}
Some text.
end{document}
但是,使用相同 cls 文件的 R markdown 中的类似最小文档无法在 Rstudio 中编译,并出现以下错误:!包几何错误:paperwidth (0.0pt) 太短.
However a comparable minimal document in R markdown, using the same cls file, fails to compile in Rstudio, with the following error: ! Package geometry Error: paperwidth (0.0pt) too short.
我的 Rmd 文件(与 clv3.cls
文件保存在同一目录中):
My Rmd file (with clv3.cls
file saved in same directory):
---
title: "Paper title"
author: "Name Surname"
documentclass: clv3
classoption: shortpaper
output: pdf_document
---
# Introduction
Some text.
当我尝试将此类文件与 R markdown 文档一起使用时,为什么会引发此错误,我该如何解决?
Why is this error induced when I try to use this class file with an R markdown document and how may I fix it?
我尝试在 YAML 标头中手动指定页面宽度设置,但我真的不知道我在做什么.无论如何,这似乎是不可取的,因为没有它,普通的 LaTeX 文档也可以正常工作(当然页面宽度应该由期刊指定,而不是由作者手动覆盖).
I've tried manually specifying a pagewidth setting in the YAML header, but I don't really know what I'm doing. This seems undesirable anyway, since the normal LaTeX document works fine without it (and surely page width is something that should be specified by a journal, not manually overwritten by an author).
推荐答案
我不知道 clv3.cls
类和默认的 pandoc
模板到底在哪里冲突.但是,该模板做了很多在使用特定样式编写时没有意义的事情,最好使用您自己的模板.使用 clv3-template.tex
I do not know where exactly the clv3.cls
class and the default pandoc
template clash. However, that template does so many things that do not make sense when writing with a specific style, that is best to use your own template. Using clv3-template.tex
documentclass[shortpaper]{clv3}
usepackage[utf8]{inputenc}
$if(title)$
itle{$title$}
$else$
itle{}
$endif$
$if(author)$
author{$for(author)$$author$$sep$ \ $endfor$}
$else$
author{}
$endif$
egin{document}
$if(title)$
maketitle
$endif$
$body$
end{document}
一起
---
title: "Paper title"
author: "Name Surname"
output:
pdf_document:
template:
clv3-template.tex
---
# Introduction
Some text.
应该是一个很好的起点.
should be a good starting point.
这篇关于Rmd to PDF 编译错误:Package geometry paperwidth (0.0pt) too short的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!