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 want to show a JSON object in my document. If I do the following, it works:

\begin{lstlisting}
{
  "id": "5",
  "key": "discardedCard"
}
\end{lstlisting}

But if I extend the code to the following, then there are only errors when compiling the document:

\begin{lstlisting}
{
  "id": "5",
  "key": "discardedCard",
  "value": {
    "suit": "DIAMONDS",
    "rank": "QUEEN"
  }
}
\end{lstlisting}

Error log:

! Incomplete \iffalse; all text was ignored after line 19.
<inserted text> 
                \fi 
l.19     "
          suit": "DIAMONDS",
A forbidden control sequence occurred in skipped text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

! Incomplete \iffalse; all text was ignored after line 19.

I'd like to provide a MWE but if I run the code in a MWE then it works. So it looks like there are other parts in my bachelor thesis which break the document.

Is there a way to output code in a listing in a secure way or maybe escaped?

share|improve this question
    
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Marco Daniel Mar 3 '13 at 15:13
1  
I would guess you have a language shorthand (babel?) that defines " to do something, you can locally turn shorthands off, which might help. –  David Carlisle Mar 3 '13 at 15:13
    
@DavidCarlisle: I thought this is related to france. Benny lives in Germany ;-) –  Marco Daniel Mar 3 '13 at 15:17
    
Thank you David! Yes, I use babel. The problem was that the name of my chapter was "\chapter{Implementation of "`Jiga"'}". I changed it to "\chapter{Implementation of Jiga}" which removed the error. –  Benny Neugebauer Mar 3 '13 at 15:19
    
There is no relation to babel. :-) –  Marco Daniel Mar 3 '13 at 15:22

1 Answer 1

I would guess you have a language shorthand (babel?) that defines " to do something, you can locally turn shorthands off, which might help

share|improve this answer
2  
I had the same problem and it was related to the place of \usepackage[francais]{babel}. Solved the problem when I put it before \usepackage{listings} in preamble. –  Penbeuz Dec 16 '13 at 9:21
    
@Penbeuz That's it! Exactly the same problem (babel francais). Merci! –  Madeleine P. Vincent Apr 19 at 23:34

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.