# Undefined Control Sequence Latex Using R

This tutorial demonstrates the undefined control sequence latex error in R.

## Undefined Control Sequence Latex Using R

When we use Latex with R, the undefined control sequence latex error will occur when there is a syntax error or typo mistake in the Latex syntax.

Usually, sometimes we need to put some R code between the Latex, and that file is saved with the Rtex extension.

The common cause for this error is a typo mistake; for example, when writing the Greek letter $\alpha$ but we made a typing mistake like $\slpha$, it will throw the undefined control sequence latex error. Let’s try an example.

\documentclass{article}
\begin{document}

Let's use R commands in our \LaTeX{} document which will be processed and output will be included in the document:

\begin{equation}
\slpha
\end{equation}

<<>>=
# Use R to create a sequence of numbers
a = 1:100

# Use R to display basic statistical measures
summary(a)

@
\end{document}


After running the code above, the Latex screen will show the output without the \alpha, and it will also show the undefined control sequence error in the log. See output:

The Latex document: The log file: To solve this error, we must write the Latex syntax correctly and make sure there are no typo mistakes. This applies to using R in Latex or using Latex in R.

Let’s see the solution.

\documentclass{article}
\begin{document}

Let's use R commands in our \LaTeX{} document which will be processed and output will be included in the document:

\begin{equation}
\alpha
\end{equation}

<<>>=
# Use R to create a sequence of numbers
a = 1:100

# Use R to display basic statistical measures
summary(a)

@
\end{document}


When the only typing mistake is corrected, the undefined control sequence latex will be solved. See output: 