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!
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.