TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to define an environment which requires a frame line as wide as \textwidth


I am not sure how I could constrain the width of the line?

share|improve this question
Although I can guess you're using fancyvrb, it is better to provide a Minimal Working Example here. – Leo Liu Aug 20 '12 at 7:03

One can modify this solution to a related question as follows:






  Test the verbatim.  
  Here is some more.



Sample output

\hrule on its own will produce a line of length \textwidth, however, it only adds a minimal amount of vertical space. This is the reason for putting in the \vskip's. You may well want to adjust the size of these spaces (or use \smallbreak, etc.) and you may also want to add some negative \vskip amount just after the first rule and just before the last. E.g. the following gives spacing closer to that obtained from \begin{Verbatim}[frame=lines]:


If you need the rules to be of different thickness you can write something like \hrule height 2pt instead.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.