\begin{verbatim}
--------------------------------------
bla bla bla
--------------------------------------
\end{verbatim}
I want that the width of this environment is equal to \textwidth
Suggestions?
--
THANX!
how? the width of each character is a fixed size, so I suggest you
explain in a bit more detail what exactly it is you want
--
/daleif (remove RTFSIGNATURE from email address)
LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html
...not the width of *each* character... but the width of the *total box*
which
contain the environment.
I use verbatim env. because the fixed size is desired but
the width of the environment exceeds the right-margin
(example the verbatim code for a shell-script).
I want to *shrink* the box of the environment exactly to textwidth.
Look at the listings package ("language={}"). It is more flexible.
...Rolf
...well, but i don't want to edit programs or scripts. I want
simply write some block in plain-text without to count the
spaces for each line!
I want only the *same width* (textwidth) for env1 and env2:
\begin{verbatim} %env1 (too large)
-------------------------------
here and here
-------------------------------
\end{verbatim}
\begin{verbatim} %env2 (too strict)
----------------------
here here
----------------------
\end{verbatim}
But how do you want to shrink? Do you want to scale down the whole
box? This will lead to different font size on the page and will look
awful.
Either break your lines manually or use the listings package. It has
an option for line breaks.
--
Ulrike Fischer
then you will have to save the contents in a box and then scale that box
using e.g. \resizebox, but as Rolf already mentioned I'd reather
recommend using the listings package, it is highly configurable, it can
even break long lines.
I think it will look odd if you through out your document have code
listings in various different font sizes
I can't understand why you must count anything. You can give the listing
environment a width like you want. In addition you can frame these
constant-with boxes an much more. See the documentation!
...Rolf
\resizebox{\textwidth}{}{\begin{verbatim}
bla bla
\end{verbatim}}
no, verbatim is a special beast, it can only be used inside other
environments, so you first have to store the contents inside a box
\newsavebox\mybox
\begin{lrbox}{\mybox}
\begin{verbatim}
...
\end{verbatim}
\end{lrbox}
\resizebox{\textwidth}{}{\usebox{\mybox}}
(untested)
but as lots of people have now told you, please reconsider this and use
a better construction. Another benefit of using listings is that it has
syntax highlighting and is able to get the source kode form external files.
-----> LaTeX Error: Something's wrong--perhaps a missing \item.
>
> but as lots of people have now told you, please reconsider this and use
> a better construction. Another benefit of using listings is that it has
> syntax highlighting and is able to get the source kode form external
> files.
>
...ok, but i want simply to shrink the text/tables/notes in plain text
and not to edit code.
then perhaps verbatim cannot be used like this, as I said verbatim is a
special beast
>>
>> but as lots of people have now told you, please reconsider this and
>> use a better construction. Another benefit of using listings is that
>> it has syntax highlighting and is able to get the source kode form
>> external files.
>>
>
> ...ok, but i want simply to shrink the text/tables/notes in plain text
> and not to edit code.
which code? the code you want to display our the source of your document
* example 1 (plain-text tables)
\begin{verbatim}
---------------------------------------------
First date 10/5 - 11/8 - 23/9
---------------------------------------------
[notes on
10/5]
---------------------------------------------
\end{verbatim}
* example 2 (your long-line post without wrapping...)
\begin{verbatim}
no, verbatim is a special beast, it can only be used inside other
environments, so you first have
to store the contents inside a box
\newsavebox\mybox
\begin{lrbox}{\mybox}
\begin{verbatim}
...
\end{verbatim}
\end{lrbox}
\resizebox{\textwidth}{}{\usebox{\mybox}}
(untested)
but as lots of people have now told you, please reconsider this and use
a better construction.
Another benefit of using listings is that it has syntax highlighting
and is able to get the source
kode form external files.
\end{verbatim}
* example 3 (copy-and-paste preformatted text from web)
\begin{verbatim}
I've paid my dues / Time after time
I've done my sentence / But committed no crime
And bad mistakes / Ive made a few / I've had my share of sand kicked in
my face ---> TOO LONG
But I've come through...
\end{verbatim}
>> ...ok, but how to use resizebox with verbatim?
>>
>> \resizebox{\textwidth}{}{\begin{verbatim}
>> bla bla
>> \end{verbatim}}
>
> no, verbatim is a special beast, it can only be used inside other
> environments, so you first have to store the contents inside a box
>
> \newsavebox\mybox
>
> \begin{lrbox}{\mybox}
> \begin{verbatim}
> ...
> \end{verbatim}
> \end{lrbox}
>
> \resizebox{\textwidth}{}{\usebox{\mybox}}
>
> (untested)
There is a ! missing in \resizebox, and you will have to put a box
around the verbatim.
\documentclass[a4paper,twoside]{book}
\usepackage{varwidth}
\usepackage{graphicx}
\begin{document}
\newsavebox\mybox
\begin{lrbox}{\mybox}
\begin{varwidth}{3\textwidth}
\begin{verbatim}
...
\end{verbatim}
\end{varwidth}
\end{lrbox}
\resizebox{\textwidth}{!}{\usebox{\mybox}}
\end{document}
--
Ulrike Fischer
> * example 3 (copy-and-paste preformatted text from web)
>
> \begin{verbatim}
> I've paid my dues / Time after time
> I've done my sentence / But committed no crime
> And bad mistakes / Ive made a few / I've had my share of sand kicked in
> my face ---> TOO LONG
> But I've come through...
>
> \end{verbatim}
\begingroup\ttfamily\obeylines
I've paid my dues / Time after time
I've done my sentence / But committed no crime
And bad mistakes / Ive made a few / I've had my share of sand
kicked in
my face ---> TOO LONG
But I've come through...
\endgroup
--
Ulrike Fischer
\textwidth
^ ^
|-------------|
This is normal
formatted text
with LaTeX.
.-------------.
| |
| | <----- This is verbatim BOX stretched to fit!
| |
`-------------'
This is yet
formatted text
with LaTeX.
I don't want to insert auto-break in my lines.
Example:
.-----------------------------.
| Cm Gm7/C |
| I ve paid my dues |
| Cm Gm7/C |
| And time after time |
| Cm Gm7/C | <---- Verbatim *without*
| I ve done my sentence | breaks is indispensable
| Cm Gm7/C |
| But commited no crime |
| |
`-----------------------------'
^
|
I want to shrink/stretch this BOX and not insert braks.
> I am not enough *intelligible*... my question is
> how to reduce the BOX with verbatim content in order
> to it fit in a document.
And what's wrong with the code with \resizebox and varwidth I sent
four hours ago?
--
Ulrike Fischer
...ops! Pardon, i try your code only now...
It's exatly that i want!
Thanx!