I began using LaTeX just yesterday and I'm stuck on a frustrating problem. I need to automatically include a lot of source code into my document and getting it code-highlighted, row-numbered, labeled and indexed. I've done most of the job, except few points. First of all, I'm using different languages: PHP, JS, PostgreSQL, R and SAS. I've found that listings
doesn't correctly treat /**/
SAS comments, so I decided to use the SASnRdisplay
package which seems to be a sort of "extension" of the listings
package. They share a lot of aspects. After a lot of tricking I finally got satisfied with the results.
What I need to do now is creating a list of listings containing the references to the listings generated by listings
and the listings generated by SASnRdisplay
using a single common numeration. At the moment I have basically two numberings: the listings
numbering and the SASnRdisplay
numbering.
I've tried using
\setcounter{lstlisting}{3}
but it doesn't seem to work.
Here's an example to test the \lstlistoflistings
command (the other features are not implemented here for simplicity):
\documentclass[a4paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{SASnRdisplay}
\begin{document}
\begin{lstlisting}[language=PHP, caption=First listing - using package ``listings'']
$var = "value";
\end{lstlisting}
\begin{lstlisting}[language=Java, caption=Second listing - using package ``listings'']
console.log('0123456789');
\end{lstlisting}
\begin{Rcode}[caption=Third listing - using package ``SASnRdisplay'']
df <- c(1,2,3)
\end{Rcode}
\begin{SAScode}[caption=Fourth listing - using package ``SASnRdisplay'']
/* comment */
PROC PRINT data=mydata; VAR v1; RUN;
\end{SAScode}
\lstlistoflistings
\end{document}
And here's the output: