Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

verbatim area with word wrap?

378 views
Skip to first unread message

hori...@gmail.com

unread,
Feb 10, 2008, 1:41:08 AM2/10/08
to
I'm having a problem. I have code that I want to put into a LaTeX
document. Only thing is, some of the lines in the code are too long
and go off the side of the page when in a normal verbatim environment,
and the verbatimtab environment that Im using.

Is there a way I can make the verbatim text word wrap?

If yes, is there a way I can have verbatimtab with word wrap?

If yes, is there a way I can have verbatimtab with line numbers, like
a listing environment, with word wrap?

Thanks

vvvv

unread,
Feb 10, 2008, 9:58:06 PM2/10/08
to
There is a package called fancyvrb that might do this, but I haven't
used it. I used the \usepackage{listings} command in the preamble
and either the \lstlisting environment or the \lstinputlisting command
(there are a few others too). Use the \lstset command to specify
options for line numbers and word wrap. This package does some
formatting according to syntax (like if you are listing the text of a
program that you wrote), but maybe somebody knows if it has a PLAN
option if you don't like the formatting.

Here is some documentation:
http://www.pvv.ntnu.no/~berland/latex/docs/listings.pdf

Here is a complete example:

\documentclass{article}
% this will print a listing of a file even if it has
% characters that are normally problematic in tex.
\usepackage{listings}
\begin{document}
%
%%% the language setting would be used to format
%%% the text according to a programming languge.
%%%\lstset{language=TeX}
%
%
% This setting will affect the inline listing.
\lstset{numbers=left,breaklines=true}%set options
%

\textbf{here is an inline listing:}
\begin{lstlisting}
this is a !@#$% funn line that is long !@#ASD !@#ASD !@#ASD !
@#ASD !@#ASD !@#ASD !@#ASD !@#ASD !@#ASD !@#ASD
this is the second line
\end{lstlisting}
%
% list lines 1 through 19 of a file and word wrap (breaklines=true):
% this is a long comment line asdf asdf asdf asdf asdf asdf asdf asdf
asdf asdf asdf asdf asdf asdf asdf asdf

\textbf{Here is a listing of a file:}
% This reads a file called FileListing2.tex
% which is what I called this tex document:
\lstinputlisting[linerange=1-9,numbers=left,breaklines=true]%
{FileListing2.tex}

This line is after the file listing.
\end{document}

Robin Fairbairns

unread,
Feb 11, 2008, 4:02:11 AM2/11/08
to

gosh: only three years old.

for a current copy of the documentation, go to ctan:

http://mirror.ctan.org/macros/latex/contrib/listings/listings.pdf
--
Robin Fairbairns, Cambridge

hori...@gmail.com

unread,
Feb 14, 2008, 12:29:34 AM2/14/08
to
On Feb 11, 4:02 am, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:

Thanks, the listing package *seems* to be the package I'm looking for,
but code needs to be in a fixed width font and I cant figure out how
to change it. I want it to look like verbatim just with line wrapping.
I looked at the manual and I still cant find how to change the font.

hori...@gmail.com

unread,
Feb 14, 2008, 12:56:29 AM2/14/08
to

sorry I spoke too soon. Its easy to change the font all is needed is
to use the \lstset{ basicstyle=\ttfamily } command.

0 new messages