I have a lstlisting environment that shows a line number either left or right side of the document.
Setting up lstlisting environment by passing parameters
Setting the ruby code in a two-column document, I keep changing the numers parameter depending on the final layout of the document. The following screen capture shows the wrong number location as a final layout.
\end{lstlisting}
\begin{lstlisting}[language=ruby, numbers=left,firstnumber=1]
...
\end{lstlisting}
Is there an way to setup the lstlisting environment based on which side of the document the lstlisting environment is located?
ADDED
I use IEEEtran class, which has its own options. One can find it from http://tug.ctan.org/tex-archive/macros/latex/contrib/IEEEtran/IEEEtran.cls
\documentclass[conference]{IEEEtran}
\usepackage{cite}
...
\DeclareOption{oneside}{\@twosidefalse\@mparswitchfalse
\CLASSOPTIONonesidetrue\CLASSOPTIONtwosidefalse}
\DeclareOption{twoside}{\@twosidetrue\@mparswitchtrue
\CLASSOPTIONtwosidetrue\CLASSOPTIONonesidefalse}
\DeclareOption{onecolumn}{\CLASSOPTIONonecolumntrue\CLASSOPTIONtwocolumnfalse}
\DeclareOption{twocolumn}{\CLASSOPTIONtwocolumntrue\CLASSOPTIONonecolumnfalse}
ADDED 2
This code works fine.
\documentclass[conference]{IEEEtran}
\usepackage{listings}
\usepackage{lipsum}
\lstdefinelanguage{rruby}{
escapechar=\,
basicstyle=\scriptsize\ttfamily,
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},
}
\lstset{
basicstyle=\ttfamily\scriptsize,
}
\makeatletter
\lstnewenvironment{ruby}{
\if@firstcolumn
\lstset{emph={def, class, end, typedef, type, constraint, sentence},emphstyle=\textbf, language=rruby, numbers=left}
\else
\lstset{emph={def, class, end, typedef, type, constraint, sentence},emphstyle=\textbf, language=rruby, numbers=right}
\fi
}{}
\makeatother
\begin{document}
\lipsum
\begin{ruby}
...
\end{ruby}
\begin{lstlisting}[language=ruby, numbers=left,firstnumber=1]
...
\end{lstlisting}
\end{document}
ADDED 3
When the listings environment is in the float environment, the code does not work.

