I have listing setups (rubyl/rubyr) for ruby for the case the line numbering is on the left or right hand side.
\lstdefinelanguage{rubyr}{
escapechar=\,
basicstyle=\scriptsize\ttfamily,
numbers=right, % <----
numberstyle=\scriptsize\ttfamily,
stepnumber=1,
numbersep=3pt,
showstringspaces=false,
breaklines=true,
frame=lines,
%backgroundcolor=\color{background},
literate=
*{0}{{{\color{numb}0}}}{1}
{1}{{{\color{numb}1}}}{1}
{2}{{{\color{numb}2}}}{1}
{3}{{{\color{numb}3}}}{1}
{4}{{{\color{numb}4}}}{1}
{5}{{{\color{numb}5}}}{1}
{6}{{{\color{numb}6}}}{1}
{7}{{{\color{numb}7}}}{1}
{8}{{{\color{numb}8}}}{1}
{9}{{{\color{numb}9}}}{1}
{:}{{{\color{punct}{:}}}}{1}
{,}{{{\color{punct}{,}}}}{1}
{\{}{{{\color{delim}{\{}}}}{1}
{\}}{{{\color{delim}{\}}}}}{1}
{[}{{{\color{delim}{[}}}}{1}
{]}{{{\color{delim}{]}}}}{1},
}
\lstdefinelanguage{rubyl}{
...
numbers=left,
...
}
Duplicating a bunch of lines of code doesn't seem proper, so is there a way to setting up by passing parameters (numbers = left or right)?
This is the usage of the lstlisting environment.
\begin{figure}[htbp]
\lstset{emph={def, class, end, typedef, type, constraint, sentence},emphstyle=\textbf}
\begin{lstlisting}[language=rubyr,firstnumber=1]
...
\end{lstlisting}
