Listings Package – How to Resolve Common Errors

listings

I am using listing package for inserting code snippets in my thesis in several chapters of my thesis. I use the following style to insert code snippets :

   \lstset{emph={sensors, string}, emphstyle={\color{blue}\bfseries\emph}, 
caption={Code snippet of the building automation domain.}, escapechar=\#,  
label=vocabDSL}
    \lstinputlisting{code-snippet/extract-vocabsec.txt} 

I am getting the following errors. My compilation indicates error at
this code location \lstinputlisting{code-snippet/extract-vocabsec.txt}

Pdflatex> Argument of \lst@for has an extra }
pdflatex> <inserted text>
pdflatex>   \par
pdflatex> l.140 ...isting{code-snippet/extract-vocabsec.txt}
pdflatex>
pdflatex> Runaway argument?
pdflatex> ! Paragraph ended before \lst@for was complete
pdflatex> <to be read again>
pdflatex>   \par
pdflatex> l.140 ...isting{code-snippet/extract-vocabsec.txt}
pdflatex> 

for reference, I have added following header of my main compilation document.

\documentclass[twoside,12pt]{Classes/aesm_edspia}

\usepackage{listings}
\usepackage{xcolor}

\definecolor{name}{rgb}{0.5,0.5,0.5}
\definecolor{javared}{rgb}{0.6,0,0} % for strings
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
\definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords
\definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc

\lstset{ %
%language=Java,                 % choose the language of the code
basicstyle=\ttfamily,     % the size of the fonts that are used for the code
keywordstyle=\color{javapurple}\bfseries,
stringstyle=\color{javared},
commentstyle=\color{javagreen},
morecomment=[s][\color{javadocblue}]{/**}{*/},
numbers=left,                   % where to put the line-numbers
numberstyle=\tiny,              % the size of the fonts that are used for the line-numbers
stepnumber=1,                   % the step between two line-numbers. If it is 1 each line will be numbered
numbersep=5pt,                  % how far the line-numbers are from the code
backgroundcolor=\color{white},  % choose the background color. You must add \usepackage{color}
showspaces=false,               % show spaces adding particular underscores
showstringspaces=false,         % underline spaces within strings
showtabs=false,                 % show tabs within strings adding particular underscores
tabsize=2,                      % sets default tabsize to 2 spaces
captionpos=b,                   % sets the caption-position to bottom
breaklines=true,                % sets automatic line breaking
breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
escapeinside={\%*}{*)}          % if you want to add a comment within your code 
} 

\begin{document}

\end{document}

extract-vocabsec.txt file contains the following code

regions:  #\label{vocab:regions-start}#
    Building: integer;
    Floor: integer;
    Room: integer;  #\label{vocab:regions-end}#
structs:                  #\label{vocab:structs-start}#
    BadgeDetectedStruct    #\label{vocab:badgedetectedstructs-start}#
        badgeID: string;
        timeStamp: long;   #\label{vocab:badgedetectedstructs-end}#
    TempStruct            #\label{vocab:tempstruct-start}#
        tempValue: double;
        unitOfMeasurement: string;  #\label{vocab:structs-end}#
resources:   
    sensors:                        #\label{vocab:sensors-start}#
        BadgeReader                 #\label{vocab:badgereader-start}# 
            generate badgeDetected: BadgeDetectedStruct;  #\label{vocab:badgereader-end}# 
        TemperatureSensor               #\label{vocab:tempsensor-end}#
            generate tempMeasurement: TempStruct;  #\label{vocab:sensors-end}#
    actuators:                   #\label{vocab:actuators-start}#
        Heater                 #\label{vocab:heater}#
            action Off();      #\label{vocab:action-end}#
            action SetTemp(setTemp: TempStruct);   #\label{vocab:actuators-end}#
    storages:       #\label{vocab:storages-start}#
        ProfileDB   #\label{vocab:profile-start}#
            generate  profile: TempStruct accessed-by badgeID: string;  #\label{vocab:storages-end}#
    userinterfaces:   #\label{vocab:ui-start}#
        EndUserGUI   #\label{vocab:endusergui-start}#
            command Off();  #\label{vocab:command-off}#
            action DisplayData(displayTemp: TempStruct);    #\label{vocab:displaydata}#     
            request profile(badgeID);    #\label{vocab:profile-ui}# 

Best Answer

Comment out line no. 376 in aesm_edspia.cls

%\def\uppercase{}

assuming the document class is like http://aesm.asso.univ-poitiers.fr/files/Modele_Latex.zip

Related Question