Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}# 
share|improve this question
    
Comment: emphstyle should not end with \emph, that command takes an argument thus may f things up. \itshape might be better –  daleif Oct 29 '13 at 15:21
    
Thanks daleif for your effort! However, I use the above style to include code snippet in whole thesis. I am not facing problem of using \emph in other code snippets. –  Pankesh Patel Oct 29 '13 at 15:25
1  
Forgetting about the fact that your MWE misses the xcolor package, I tested your settings for article class and it works really fine! –  Pouya Oct 29 '13 at 15:41
    
Thanks pouya. I have tried your setting. I am getting the same error. –  Pankesh Patel Oct 29 '13 at 16:07
1  
Without seeing (an unabridged version of) code-snippet/extract-vocabsec.txt it's difficult to say more. –  egreg Oct 29 '13 at 18:25

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
Many Many thanks Samcarter for the answer. The problem is solved now. However, this produces a new problem. The title of each chapter is now in CAPITAL. Any suggestion on this? –  Pankesh Patel Oct 30 '13 at 10:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.