# KnitR/Pitfalls

Learning about common pitfalls for advanced users provide insights in the structure of document generation. The provide solutions are templates for generic problem solving in document generation in KnitR. This section is not meant to be a debugging resource. So add KnitR problems with additional comments, so that learners understand more about the basic principles of dynamic document generation.

## PDF Output edit

PDF output uses LateX to render the output:

### Lower Symbol in LaTeX Expression in R-Markdown edit

**Date:**2019/07/05**Topic:**Math delimiters and Symbols

#### Document with Bug edit

The mathematical expression with a lower sign causes a problem in the PDF rendering of the following R-markdown source document:

--- title: "Document Test PDF output" author: "Bert Niehaus" date: "9 7 2019" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` The equation $y_{k} < \alpha$ is not rendered properly in R-Markdown with PDF output

#### Expected output edit

The latex expression should render to:

*The equation is not rendered properly in R-Markdown with PDF output*

#### Error Message edit

! Missing $ inserted. <inserted text> $ l.92 The equation \$ y\_\{k\} \textless{} \alpha

Explanation: the lower symbol is replace by the textless command, which is OK when the less symbol is used in regular text mode. But if the replacement is performed in the math environment in R-Markdown, this replacement causes a problem for document rendering due to fact that the *textless*-command in LaTeX is meant to used in text mode and not in a math environment.

### Solution edit

Wrap the less-symbol with Dollar-character, so that the *textless*-command is in **text** environement for rendering.

The equation $y_{k}$ < $\alpha$ is not rendered properly in R-Markdown with PDF output

### Lesson learnt edit

The general recommendation (lesson learnt) is to use the <-Symbol in R-Markdown outside the math-delimiters (i.e. Dollor-symbol $).