Section on customizing list environments

This commit is contained in:
Kenneth John Odle 2024-07-03 14:16:23 -04:00
parent 4ec046d0bb
commit 333706b9cf

View File

@ -27,6 +27,7 @@
\usepackage{tabto} % Use tab stops when we need to (especially in footnotes)
\usepackage{microtype} % Make things neater. Thanks /u/-LeopardShark-
\usepackage{tabularray} % Easy tables
\usepackage[]{FiraSans} % sans-serif font; https://tug.org/FontCatalogue/firasansregular/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -387,7 +388,9 @@ It's possible that the snap was configured wrong. It's also possible that I bork
Ever since I first learned about outlining in high school (or was it earlier?) I've always loved being able to organize information hierarchically. The irony is that I also love biology and the natural world does not necessarily organize itself in a hierarchical way. Cross-pollination and inter-species breeding is a thing.
You can use the built-in \texttt{enumerate} environment to create outlines, but it requires lots and lots of embedded environments. (\texttt{html} is the same way—an occupational hazard, I suppose.) I grew up using a typewriter, so I've always been looking for something simpler.
You can use the built-in \texttt{enumerate} environment to create outlines, but it requires lots and lots of nested enumerate environments. (\texttt{html} is the same way—an occupational hazard, I suppose, of liking outlines.) I grew up using a typewriter, so I've always been looking for something simpler.
\section{The \texttt{outlines} Package}
Loading it is pretty easy, as it has no options. You just add this to your preamble:
@ -425,7 +428,9 @@ which gives us this beautiful bean footage:
The indents in your source code are absolutely not necessary, but you can indent with tabs or spaces to help you keep visual track of things. The levels are controlled by the number after the backslash.
A couple of caveats: First, you are limited to four levels of indentation. (This is a part of \LaTeX{}.) But you can always introduce a normal, non-itemized paragraph into your list by using \verb|\0| as a list item, which prevents you from having to end a previous environment and creating a new one.
\section{Caveats}
A couple of caveats: First, you are limited to four levels of indentation. (This is a part of \LaTeX{}.\footnote{It is possible to build list environments with more than four levels, but I don't think they would automatically work with the \texttt{outlines} package. However, its code is fairly straightforward and simple, so if I get time, I may play around with making my own package.}) But you can always introduce a normal, non-itemized paragraph into your list by using \verb|\0| as a list item, which prevents you from having to end a previous environment and creating a new one.
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=\fbox{outlines Example with Normal Paragraph}]
\begin{outline}[enumerate]
@ -457,9 +462,125 @@ This also resets all the counters after that normal paragraph. I think this is f
I also passed the \texttt{[enumerate]} option to the environment, so that instead of symbols, it uses numbers and letters to label the list items, rather than symbols. I like this.
\section{Custom Outline Styles}
Unfortunately, this is not the style of outlining I learned in high school.\footnote{Apparently, I learned what the Purdue OWL calls a ``decimal outline''. See \kref{https://owl.purdue.edu/owl/general_writing/the_writing_process/developing_an_outline/types_of_outlines.html}{https://owl.purdue.edu/owl/general\_writing/the\_writing\_process/developing\_an\\\_outline/types\_of\_outlines.html}.} However, it is possible to use \texttt{renewcommand} to change the counter style when using the \texttt{[enumerate]} option to get what we want. What we need to know is that the \texttt{enumerate} list style uses two sets of placeholders to keep track of things. \texttt{labelenumi} etc. determines what kind of label you see, and \texttt{enumi} etc. keeps track of the counter. So we can do something like this:
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=\fbox{Custom Outlineing Style in outlines Package}]
\renewcommand{\labelenumi}{\Roman{enumi}.}
\renewcommand{\labelenumii}{\Alph{enumii}.}
\renewcommand{\labelenumiii}{\arabic{enumiii}.}
\renewcommand{\labelenumiv}{\alph{enumiv}.}
\begin{outline}[enumerate]
\1 Top-level item.
\2 Second-level item.
\3 Third-level item.
\4 Fourth-level.
\end{outline}
\end{Verbatim}
\noindent{}which produces this:
\renewcommand{\labelenumi}{\Roman{enumi}.}
\renewcommand{\labelenumii}{\Alph{enumii}.}
\renewcommand{\labelenumiii}{\arabic{enumiii}.}
\renewcommand{\labelenumiv}{\alph{enumiv}.}
\begin{outline}[enumerate]
\1 Top-level item.
\2 Second-level item.
\3 Third-level item.
\4 Fourth-level.
\end{outline}
Keep in mind that because we are using the standard \texttt{enumerate} commands, this will affect \textit{all} numbered listst that follow it. We would have to reset these if we need to prevent that from happening. For that, we can use this code:
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=\fbox{Commands to Reset enumerate Environment}]
\renewcommand{\labelenumi}{\arabic{enumi}.}
\renewcommand{\labelenumii}{(\alph{enumii})}
\renewcommand{\labelenumiii}{\roman{enumiii}.}
\renewcommand{\labelenumiv}{\Alph{enumiv}.}
\end{Verbatim}
If you need to pop in and out of your outlines and also numbered lists quite a bit, you could just turn both sets of those \texttt{renewcommand} lines into macros to make your mischief a bit easier to manage.
\section{Customizing \texttt{enumerate} and \texttt{itemize} List Environments}
Given all that, it's pretty easy to see how to customize list environments. You just need to know the commands that those environments use to keep track of things. Here's a list of the commands used to generate the labels for both environments:
\begin{longtblr}
[
caption = {Label Commands for List Environments},
label = {tb:listcommands},
% theme = {custom1}
]{
width = {\textwidth},
colspec = { X[16,l] X[41,l] X[41,l] },
hlines = {0.5pt,solid},
vline{1,4} = {0.5pt,solid},
rows = {5mm, m, rowsep=1.5pt},
row{1} = {font=\bfseries},
rowhead = 1,
cells = {font=\sffamily\fontsize{9pt}{12pt}\selectfont},
}
Level & \texttt{enumerate} commands & texttt{itemize} commands \\
Level 1 & \texttt{labelenumi} & \texttt{labelitemi} \\
Level 2 & \texttt{labelenumii} & \texttt{labelitemii} \\
Level 3 & \texttt{labelenumiii} & \texttt{labelitemiii} \\
Level 4 & \texttt{labelenumiv} & \texttt{labelitemiv} \\
\end{longtblr}
Because \texttt{enumerate} environments also use numbers, we need some counter variables to keep track of those. They look like this:
\begin{longtblr}
[
caption = {Counter Variables for Numbered Lists},
label = {tb:enumcountervar},
% theme = {custom1}
]{
width = {0.7\textwidth},
colspec = { X[30,l] X[70,l] },
hlines = {0.5pt,solid},
vline{1,3} = {0.5pt,solid},
rows = {5mm, m, rowsep=1.5pt},
row{1} = {font=\bfseries},
rowhead = 1,
cells = {font=\sffamily\fontsize{9pt}{12pt}\selectfont},
}
Level & \texttt{enumerate} counter variable \\
Level 1 & \texttt{enumi} \\
Level 2 & \texttt{enumii} \\
Level 3 & \texttt{enumiii} \\
Level 4 & \texttt{enumiv} \\
\end{longtblr}
And what can you make those labels look like? List this:
\begin{longtblr}
[
caption = {Counter Variable Formats},
label = {tb:counterform},
% theme = {custom1}
]{
width = {0.7\textwidth},
colspec = { X[60,l] X[40,l] },
hlines = {0.5pt,solid},
vline{1,3} = {0.5pt,solid},
rows = {5mm, m, rowsep=1.5pt},
row{1} = {font=\bfseries},
rowhead = 1,
cells = {font=\sffamily\fontsize{9pt}{12pt}\selectfont},
}
Command & Example \\
\texttt{\textbackslash{}arabic\{cv\}} & 1 \\
\texttt{\textbackslash{}roman\{cv\}} & i \\
\texttt{\textbackslash{}Roman\{cv\}} & I \\
\texttt{\textbackslash{}alph\{cv\}} & a \\
\texttt{\textbackslash{}Alph\{cv\}} & A \\
\end{longtblr}
Just substitute one of the counter variables from table \ref{tb:enumcountervar} in place of the \texttt{cv}.
\chapter{Coda}