I'm using an existing LaTeX template for a thesis and am trying to match the List of Algorithms to the List of Figures. I have already applied some formatting changes, but there are a few attributes that I am having trouble manipulating.
Here is a sample of the LoF:
And here is a sample of the LoA:
There are three attributes that I still need to edit in the LoA:
- The algorithm number needs to be flush with the column heading
- The indentation after the algorithm number needs to be reduced slightly
- The spacing between the dot separation needs to be reduced in the LoA
After much googline, I was able to find a couple attributes Ideally, I would like to know where the source code is located that produces the LoA so that I can view it myself and any documentation associated with the construction of the LOA, but I am also interested in knowing how to edit these three specific attributes.
EDIT
I'm working on a minimal working example, but the template is a bit convoluted.
Here is the main .tex file:
\documentclass[oneside, 12pt]{memoir}
\usepackage{verbatim}
\usepackage[labelsep=period, font=singlespacing, skip=12pt, format=hang,
justification=RaggedRight, singlelinecheck=false]{caption}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{indentfirst}
\usepackage{thesis}
\usepackage{layouts}
\usepackage{array}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{tocloft}
\floatname{algorithm}{\textnormal{Algorithm}}
\renewcommand{\thealgorithm}{\textnormal{\arabic{algorithm}.} }
\renewcommand{\listalgorithmname}{LIST OF ALGORITHMS\\
\thispagestyle{plain}%
\par\nobreak {\normalfont ALGORITHM \hfill PAGE}\par\nobreak
}
\begin{document}
\listoffigures
\clearpage
\pagebreak
\listofalgorithms
\clearpage
\pagebreak
\pagestyle{plain}
\mainmatter
\counterwithout{figure}{chapter}
%\counterwithout{table}{chapter}
\addtocontents{toc}{\noindent CHAPTER \par}
\setulmarginsandblock{0.75in}{1.25in}{*}
\begin{figure}[t]
\centering
\begin{subequations}
\begin{equation} \label{eq:tf}
tf(t, d) = \frac{| t \in d |}{| words \in d |}
\end{equation}
\vspace{\linespace}
\begin{equation} \label{eq:idf}
idf(t, D) = \log \frac{|D|}{|\{d \in D : t \in d\}|}
\end{equation}
\vspace{\linespace}
\begin{equation} \label{eq:tfidf}
tfidf(t, d, D) = tf(t, d) \times idf(t, D)
\end{equation}
\end{subequations}
\caption{Formula for calculating the TF-IDF}
\label{fig:tfidf}
\vspace{\linespace}
\end{figure}
\begin{algorithm}[t]
\caption{Building a C4.5 Decision Tree}
\label{alg:C4.5}
\begin{algorithmic}[1]
\STATE Check for base cases
\FORALL{$a$ $\in$ attributes}
\STATE Find the normalized information gain ratio from splitting on $a$
\ENDFOR
\STATE Let $a\_best$ be the attribute with the highest normalized information
gain
\STATE Create a decision $node$ that splits on $a\_best$
\STATE Recurse on the sublists obtained by splitting on $a\_best$, and add those
nodes as children of $node$
\end{algorithmic}
\end{algorithm}
\end{document}
Here is the .sty file that contains many custom layout commands: Link
The .sty file is particularly full of random bits and peices, but I'll try to simplify them as much as I can (edits should occur in real-time via Dropbox).
EDIT 2
Through much googline, I was able redefine a couple commands in the LoA: thealgorithm
and listofalgorithmname
. I think my main issue is that I have no idea where these commands are documented, declared, or used in the first place, so I have no idea how I can redefine other commands.
Where are these commands declared?
Best Answer
Here is my train of thought in terms of analysing the problem...
I first try and create a minimal example that replicates your problem. This means I keep an eye open for the things that you generate, and package that could influence them. For that,
algorithm
andtocloft
stand out:That was easy...
Now we try and understand the difference between how
\listoffigures
and\listofalgorithms
generate there output. Well, to understand this, it seems liketocloft
's\cftdotsep
has an influence on the former, but not the latter. Strange... Looking at the code ofalgorithms.dtx
- the source bundle for thealgorithm
package - it is clear that thealgorithm
float environment is generated by means of thefloat
package with\listofalgorithms
having the following definition:That is,
\listofalgorithms
actually just calls some\listof
routine provided byfloat
. So, let's look at\listof
:Ahhh, with a call to
\listof{<name>}{..}
, it creates\l@<name>
- the macro responsible for setting each entry inside the List of XX construct. From this I'm able to conclude that the in-line construction of\l@algorithm
is most likely not compatible withtocloft
, and that's why it's not affected in the same way.The resolution is to attempt to make
\l@algorithm
act exactly like\l@figure
. In TeX terms, this is as simple as\let\l@algorithm\l@figure
. We can useetoolbox
to patch\listof
to always make\l@XX
be equivalent to\l@figure
(for anyXX
):The above patch inserts a variant of the above-mentioned
\let
into the appropriate location of\listof
.Here's a minimal example showing the output: