In order to produce an ereader-friendly PDF with small page dimensions, I'd like to scale down some oversize verbatim blocks such as program output with lines too long for the small page. Then readers should be able just to zoom in when needed. This simple test using adjustbox and the BVerbatim environment from fancyvrb works fine:
\documentclass[12pt,a4paper]{article}
\usepackage{adjustbox}
\usepackage{fancyvrb}
\begin{document}
\begin{adjustbox}{max width=\linewidth}
\begin{BVerbatim}
a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line
\end{BVerbatim}
\end{adjustbox}
\end{document}
However, I'm having a bit of trouble with wrapping the adjustbox+verbatim combo in a reusable environment. In particular, this attempt:
\documentclass[12pt,a4paper]{article}
\usepackage{adjustbox}
\usepackage{fancyvrb}
\newenvironment{myverb}{
\begin{adjustbox}{max width=\linewidth}
\begin{BVerbatim}
}{
\end{BVerbatim}
\end{adjustbox}
}
\begin{document}
\begin{myverb}
a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line
\end{myverb}
\end{document}
produces this error:
Runaway argument?
! File ended while scanning use of \FancyVerbGetLine.
<inserted text>
\par
And this attempt:
\documentclass[12pt,a4paper]{article}
\usepackage{adjustbox}
\usepackage{verbatim}
\newenvironment{myverb}{%
\adjustbox{max width=\linewidth}%
\verbatim
}{%
\endverbatim
\endadjustbox
}
\begin{document}
\begin{myverb}
a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line
\end{myverb}
\end{document}
results in this error:
! LaTeX Error: Something's wrong--perhaps a missing \item.
Do you think what I need can be achieved using available LaTeX packages and tools?
\VerbatimEnvironmentcommand, which doesn't seem too well known but works like a charm! – Yar Sep 20 '13 at 09:59\VerbatimEnvironmentis that forfancybox. Go figure! – Yar Sep 20 '13 at 10:17\begin{verbatim}environment. nothing fancy command etc. Just scale the verbatim environemnt? – droid192 Apr 29 '19 at 22:50