How to knit a greek symbol in R-studio to generate a pdf

12,442

For greek symbols in Rmarkdown you can use inline formulas, indicated by $ ... $, i.e. two $ signs.

Try this:

If the p-value is equal or smaller than the significance level $\alpha$

enter image description here

Share:
12,442
Hugo Koopmans
Author by

Hugo Koopmans

data scientist and head of advanced analytics @ DIKW Consulting. The last few years my ambitions focus on what is now called big data and social media analytics. Mining unstructured content like text, video, pictures and social networks brings new insights into customer profiling and what can be done with analytics in the field of datamining and CRM.

Updated on June 17, 2022

Comments

  • Hugo Koopmans
    Hugo Koopmans about 2 years

    I am working with R studio markdown and knitr, all together great stuff.

    I seem not to be able to knit a greek symbol into pdf.

    Same Rmd file:

    ---
    title: "Untitled"
    author: "Hugo Koopmans"
    date: "11-01-2015"
    output: pdf_document
    ---
    
    
    Test Greek symbol
    ----------------
    
    P-value
    In statistics, the p-value is a function of the observed sample results (a statistic) that is used for testing a statistical hypothesis. Before performing the test a threshold value is chosen, called the significance level of the test, traditionally 5% or 1% [1] and denoted as α. If the p-value is equal or smaller than the significance level (\alpha)
    

    Now I am on linx mint 17 texlive 2013 Rstudio Version 0.98.1062

    Result:

      |.................................................................| 100%
      ordinary text without R code
    
    
    /usr/lib/rstudio/bin/pandoc/pandoc Preview-25df24aa1731.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Preview-25df24aa1731.pdf --template /home/hugo/R/x86_64-pc-linux-gnu-library/3.0/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in' 
    
    
    processing file: Preview-25df24aa1731.Rmd
    output file: Preview-25df24aa1731.knit.md
    
    ! Package inputenc Error: Unicode char \u8:α not set up for use with LaTeX.
    
    See the inputenc package documentation for explanation.
    Type  H <return>  for immediate help.
     ...                                              
    
    l.73 denoted as α
    
    Try running pandoc with --latex-engine=xelatex.
    pandoc: Error producing PDF from TeX source
    Error: pandoc document conversion failed with error 43
    Execution halted
    

    The result is pandoc complaining about the the alpha symbol. So the latex generated seems not to be able to handle the symbol...

    I would like to have R studio handle this properly without going into changing the tex file by hand ...ideally...

    Any tips?

    hugo