LoginSignup
1
2

More than 5 years have passed since last update.

texテンプレートを使ってknitrからpdfを作る際のエラー対処

Posted at

学術雑誌や学会論文など、latexのテンプレートを配布しているところが多いが、それらを使ってRmarkdownからpdfを作成したい。今回は小さなエラーが出てつまづいたので、おそらくすぐ忘れるので解決した方法をメモ。

1. テンプレのダウンロード

今回はisprsという国際会議プロシーディングスのテンプレートを使いたい。

2. Yamlの作成

こんな感じ。templateで.texを、documentclassで.clsを、bibliographyで.bibを指定する。
ascii_identifiersはなくてもよいと思う。

---
title: "ISPRSguidelines_authors"
author: "AAA"
date: "8/1/2018"
output:
  pdf_document: 
    md_extensions: -ascii_identifiers
    fig_caption: yes
    keep_tex: true
    template: ~/ISPRSguidelines_authors.tex
  md_document:
documentclass: ~/isprs.cls
bibliography: ~/ISPRSguidelines_authors.bib
---

3. Error対処

こんなエラーが出ました。

pandoc: "template" (line 49, column 748):
unexpected "\\"
expecting letter
CallStack (from HasCallStack):
  error, called at src/Text/Pandoc/Templates.hs:73:35 in pandoc-1.19.2.1-JIeRA5EnQv74mk86CvVbbp:Text.Pandoc.Templates
Error: pandoc document conversion failed with error 1
Execution halted

調べてみるとこちら[https://github.com/jgm/pandoc/issues/2937] が原因のよう。

そこで、.texファイル内の$ $でくくられているものを、$$ $$にする。
これで解決しました。

もし、rticlesで対応しているテンプレートを使うならそれを用いるのがもっとも手っ取り早いと思います。
https://github.com/rstudio/rticles

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2