Generallstlisting problems

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
eleanor
Posts: 19
Joined: Sat Oct 03, 2009 6:03 pm

lstlisting problems

Post by eleanor »

Hi, I have a problem with lstlisting. Look at these two examples:

Code: Select all

    \begin{lstlisting}
int main () {
  bool b = true;
  cout << boolalpha << b << endl;
  cout << noboolalpha << b << endl;
  return 0;
}
    \end{lstlisting}
or:

Code: Select all

    \begin{lstlisting}
      int main () {
        bool b = true;
        cout << boolalpha << b << endl;
        cout << noboolalpha << b << endl;
        return 0;
      }
    \end{lstlisting}
Well I have to combine those two options to include:
1) from the first: there are no empty spaces in the lstlisting's box in the pdf file (when generated with pdflatex)
2) from the second: is the style I would like to use when typing the latex code in the notepad

Any ideas how to do that?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply