Updated code blocks section with information about verbatim, fancyvrb, and fvextra packages
This commit is contained in:
parent
8f3adce5e3
commit
01a92bfb5a
28
lbol.tex
28
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}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user