From 01a92bfb5a0a74a6cebd3ac1ac23f67b7d1e049a Mon Sep 17 00:00:00 2001 From: Kenneth Odle Date: Sat, 28 Oct 2023 19:21:08 -0400 Subject: [PATCH] Updated code blocks section with information about verbatim, fancyvrb, and fvextra packages --- lbol.tex | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lbol.tex b/lbol.tex index 1f18f44..ffc9224 100644 --- a/lbol.tex +++ b/lbol.tex @@ -722,8 +722,34 @@ The only way around that is to break that text into two parts like this: It works, but it's clunky. If you change anything around those two \texttt{verb} commands, you'll need to adjust what is contained within each of them. -For longer code examples, you will need to use the built-in environment \texttt{verbatim}. To gain more control over those environments, you will need to use the package \texttt{fancyvrb} (which uses the \texttt{Verbatim} environment—note the capital letter). Need even more control than the \texttt{fancyvrb} package gives you? Try the \texttt{fvextra} package. (I used it because it very nicely breaks lines inside this environment.) +For longer code examples, you will need to use the built-in environment \texttt{verbatim}, which makes use of the \verb|\begin{verbatim}| and \verb|\end{verbatim}| commands to define the environment. +To gain more control over those environments, you can use the package \texttt{fancyvrb} (which uses the \texttt{Verbatim} environment—note the capital letter). You can add options in square brackets after the \texttt{begin} command. For example, to format the example blocks in this document, I am using this code: + +\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, label=\fbox{Verbatim Example}, framesep=6mm, breaklines=true, commandchars=\+\(\)] +\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, label=\fbox{Bullets Example}, framesep=6mm] +\begin{itemize}[noitemsep] + \item[$\Box$] First item + \item[$\aleph$] Second item + \item[$\triangle$] Third item +\end{itemize} +\ +!+!+!+!+!+! end{Verbatim} +\end{Verbatim} + +Here's a brief breakdown of what those options do: + +\begin{itemize}[noitemsep] + \item \texttt{frame=lines} puts a line at the top and bottom of the code block. Other options are \texttt{leftline}, \texttt{topline}, \texttt{bottomline}, and \texttt{single} (which puts a box around the code block). + \item \texttt{numbers=left} adds line numbers to the left side of the code block. + \item \texttt{xleftmargin=5mm} adds a five millimeter margin to the left side, so that the line numbers are not hanging off into space. + \item \texttt{label=} adds a label to the top of the code block. Putting it in an \texttt{fbox} adds a border around it. +\end{itemize} + +There are numerous other options in this package; please see the package documentation for more details + +The \texttt{fvextra} package adds even more options for the \texttt{Verbatim} environment. Again, there are too many to list here; please see the package documentation, which is extensive. + +If you still need even more options, you can try the \texttt{listings} package, which I have yet to try. \section{Quotations}