eddelbuettel / pinp

Pinp Is Not PNAS -- Two-Column PDF Template
147 stars 25 forks source link

Failed to compile if non-english characters included #20

Closed ghost closed 7 years ago

ghost commented 7 years ago

What should I change to create a document in a language other than English? Thank you.

eddelbuettel commented 7 years ago

I would suggest the following:

I guess that you probably just need to declare a UTF-8 encoding, possibly via %\VignetteEncoding{UTF-8} in the vignette header.

eddelbuettel commented 7 years ago

There is nothing you need to do. Quick loG:

edd@brad:/tmp$ mkdir other-languages
edd@brad:/tmp$ cd other-languages/
edd@brad:/tmp/other-languages$ Rscript -e 'rmarkdown::draft("quickCheck.Rmd", template="pdf", package="pinp", edit=FALSE)'
edd@brad:/tmp/other-languages$ # edits quickCheck.Rmd
edd@brad:/tmp/other-languages$ Rscript -e 'rmarkdown::render("quickCheck.Rmd")'

processing file: quickCheck.Rmd
  |.................................................................| 100%
  ordinary text without R code

output file: quickCheck.knit.md

/usr/bin/pandoc +RTS -K512m -RTS quickCheck.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output quickCheck.tex --template /usr/local/lib/R/site-library/pinp/rmarkdown/templates/pdf/resources/template.tex --highlight-style tango --latex-engine pdflatex --natbib 
Latexmk: This is Latexmk, John Collins, 1 January 2015, version: 4.41.

Output created: quickCheck.pdf
edd@brad:/tmp/other-languages$ 

using the following near-minimal (?) RMarkdown input file:

---
title: A Quick Test

author:
  - name: First Author
    affiliation: a
address:
  - code: a
    address: Institute of Smoke and Magic, University of Sometown, Sometown, XY, 12345

keywords:
  - one
  - two

output: pinp::pinp
---

## Introduction 

Il fait chaud en été à Paris.

Schöne Grüße.

and it just works as is.

ghost commented 7 years ago

Your example with French works indeed. However, If you use Ελληνικά (Greek), you will get an error.

eddelbuettel commented 7 years ago

I very strongly suspect that if you do whatever you need to do to typset Greek (or other) letters via Markdown and then LaTeX, it will just work. We this in the template.tex file:

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

which means UTF-8 character should be supported. For the rest, i,e., direct input of non latin-1 characters you may need to research how RMarkdown does. There is no fundamental reason why this can't work.

eddelbuettel commented 7 years ago

This tex.stackexchange.com post seems relevant. It may after all we a regular LaTeX issue. But we're not taking any features away...