[texhax] How to truncate lines in a fancyvrb
Niall Mansfield
texhax at uit.co.uk
Sat Jun 9 09:00:17 CEST 2007
Donald,
Donald Arseneau wrote:
> Niall Mansfield <texhax at uit.co.uk> writes:
>
>>>> I'm typesetting material which includes a lot of sample program outputs,
>>>> which are plain text, typeset using \VerbatimInput from the excellent
>>>> fancyvrb package.
>>>>
>>>> Some of the lines are very long. Is there any way to truncate them
>>>> automatically?
>> Really truncate -- ends of lines thrown away.
>
> Then I would try my truncate.sty package, defining \FancyVerbFormatLine
> in terms of \truncate.
Thanks for your message. With your help I've got it almost perfect.
One little problem remains: truncation seems to behave differently
around a space character. The little test file below shows the problem:
\documentclass{book}
\usepackage{fancyvrb}
\usepackage[breakall]{truncate}
\renewcommand{\TruncateMarker}{\rule{1em}{1em}} %% make it easier to see
\def\FancyVerbFormatLine#1{\truncate{6cm}{#1}}
\begin{document}
\begin{Verbatim}
1 10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
2 .10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
3 3.10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
4 33.10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
5 133.10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
6 .133.10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
7 0.133.10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
8 40.133.10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
9 140.133.10.1928 > 193.63.88.162.80: S 37179877:37179877(0) win 8192 <mss 1460> (DF)
\end{Verbatim}
\end{document}
(Output shown as PDF in http://uit.co.uk/norobots/verbtrun.pdf )
Lines 7 and 9 are slightly short.
(And changing the truncate length from 6cm to 5cm makes it go very weird.)
Is there a way to ensure truncation at exactly the same place?
Thanks,
Niall
More information about the texhax
mailing list