I don't understand why the following document does not compile:

\documentclass[letterpaper, 11pt, onecolumn]{article}


struct test
    int x = 0;

Where is the problem?


[language=[11]C++] is an optional argument and [11] is another optional argument. In listings package, When using an optional argument inside another optional you need to use braces around the whole value.

\begin{lstlisting}[language={[11]C++}] ought to fix it.

If you check the listings documentation in Section 2.3 the third point in the \itemize explains it

→ ‘language=[77]Fortran’ does not work inside an optional argument. You must put braces around the value if a value with optional argument is used inside an optional argument. In the case here write ‘language={[77]Fortran}’ to select Fortran 77.

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.