# SLatex and line numbering?

I'm using SLaTeX to typeset some Racket source code. I would like to have line numbers along the left edge, so that I can refer to them in my document. However, I haven't yet discovered the option for turning line numbers on.

I suspect I should just switch over to the listings package and be done with it, but before I do, I wanted to check with the other LaTeX experts here.

-
You could try the lineno pacakge.But for typesetting source code the listings package is the one to use. –  Peter Grill Mar 3 '12 at 5:19
Personally I use listings, but an alternative that seems to be gaining some popularity is minted, which uses pygments. That may be worth a look for you. I do recommend moving away from SLaTeX, whichever route you take. –  qubyte Mar 3 '12 at 10:15

From the listings documentation:

SLaTeX is a pretty-printing Scheme program (which invokes LaTeX automatically) especially designed for Scheme and other Lisp dialects. It supports stand alone ﬁles, text and display listings, and you can even nest the commands/environments if you use LATEX code in comments, for example. Keywords, constants, variables, and symbols are deﬁnable and use of diﬀerent styles is possible. No line numbers.

Your best bet, is to use listings or pygments. Here is a MWE for listings to get you going.

\documentclass{article}
\usepackage{xcolor,listings}
\begin{document}
\newcommand\emphasis[2][red]{\lstset{emph={#2,},
emphstyle={\ttfamily\textcolor{#1}}}}%
\emphasis{x,a}
\lstset{%
language={[Auto]Lisp},
framesep=0pt,
numbers=left,numberstyle=\normalsize,stepnumber=1,numbersep=5pt,
breaklines=true,
basicstyle=\normalsize\ttfamily,
showstringspaces=false,
keywordstyle=\ttfamily\color{blue},
identifierstyle=\ttfamily,
stringstyle=\color{maroon},
rulecolor=\color{gray!10},
xleftmargin=5pt,
xrightmargin=5pt,
aboveskip=\bigskipamount,
belowskip=\bigskipamount,
backgroundcolor=\color{gray!5}
}
\begin{lstlisting}
(define-syntax setq
(syntax-rules ()
[(setq x a)
(begin (set! x a)
x)]))
\end{lstlisting}
\end{document}


What I particularly like about listings (especially if you writing tutorials), is that you can highlight specific key words (see the \emphasis macro in the code).

If you actually and absolutely insist that you use SLaTeX, yo can try the following code, which will number the full page.

\documentclass[10pt]{article}
\usepackage{fancyhdr,lipsum}
\makeatletter
\newsavebox{\@linebox}
\savebox{\@linebox}[3em][t]{\parbox[t]{3em}{%
\@tempcnta\@ne\relax
\loop{\underline{\scriptsize\the\@tempcnta}}\\
\pagestyle{fancy}
\fancyfoot{}
%% insert this block within a conditional
\put(-26,-25){\usebox{\@linebox}}%
\end{picture}}
\begin{picture}(0,0)%
\put(-18,-25){\usebox{\@linebox}}%
\end{picture}}
\fancyfoot[C]{\scriptsize Draft copy}
%% end conditional
\makeatother
\begin{document}
\section*{Lorem Ipsum}
\lipsum[1]
$$f_{nk}=\sum\,{\frac{n!}{ 1!^{k_1}\,k_1!\,2!^{k_2}\,k_2!\,3!^{k_3}\,k_3!\,\ldots}}\; f_1^{k_1}f_2^{k_2}f_3^{k_3}\ldots\;,$$
summed over all $k_1,k_2,k_3,\ldots\geq 0$
\lipsum[3]
$$f_{nk}=\sum\,{\frac{n!}{ 1!^{k_1}\,k_1!\,2!^{k_2}\,k_2!\,3!^{k_3}\,k_3!\,\ldots}}\; f_1^{k_1}f_2^{k_2}f_3^{k_3}\ldots\;,$$
summed over all $k_1,k_2,k_3,\ldots\geq 0$
\lipsum[5-7]
\end{document}


-