General ⇒ Spacing in List of Algorithms
Spacing in List of Algorithms
I have attached an example.
Thanks in advance.
- 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 476 times
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Spacing in List of Algorithms
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.
-
- Posts: 1
- Joined: Wed Feb 22, 2012 5:48 am
Spacing in List of Algorithms
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}