I'm writing my thesis with ShareLatex online tool (pdfLaTeX compiler) based on template; METU Thesis Template on ShareLatex. When I try to add a lstlisting or lstinputlisting to my document, curly braces ({, }) in my Java code are not showing at all. I'm fairly new at LaTeX but I tried a lot of solutions found online like escaping brackets in my Java code, or trying to adjust lstset parameters accordingly. I also tried to simplify and comment out every lstset directive but nothing solved my problem.

In my tests, it seems that when I use metu.cls as my document class, it messes up with my listing formatting. How can I overcome this issue or include a different document class just for my listings?Thanks for any help.

A sample of my document (For compiling, I just included some parts of the template) (For the document class directive, metu.cls file can be found in the following link - metu.cls):

%%%% Works fine with this default article document class %%%%
%%%% When I use the "metu" class, it seems like it messes up with my source codes %%%%

\graphicspath{ {./images/} }

% Listings formatting directives
\captionsetup[lstlisting]{format=listing,singlelinecheck=false, margin=0pt, font={sf}}
\definecolor{splashedwhite}{rgb}{1.0, 0.99, 1.0}
    language = Java,

% Sample lstlisting from my document
\begin{lstlisting}[caption=Browsed Log Hadoop Mapper Code]
public void map(Text key, Text value, Mapper.Context context) throws IOException, InterruptedException {
List<String> logValues = Lists.newArrayList();

StringTokenizer itr = new StringTokenizer(value.toString(), LOG_SEPERATOR);
while (itr.hasMoreTokens()) {

context.write(new Text(logValues.get(UID_INDEX)), new Text(logValues.get(URL_INDEX)));

% Sample lstinputlisting from my document
%\lstinputlisting[language=Java, float=false, frame=none]{source-codes/EUrlCategory.java}

  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – jubobs Jan 14 '15 at 20:36
  • @Jubobs thanks for the heads up, I edited the question as you suggested and I hope it helps. – Erinç İnci Jan 14 '15 at 21:40
  • 1
    Good, but it's best to have the entire MWE in one code block (less editing required). – jubobs Jan 14 '15 at 21:50
  • @Jubobs I found out that metu.cls document class file is my problem, however I need it because it is the main template document for my thesis. Can you help me to pinpoint the code that causes the problem? The class file can be found in the following link: filedropper.com/metu – Erinç İnci Jan 15 '15 at 8:16
  • 1
    Found it. It is this line inside metu.cls: \uccode`@=`I \lccode`@="10, that messes up listings and the {} disappear. It is found at the very end. No idea what it is for. – daleif Jan 15 '15 at 9:07

The problem can be seen with this very small MWE:


\uccode`@=`I \lccode`@="10

    language = Java,

... InterruptedException {


The \uccode`@=`I \lccode`@="10 line is found at the very end of metu.cls, and it apparently messes up listings. Remove the line, and the {} reappear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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