An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081017/d807546b/attachment.pl>
R-code in Latex --- $ sign causes error
7 messages · Greg Snow, erwann rogard, Gabor Grothendieck +1 more
The $ is special in TeX/LaTeX as a shortcut for beginning/ending inline math mode, so if you want an actual $ then you need to escape it so that the TeX/LaTeX file has \$ in it. This means that in your R code that generates the file you may need \\$ or in some cases \\\\$. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of erwann rogard
Sent: Friday, October 17, 2008 5:18 PM
To: r-help at r-project.org
Subject: [R] R-code in Latex --- $ sign causes error
hi,
here's what i have:
\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
showstringspaces=false,
columns = fullflexible,
mathescape = true,
language=R
}
\begin{lstlisting}
lst$val<-val
\end{lstlisting}
./software.tex:16:Extra }, or forgotten \endgroup. lst$
the culprit here is the $ sign.
thanks.
ps:
i'm posting here rather than Latex is bec i guess an R user is more
likely 2
to have encountered this before, but if not ok, pls let me know.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081017/91c4e702/attachment.pl>
Greg was referring to what to write in R character literals in order to generate a single \ in the output from R which in turn would be fed into latex or Sweave and then latex. Google this: special characters in latex
On Fri, Oct 17, 2008 at 11:23 PM, erwann rogard <erwann.rogard at gmail.com> wrote:
Thanks, but unfortunately
\begin{lstlisting}
\\$
\end{lstlisting}
and
\begin{lstlisting}
\\\\$
\end{lstlisting}
still generate the same error.
On Fri, Oct 17, 2008 at 9:38 PM, Greg Snow <Greg.Snow at imail.org> wrote:
The $ is special in TeX/LaTeX as a shortcut for beginning/ending inline math mode, so if you want an actual $ then you need to escape it so that the TeX/LaTeX file has \$ in it. This means that in your R code that generates the file you may need \\$ or in some cases \\\\$. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of erwann rogard
Sent: Friday, October 17, 2008 5:18 PM
To: r-help at r-project.org
Subject: [R] R-code in Latex --- $ sign causes error
hi,
here's what i have:
\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
showstringspaces=false,
columns = fullflexible,
mathescape = true,
language=R
}
\begin{lstlisting}
lst$val<-val
\end{lstlisting}
./software.tex:16:Extra }, or forgotten \endgroup. lst$
the culprit here is the $ sign.
thanks.
ps:
i'm posting here rather than Latex is bec i guess an R user is more
likely 2
to have encountered this before, but if not ok, pls let me know.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081017/22a263a0/attachment.pl>
Check out the 'fancyvrb' latex package - that is quite flexible and I wouldn't be surprised if it can help you. Make sure to read the docs (fancyvrb.pdf). /H
On Fri, Oct 17, 2008 at 8:37 PM, erwann rogard <erwann.rogard at gmail.com> wrote:
Thanks for clarifying. Yes, \$ works in latex, but not *within* the lstlisting environment. On Fri, Oct 17, 2008 at 11:32 PM, Gabor Grothendieck < ggrothendieck at gmail.com> wrote:
Greg was referring to what to write in R character literals in order to generate a single \ in the output from R which in turn would be fed into latex or Sweave and then latex. Google this: special characters in latex On Fri, Oct 17, 2008 at 11:23 PM, erwann rogard <erwann.rogard at gmail.com> wrote:
Thanks, but unfortunately
\begin{lstlisting}
\\$
\end{lstlisting}
and
\begin{lstlisting}
\\\\$
\end{lstlisting}
still generate the same error.
On Fri, Oct 17, 2008 at 9:38 PM, Greg Snow <Greg.Snow at imail.org> wrote:
The $ is special in TeX/LaTeX as a shortcut for beginning/ending inline math mode, so if you want an actual $ then you need to escape it so that
the
TeX/LaTeX file has \$ in it. This means that in your R code that
generates
the file you may need \\$ or in some cases \\\\$. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of erwann rogard
Sent: Friday, October 17, 2008 5:18 PM
To: r-help at r-project.org
Subject: [R] R-code in Latex --- $ sign causes error
hi,
here's what i have:
\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
showstringspaces=false,
columns = fullflexible,
mathescape = true,
language=R
}
\begin{lstlisting}
lst$val<-val
\end{lstlisting}
./software.tex:16:Extra }, or forgotten \endgroup. lst$
the culprit here is the $ sign.
thanks.
ps:
i'm posting here rather than Latex is bec i guess an R user is more
likely 2
to have encountered this before, but if not ok, pls let me know.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081018/99f28ba4/attachment.pl>