0

I need to deal with loads of code lines in verbatim mode and append them to the appendix. That is, I may not need to show them in a fancy way but I want them to occupy least amount of space. As you could see in the following figure, the text occupy a lot of space. I also need them to have a fix indent from right and left, so by keeping as many in a line, they indentation varies. enter image description here

Paul Gessler
  • 29,607
Ramin
  • 291

2 Answers2

2

Would this be close to what you seek? The proposed solution utilizes fancyvrb package where

  1. xleftmargin/xrightmarin (dimension) commands for indentation to add at the start/end of each line (Default: 0pt—no left/right margin) is readily available.

  2. However, this solution also defines myindent macro taking one length argument for manual indentation within Verbatim environment.

  3. Furthermore, the shrinking of text is via resizebox from graphicx. The outer frame can be removed by removing the frame=single key.

enter image description here

Code

\documentclass{article}
\usepackage[top=1cm]{geometry}
\usepackage{fancyvrb,graphicx}
\newcommand\myindent[1]{
\makebox[#1]{}
}
\begin{document}
Before:
\begin{Verbatim}[frame=single]
pred3(s11,s17,s11,s19,s10).

\myindent{1cm} pred3(s11,s17,s11,s19,s10).

\myindent{2cm} pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred4(s19).

pred5(s16).

pred6(s10,s12,s17,s11,s14).

logic symbols like ->
\end{Verbatim}

After:
\begin{Verbatim}[frame=single,commandchars=\\\{\}, xleftmargin=1cm,xrightmargin=1cm]
\resizebox{\textwidth}{!}{
\begin{minipage}{\textwidth}
pred3(s11,s17,s11,s19,s10).

\myindent{1cm} pred3(s11,s17,s11,s19,s10).

\myindent{2cm} pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred4(s19).

pred5(s15).

pred6(s10,s12,s17,s11,s14).

logic symbols like ->

\end{minipage}
}
\end{Verbatim}

\end{document}
Jesse
  • 29,686
1

Please always provide a complete example document, Thanks to Jesse, I stole this one from the other answer.

You can use \small or any other font size to reduce the size of the verbatim:

enter image description here

\documentclass{article}

\begin{document}
\vspace*{-3cm}
Before:
\begin{verbatim}
pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

pred3(s11,s17,s11,s19,s10).

    pred4(s19).

    pred5(s16).

    pred6(s10,s12,s17,s11,s14).

    logic symbols like ->
\end{verbatim}

After:
{\small
\begin{verbatim}
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
pred3(s11,s17,s11,s19,s10).
    pred4(s19).
    pred5(s16).
    pred6(s10,s12,s17,s11,s14).
    logic symbols like ->
\end{verbatim}}

\end{document}
David Carlisle
  • 757,742