GeneralToo long lines with fancyvrb and Verbatim frame

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
bubada
Posts: 2
Joined: Tue Mar 13, 2007 1:19 am

Too long lines with fancyvrb and Verbatim frame

Post by bubada »

Hi all,
I am a newbie to Latex. Please tell me if I am posting my question at the wrong place.
-----------------------------------------------------------------

I use the fancy verbatim package in order to draw a line on top and bottom of the content. However, the content is quite short but the line is too long. It is too urgly.

Code: Select all

\begin{Verbatim}[fontshape=it,label=INPUT,
  frame=lines, labelposition=topline,fontsize=\scriptsize]
            one two three
\end{Verbatim}

I have tried all the documentation of the fancyvrb package but I find no macro or command that can make the line shorter.

Any help is appreciated.

Dang

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Void
Posts: 11
Joined: Mon Mar 12, 2007 3:00 pm

Re: using fancyvrb

Post by Void »

why not using \hline{...} before and after verbatim instead...
No or not enough coffee, user halted.
bubada
Posts: 2
Joined: Tue Mar 13, 2007 1:19 am

Re: using fancyvrb

Post by bubada »

\hline is used for tabular environment, is that true ? I want to use the Verbatim because it allows me to put code in there.
User avatar
Void
Posts: 11
Joined: Mon Mar 12, 2007 3:00 pm

Too long lines with fancyvrb and Verbatim frame

Post by Void »

\hline is used where ever you want to have a horizontal line. If you append a number in {} you can specify the length of that line.

By the way, I used

Code: Select all

\newcommand{\prog}[1]{\texttt{#1}} 
in the header and in the text

Code: Select all

\prog{some text}
to show code syntax.

In your case perhaps instead of \texttt \textit or something.
No or not enough coffee, user halted.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Too long lines with fancyvrb and Verbatim frame

Post by localghost »

Void wrote: \hline is used where ever you want to have a horizontal line. […]

Could you please give me a working example outside the tabular environment? Or what do you mean with "where ever"?
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
N00bDaan
Posts: 14
Joined: Tue Feb 27, 2007 4:44 pm

Too long lines with fancyvrb and Verbatim frame

Post by N00bDaan »

Ok, \hline is indeed used in tabular enviroments and you can use it without the tabular enviroment, but then you will get some stupid error when compiling... The solution is simple:

Code: Select all

\hrule
Inserting \hrule anywhere in the text will draw a line as wide as the textwidth. I am also messing around with the lines in headers and footers and I will post my solution to the whole problem when I get it working. :)
Cheers
User avatar
Void
Posts: 11
Joined: Mon Mar 12, 2007 3:00 pm

Too long lines with fancyvrb and Verbatim frame

Post by Void »

localghost wrote:
Void wrote: \hline is used where ever you want to have a horizontal line. […]

Could you please give me a working example outside the tabular environment? Or what do you mean with "where ever"?


It seems, you're right and I was wrong. \hrule is the right way to draw a line. Excuse me for any inconvenience.

To shorten or enlength the line or vary the thickness you can use:

\hrule width 100mm height 1pt
No or not enough coffee, user halted.
pfjorgeo
Posts: 6
Joined: Fri Mar 30, 2007 11:28 pm

Too long lines with fancyvrb and Verbatim frame

Post by pfjorgeo »

You can try with

Code: Select all

\begin{minipage}[c]{5cm}
\begin{Verbatim}...
...
\end{Verbatim}
\end{minipage}
where {5cm} is the desired width, remember not to try a width greater than \textwidth (approximately 12.4cm when working with the default margins of LaTeX).
Post Reply