Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rmd to PDF compiling error: Package geometry \paperwidth (0.0pt) too short

I am writing a paper in R markdown and need to format it with this .cls file supplied by an academic journal.

A minimal .tex file compiles perfectly well with the above cls file.

My .tex file (compiled on ShareLaTeX with clv3.cls saved in same directory):

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

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

\begin{document}

\maketitle

\section{Introduction}

Some text.

\end{document}

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.

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.

Why is this error induced when I try to use this class file with an R markdown document and how may I fix it?

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).

like image 516
JaydenM-C Avatar asked Mar 06 '23 06:03

JaydenM-C


1 Answers

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)$
  \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}

together with

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

# Introduction

Some text.

should be a good starting point.

like image 186
Ralf Stubner Avatar answered Apr 07 '23 05:04

Ralf Stubner