5

I have a style where all paragraphs have indentation of about 5cm. Verbatim environment does not have any indentation to the combination of paragraphs and verbatim environments does not look good. Something like this:

             This is paragraph ...
          Next line of the same paragraph.

and this is verbatim

Is it possible to define an global indent for verbatim environment?

2
  • 3
    Why don't you use listings.sty? Commented Jan 13, 2011 at 17:46
  • Can you provide a minimal example? I don't think I understand what is going on exactly. Is the verbatim in the margin?
    – TH.
    Commented Jan 14, 2011 at 8:32

2 Answers 2

5

Some extented packages provide this feature. For example, fancyvrb:

% in preamble \usepackage{fancyvrb}
\begin{Verbatim}[xleftmargin=2em]
hello
\end{Verbatim}

Global setting can be done by \fvset:

\fvset{xleftmargin=2em}
-1

what about this idea: You can but all you verbatim environment inside quote environments. If that will fit your needs, you can of course define

\newenvironment{qverb}{\begin{quote}\begin{verbatim}}{\end{verbatim}\end{quote}}

your own "qverb" environment for that case.

Greets

5
  • It cannot (in fact, impossible) work. You can't use verbatim env in another environment's argument.
    – Leo Liu
    Commented Jan 28, 2011 at 7:20
  • @Leo-Liu - I'm sorry to tell your comment is wrong. I just tried \documentclass[english]{report} \usepackage{babel} \usepackage{blindtext} \begin{document} \blindtext \begin{verbatim} Hallo \end{verbatim} \blindtext \begin{quote}\begin{verbatim} Hallo \end{verbatim}\end{quote} \blindtext \end{document} and it worked well. I think you ment one cannot use other environments INSIDE of verbatim, did you? Commented Jan 28, 2011 at 7:39
  • 2
    I don't want to argue. You can use verbatim env in quote env, but you cannot use verbatim in arguments of \newenvironment and use it without errors. Just put your definition of qverb in your document and have a try.
    – Leo Liu
    Commented Jan 28, 2011 at 7:54
  • And you can refer this FAQ: tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin
    – Leo Liu
    Commented Jan 28, 2011 at 7:55
  • @Leo-Liu: Okay, I got it - you are right. Thanks for teaching me! Commented Feb 24, 2011 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .