I am using the algorithms package for my pseudocode. The only problem I encounter is in the List of Algorithms. The spaces between the items in the list do not correspond to the spacing in the List of Figures or the List of Tables. How can I make the List of Algorithms look the same?
I have attached an example.
Thanks in advance.
General ⇒ Spacing in List of Algorithms
Spacing in List of Algorithms
- Attachments
-
- LoA-Behaviour.tex
- Minimal working example of strange spacing in the List of Algorithms compared to the LoF and LoT.
- (2.04 KiB) Downloaded 467 times
TeXnicCenter 1RC, LEd 0.53, MikTeX 2.8, Windows XP (SP3)
NEW: TikZ book now 40% off at Amazon.com for a short time.

Spacing in List of Algorithms
I managed to figure out how to fix this problem. To get the spacing right between algorithms in the same chapter, add the lineafter your caption.
If the algorithm is the last one in the chapter, add an ADDITIONALafter the previous command.
That seems to result in the correct spacings. If those values are not quite right, please let me know.
Code: Select all
\addtocontents{loa}{\vskip 6pt}
If the algorithm is the last one in the chapter, add an ADDITIONAL
Code: Select all
\addtocontents{loa}{\vskip 9pt}
That seems to result in the correct spacings. If those values are not quite right, please let me know.
TeXnicCenter 1RC, LEd 0.53, MikTeX 2.8, Windows XP (SP3)
-
- Posts: 1
- Joined: Wed Feb 22, 2012 5:48 am
Spacing in List of Algorithms
I, too, would like to adjust the spacing of List of Algorithms. However, I want the spacing following the title of my list of algorithms page to be the same as my list of figures and list of tables. If someone could help me figure this out, I would greatly appreciate it.
Thank you
Thank you
Code: Select all
\documentclass[12pt,letterpaper, titlepage, oneside]{book}
\renewcommand{\rmdefault}{phv} % Arial
\renewcommand{\sfdefault}{phv} % Arial
\usepackage[noline, linesnumbered]{algorithm2e}
\SetAlCapNameSty{textbf}\SetAlCapNameFnt{\normalsize}%sets the captions of algorithm figures to be bold and normal
\SetAlgoSkip{}%No extra vertical skip before or after algorithms
\DontPrintSemicolon
\usepackage[explicit]{titlesec}%Modify the layout of the chapter and section titles
\titleformat{\chapter}[display]{\normalfont\filcenter\sffamily}
{\chaptertitlename\,\,\thechapter}
{-\parskip}
{\large\bf\MakeUppercase{#1}}
\titlespacing*{\chapter}{0in}{-\baselineskip}{\baselineskip}
\assignpagestyle{\chapter}{fancy}%%%%%%%%%%%%%%This assigns fancy pagestyles to chapter pages!!!!!Remember to remove \thispagestyle{} from other pages!!!
\usepackage{tocloft} % Make adjustsments to table of contents
%\setlength{\cftsecnumwidth}{1cm}
%\setlength{\cftbeforechapskip}{2ex}
%\setlength{\cftbeforesecskip}{.001ex}
\setcounter{tocdepth}{3}
\newcommand*{\noaddvspace}{\renewcommand*{\addvspace}[1]{}}%get rid of extra space in lof entries between chapters
\renewcommand{\contentsname}{Table of Contents} % change "Contents" to "Table of Contents"
\renewcommand{\cfttoctitlefont}{\vspace{-2\baselineskip}\hfill\large\bfseries\MakeUppercase}
\renewcommand{\cftaftertoctitle}{\hfill%
\vspace{\baselineskip}\\{\bf \underline{Chapter} \hfill \underline{Topic} \hfill \underline{Page}
\vspace{-\baselineskip}
}
}%center TOC to page
\renewcommand{\listfigurename}{List of Figures}
\renewcommand{\cftloftitlefont}{\vspace{-2\baselineskip}\hfill\large\bfseries\MakeUppercase}
\renewcommand{\cftafterloftitle}{\hfill%
\vspace{\baselineskip}\\{\bf \underline{Figure Number} \hfill \underline{Topic} \hfill \underline{Page}
\vspace{-\baselineskip}
}
}%center LOF to page
\renewcommand{\listtablename}{List of Tables}
\renewcommand{\cftlottitlefont}{\vspace{-2\baselineskip}\hfill\large\bfseries\MakeUppercase}
\renewcommand{\cftafterlottitle}{\hfill%
\vspace{\baselineskip}\\{\bf \underline{Table Number} \hfill \underline{Topic} \hfill \underline{Page}
\vspace{-\baselineskip}
}
}%center LOT to page
\usepackage[top=1in, bottom=1in, left=1.25in, right=1in]{geometry}
\usepackage{setspace}
%\singlespacing
%\onehalfspacing
%\doublespacing
\setstretch{2}%Set line spacing
\setlength{\parskip}{\baselineskip}%Set Pargraph Spacing to extra line skip
\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0 pt}%0 pt means no line
\renewcommand{\footrulewidth}{0 pt}
\fancyhf{}%THIS IS NOT A DUPLICATION NEED BOTH OF THESE BELOW!
\fancyhead[R]{\normalfont{\thepage}}%place page number in header to Right for Odd and Even pages
\fancyhead[C]{}
\fancyhead[L]{}
\fancypagestyle{plain}{%make chapter pages adhere to same page number positions as regular pages
\fancyhf{} % remove everything
\fancyhead[R]{\normalfont{\thepage}}%place page number in header to Right for Odd and Even pages
\fancyhead[C]{}
\fancyhead[L]{}
}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%CONTENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\raggedright
\frontmatter
\begin{onehalfspace}
\newpage
\tableofcontents
\end{onehalfspace}
\newpage
\listoftables
\addcontentsline{toc}{section}{\listtablename}
\newpage
\listoffigures
\addtocontents{lof}{\protect\noaddvspace}
\addcontentsline{toc}{section}{\listfigurename}
\begin{spacing}{5}
\clearpage
\listofalgorithms
\addcontentsline{toc}{section}{List of Algorithms}
\end{spacing}
\newpage
\vspace{-\baselineskip}
\begin{singlespace}
\begin{center}
\begin{minipage}{0.68\textwidth}
\begin{algorithm}[H]
\SetKw{Kw}{procedure}
\Kw{evolutionary algorithm}\;
\Begin{
$t \longleftarrow 0$\;
initialize $P(t)$\;
evaluate $P(t)$\;
\While{{\bf not} termination-condition}{
\Begin{
$t \longleftarrow t+1$\;
select $P(t)$ from $P(t-1)$\;
alter $P(t)$\;
evaluate $P(t)$\;
}
}
}
\vspace{\baselineskip}
\caption[EA Pseudo-code]{Evolutionary algorithm pseudo-code}
\addtocontents{loa}{\vspace{-1.75\baselineskip}}%NECESSARY TO REDUCE SPACING IN LIST OF ALGORITHMS!!!!
\label{alg:stdEA}
\end{algorithm}
\end{minipage}
\end{center}
\end{singlespace}
\end{document}