Hola! I ask here since I learnt from this list that the LaTeX package listings should be good for typesetting R code. I encountered one problem: \begin{lstlisting} X %*% V \end{lstlisting} in the output the * in %*% disappears! same with %/%, etc, the / disappears. Any ideas? Kjetil -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra
On Sun, 2004-10-03 at 21:26, Kjetil Brinchmann Halvorsen wrote:> Hola! > > I ask here since I learnt from this list that the LaTeX package listings > should be good > for typesetting R code. I encountered one problem: > \begin{lstlisting} > X %*% V > \end{lstlisting} > > in the output the * in %*% disappears! same with %/%, etc, the / > disappears. > > Any ideas? > > KjetilThat's because the "%" is a comment character in LaTeX. Thus, anything after it will be ignored. For program code, you generally want to use the 'verbatim' or 'smallverbatim' environment: \begin{verbatim} X %*% V \end{verbatim} In the verbatim environment, all characters are treated literally, rather than interpreted by any special meaning. Outside of that, say in a regular LaTeX document, you can escape the "%": \% HTH, Marc Schwartz
On Sun, 03 Oct 2004 22:26:21 -0400 Kjetil Brinchmann Halvorsen wrote:> Hola! > > I ask here since I learnt from this list that the LaTeX package > listings should be good > for typesetting R code. I encountered one problem: > \begin{lstlisting} > X %*% V > \end{lstlisting} > > in the output the * in %*% disappears! same with %/%, etc, the / > disappears. > > Any ideas?The comment characters in listings can be configured via \lstset{}, but I'm not sure wether this also includes the % character. Maybe it has to be escaped. Z> Kjetil > > -- > > Kjetil Halvorsen. > > Peace is the most effective weapon of mass construction. > -- Mahdi Elmandjra > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
Kjetil Brinchmann Halvorsen <kjetil <at> acelerate.com> writes:> > Hola! > > I ask here since I learnt from this list that the LaTeX package listings > should be good > for typesetting R code. I encountered one problem: > \begin{lstlisting} > X %*% V > \end{lstlisting} > > in the output the * in %*% disappears! same with %/%, etc, the / > disappears. > > Any ideas? > > Kjetil >I use the following and it displays fine \lstset{numbers=left, stepnumber=5,breaklines=true} \lstset{basicstyle=\footnotesize,frame=single} \lstset{language=R} This is a test \begin{lstlisting} X in %*% V %% \end{lstlisting} HTH
Toby Popenfoose wrote:>Kjetil Brinchmann Halvorsen <kjetil <at> acelerate.com> writes: > > > >>Hola! >> >>I ask here since I learnt from this list that the LaTeX package listings >>should be good >>for typesetting R code. I encountered one problem: >>\begin{lstlisting} >> X %*% V >>\end{lstlisting} >> >>in the output the * in %*% disappears! same with %/%, etc, the / >>disappears. >> >>Any ideas? >> >>Kjetil >> >> >>Answering myself, this seems to be a problem with babel and spanish. I have \usepackage[spanish]{babel} replacing this with \usepackage[english]{babel} (or removing babel) problem disappears. The maintainers of [spanish] are known to be hyperactive! Kjetil> >I use the following and it displays fine > >\lstset{numbers=left, stepnumber=5,breaklines=true} >\lstset{basicstyle=\footnotesize,frame=single} >\lstset{language=R} > >This is a test >\begin{lstlisting} >X in %*% V >%% >\end{lstlisting} > >HTH > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > > >-- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra