Royun - 5 months ago 29

LaTeX Question

The following codes are for the Sweave/Latex beamer：

`\begin{frame}[fragile]`

\frametitle{Function Basics}

\begin{block}{Elementary Functions}

<<>>=

pi # \texttt{pi} is a predefined const.

sin(pi) # \texttt{sin(pi)}$\neq$0, due to computing error.

sinpi(1) # Instead, we use \texttt{sinpi(x=1)} to get around.

exp(1)

log(10)

@

\end{block}

\end{frame}

My question:

in the above three # comments, after Sweave compiling, \texttt{}, $\neq$ still exist. Sweave does not recognize Latex code in the R chunk.

On the other hand, it seems that Latex does not identify any codes (R or Latex) in the R chunk as well.

So, how to show \texttt{}, $\neq$ in Latex math format in this circumstance? Thank you in advance!

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

This is expected behaviour. I would suggest a workaround:

```
\begin{frame}
\begin{tabular}{ll}
> pi&\# \texttt{pi} is a predefined const.\\
\Sexpr{pi}&\\
> sin(pi)&\# \texttt{sin(pi)}$\neq$0, due to computing error.\\
\Sexpr{sin(pi)}&\\
> sinpi(1)&\# Instead, we use \texttt{sinpi(x=1)} to get around.\\
\Sexpr{sinpi(1)}&\\
\end{tabular}
\end{frame}
```

yields

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**