verbatim spacing

371 views
Skip to first unread message

Liow, Dr. Yihsiang

unread,
Jul 8, 2011, 10:44:20 PM7/8/11
to latexus...@googlegroups.com
Hi everyone,

I have a question on the vertical spacing before and after a verbatim environment.

I prefer to have a blank line between paragraphs. So I have

\setlength{\parskip}{12pt}

in all my tex files.

The problem is I used the verbatim environment a lot (usually with frame=single and sometimes with numbers=left and commandchars).

The the verbatim environment (at least in the way I always use it) always look better if the parskip is 0pt. In other words I do not want to have too much blank vertical space before and after the verbatim environment. But if I do that I would have to do \\ for a blank line separating paragraphs and also \mbox{} if a verbatim is the last thing in a paragraph.

Is there a good solution for this problem? In other words is there a way so that I can set parskip to 12pt and create a new verbatim environment (with frame, numbers, and commandchars) that does not have the extra vertical space before and after the new verbatim environment?

I prefer not to insert negative vertical space because that will cause problems in certain cases and it make the tex file harder to maintain.

For instance instead of:


% ---- FIRST WAY
\setlength{\parskip}{0pt}
This is the first paragraph.
\\

This is the second paragraph.
\begin{Verbatim}[frame=single]
Some verbatim stuff
\end{Verbatim}
End of second paragraph.
\\

This is the third paragraph.
\\


I wish to do this:


% ---- SECOND WAY
\setlength{\parskip}{12pt}
This is the first paragraph.

This is the second paragraph.
\begin{newverbatim}[frame=single]
Some verbatim stuff
\end{newverbatim}
End of second paragraph.

This is the third paragraph.


Thanks.

Peter Flynn

unread,
Jul 9, 2011, 12:03:41 PM7/9/11
to latexus...@googlegroups.com
On Sat, Jul 9, 2011 at 3:44 AM, Liow, Dr. Yihsiang <yl...@ccis.edu> wrote:
Hi everyone,

I have a question on the vertical spacing before and after a verbatim environment.

I prefer to have a blank line between paragraphs. So I have

\setlength{\parskip}{12pt}

in all my tex files.

Better is to use the parskip package, which does the spacing for you.
 
The problem is I used the verbatim environment a lot (usually with frame=single and sometimes with numbers=left and commandchars).

I think you mean the Verbatim environment (capital V) from the fancyvrb package. The standard LaTeX verbatim (small v) environment doesn't have any options AFAIK.
 
The the verbatim environment (at least in the way I always use it) always look better if the parskip is 0pt. In other words I do not want to have too much blank vertical space before and after the verbatim environment. But if I do that I would have to do \\ for a blank line separating paragraphs and also \mbox{} if a verbatim is the last thing in a paragraph.

Try the parskip package instead.
 
Is there a good solution for this problem? In other words is there a way so that I can set parskip to 12pt and create a new verbatim environment (with frame, numbers, and commandchars) that does not have the extra vertical space before and after the new verbatim environment?

That would be possible, but try using packages first.
 
I prefer not to insert negative vertical space because that will cause problems in certain cases and it make the tex file harder to maintain.

Yes, always avoid manual formatting if possible. That's what packages are for.

///Peter

yliow

unread,
Jul 11, 2011, 3:35:28 PM7/11/11
to LaTeX Users Group
I've tried the koma script and parskip package. Everything looks a lot
better now. Thanks.
Reply all
Reply to author
Forward
0 new messages