Jay*_*M-C 4 latex r knitr r-markdown
我正在写一篇关于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}
Run Code Online (Sandbox Code Playgroud)
但是,使用相同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.
Run Code Online (Sandbox Code Playgroud)
当我尝试将此类文件与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}
Run Code Online (Sandbox Code Playgroud)
和...一起
---
title: "Paper title"
author: "Name Surname"
output:
pdf_document:
template:
clv3-template.tex
---
# Introduction
Some text.
Run Code Online (Sandbox Code Playgroud)
应该是一个很好的起点.