Search code examples
rr-markdownpandoc

Rmarkdown doesn't display dots in formulae (pdf output)


I'm trying recent 1.0 version of RStudio, I generated a document that previously worked ok, but now I' having problems with dots in formulae when compiling to pdf_output. For example when i write:

$A(L) = 1 - 1.6  L  + 0.96 L^2  -  0.256 L^3$

i get in pdf:

this

I´ve searched in the web and found nothing useful. Thanks in advance for your help.

It worked quiting the spanish language option (lang: es) from the YAML. Also the acepted answer solved the problem without need of changing the language.


Solution

  • babel expects commas as decimal separators when using spanish. Thus, this would work out of the box (and this would be in my opinion the proper solution).

    $A(L) = 1 - 1,6  L  + 0,96 L^2  -  0,256 L^3$
    

    However, you can still get your example to work. According to this tex.SE answer, you can force babel to use dots as decimal separator by setting the language this way (notice there is no lang option):

    ---
    title: "Test"
    output: pdf_document
    header-includes:
    - \usepackage[spanish,es-nodecimaldot]{babel}
    ---