I'm looking for a way to combine the features of the verbatim-
environment
and LaTeX's automatic line breaking.
I've found the following thread
http://groups.google.it/group/comp.text.tex/browse_thread/thread/a15a9ed113a3939c/8b8f03337a51282c?
It is suggested to use the package listings.
However, when I include \usepackage{listings} and compile afterwards
I receive no error messages but the output are 0 pages.
Without \usepackage{listings} the compilation works fine and my
document is 20 pages long.
Any suggestions are most appreciated!
Hello,
please provide an MWE. Normally the listings package works just fine.
--
Replace “READ-MY-SIG” by “tcalveu” to answer by mail.
Here we go:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{report}
\begin{document}
This is a minimal example.
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The above example compiles with 1 page.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{report}
\usepackage{listings}
\begin{document}
This is a minimal example.
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The second example compiles with 0 pages.
> Here we go:
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \documentclass{report}
>
> \begin{document}
>
> This is a minimal example.
>
> \end{document}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> The above example compiles with 1 page.
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \documentclass{report}
> \usepackage{listings}
>
> \begin{document}
>
> This is a minimal example.
>
> \end{document}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> The second example compiles with 0 pages.
What does the log file say, in the second case?
Ciao
Enrico
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \documentclass{report}
> \usepackage{listings}
>
> \begin{document}
>
> This is a minimal example.
>
> \end{document}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> The second example compiles with 0 pages.
No problem here.
Add \listfiles at the start and check the versions:
*File List*
report.cls 2005/09/16 v1.4f Standard LaTeX document class
size10.clo 2005/09/16 v1.4f Standard LaTeX file (size option)
listings.sty 2007/02/22 1.4 (Carsten Heinz)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
listings.cfg 2007/02/22 1.4 listings configuration
--
Ulrike Fischer
Here is the content of the log file:
This is pdfeTeX, Version 3.141592-1.30.6-2.2 (MiKTeX 2.5) (preloaded
format=latex 2007.9.4) 9 APR 2009 14:04
entering extended mode
**minimalexample.tex
(minimalexample.tex
LaTeX2e <2005/12/01>
Babel <v3.8g> and hyphenation patterns for english, dumylang,
nohyphenation, ge
rman, ngerman, french, loaded.
("C:\Program Files\MiKTeX 2.5\tex\latex\base\report.cls"
Document Class: report 2005/09/16 v1.4f Standard LaTeX document class
("C:\Program Files\MiKTeX 2.5\tex\latex\base\size10.clo"
File: size10.clo 2005/09/16 v1.4f Standard LaTeX file (size option)
)
\c@part=\count79
\c@chapter=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) (listings.sty
Package: listings 2002/04/01 1.0 (Carsten Heinz)
("C:\Program Files\MiKTeX 2.5\tex\latex\graphics\keyval.sty"
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
\KV@toks@=\toks14
)
\lst@mode=\count88
\lst@gtempboxa=\box26
\lst@token=\toks15
\lst@length=\count89
\lst@currlwidth=\dimen103
\lst@column=\count90
\lst@pos=\count91
\lst@lostspace=\dimen104
\lst@width=\dimen105
\lst@newlines=\count92
\lst@lineno=\count93
\c@lstlisting=\count94
\lst@maxwidth=\dimen106
(lstpatch.sty
File: lstpatch.sty 2002/10/13 1.0i (Carsten Heinz)
)
(lstmisc.sty
File: lstmisc.sty 2004/02/13 1.2 (Carsten Heinz)
***
*** This file requires `listings.sty' version 1.2.
*** You have a serious problem, so I'm exiting ...
***
) ) )
(\end occurred inside a group at level 1)
### semi simple group (level 1) entered at line 1820 (\begingroup)
### bottom level
(\end occurred when \ifx on line 1820 was incomplete)
(\end occurred when \ifx on line 1820 was incomplete)
(\end occurred when \ifx on line 1820 was incomplete)
(\end occurred when \ifx on line 1820 was incomplete)
(\end occurred when \ifx on line 1820 was incomplete)
(\end occurred when \ifx on line 1820 was incomplete)
Here is how much of TeX's memory you used:
909 strings out of 95420
11485 string characters out of 1187321
57930 words of memory out of 1061630
4120 multiletter control sequences out of 60000
3640 words of font info for 14 fonts, out of 1000000 for 2000
14 hyphenation exceptions out of 8191
23i,1n,28p,152b,61s stack positions out of 5000i,500n,10000p,200000b,
32768s
No pages of output.
Upgrade your MiKTeX distribution. As far as I can see you are trying
to use different versions of the listings bundle: the main style file
is version 1.0, while ltpatch.sty is version 1.2.
Ciao
Enrico
You may also try the following:
\makeatletter
\def\@xobeysp{ }
\makeatother
This redefines \@xobeysp, to which the space character is \let in
verbatim text, to a normal space instead of an unbreakable space. Then
you can use the usual "verbatim" environment.
Paul
Wow! Thank you!
That's a very elegant solution! It does work and I don't have to
bother
with dealing with listings.sty at all.
Well, I have another question related to my previous one. Now,
following
Paul's aka zappathustra's above my "verbatim" environment has an
automatic line break.
And here is a follow-up question:
I would like a "verbatim"-environment within a sentence.
Example:
This is an example and I want \begin{verbatim}TO_BE_LEFT_IN_THIS_LINE
\end{verbatim}
to be left in this line.
But the result is that there is a new line started. So the output
looks
like:
This is an example and I want
TO_BE_LEFT_IN_THIS_LINE
to be left in this line.
However, I want the output to be:
This is an example and I want TO_BE_LEFT_IN_THIS_LINE to be left in
this line.
How can I achieve that?
Thanks!
Never mind! I've just found the answer:
This is an example and I want \verb+TO_LEFT_IN_THIS_LINE+ to be left
in
this line.
Thanks anyway!