# UDThesis: LaTeX packages and modifications

### Algorithmic and Algorithm

1. After the package declaration in your preamble (after \documentclass {udthesis} and before \begin{document}) of your main LaTeX UDThesis file (e.g. main.tex):

\usepackage{algorithmic}
\usepackage{algorithm}

add the following lines:

% Change the List of Algorithms to be in all caps
\renewcommand{\listalgorithmname}{LIST OF ALGORITHMS}

% Redefine List of Algorithms to include an entry in the TOC and be properly spaced

\makeatletter
\renewcommand*{\listofalgorithms}{%
\begingroup
\@ifundefined{@restonecoltrue}{}{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
}%
\prefacesectiontoc{\listalgorithmname}
\vspace*{\parskip}
{\pretolerance=10000\raggedright
\renewcommand{\baselinestretch}{1}\large\normalsize
\parskip\baselineskip
%\parskip\z@\parindent\z@\parfillskip \z@ \@plus 1fil%

\@starttoc{loa}%
\@ifundefined{@restonecoltrue}{}{%
\if@restonecol\twocolumn\fi}
}%
\endgroup
}%

% Define the algorithm listing for list of algorithms to be spaced the same as LOF
and LOT with dotted lines
\def\l@algorithm#1#2{\@dottedtocline{1}{1.5em}{3.2em}{#1}{#2}}
\makeatother

2. Put \listofalgorithms after \maketoclof in your Title and Approval page file (e.g. tap.tex) .
3. Run LaTeX at least 3 times to get all the cross-references and updates correctly in the .loa and .toc.

### Overleaf

When using Overleaf there may be a number of packages included as part of using Overleaf, and as such you may find it will change the way UDThesis is designed to work. This document serves to provide a list of suggested changes/recommendations reported by clients that fix issues with UDThesis formatting when using Overleaf.

After the package declaration in your preamble (after \documentclass {udthesis} and before \begin{document}) of your main LaTeX UDThesis file (e.g. main.tex) you need to comment out this package by putting a % in front of it:

%\usepackage{parskip}

add the following lines:

\setlength{\parskip}{6pt}

### gb4e - Linguistic tools

By default line numbering in your examples will be continuous throughout your document regardless of chapters, appendices, etc. If you want the line numbers to include the chapter number or appendix letter and reset at 1 with each new chapter or appendix, then you will find these instructions useful.

After the package declaration in your preamble (after \documentclass {udthesis} and before \begin{document}) of your main LaTeX UDThesis file (e.g. main.tex):

\usepackage{gb4e}

add the following lines:

\renewcommand{\thexnumi}{\thechapter.\arabic{xnumi}} % the manual way
\makeatletter
\makeatother
\exewidth{(1.234)} % leave enough room for the example number

### Listings

These steps have to be done by everyone who is using the listings package:

1. After the package declaration in your preamble (after \documentclass {udthesis} and before \begin{document}) of your main LaTeX UDThesis file (e.g. main.tex)

\usepackage{listings}

add the following lines:

% Change the List of Listings to be in all caps
\renewcommand\lstlistlistingname{LIST OF LISTINGS}
% Redefine List of Listings to include entry in
% the TOC and properly spaced
\makeatletter
\renewcommand*{\lstlistoflistings}{%
\begingroup
\@ifundefined{@restonecoltrue}{}{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
}%
\prefacesectiontoc{\lstlistlistingname}
\vspace*{\parskip}
{\pretolerance=10000\raggedright
\renewcommand{\baselinestretch}{1}\large\normalsize
\parskip\baselineskip
%\parskip\z@\parindent\z@\parfillskip \z@ \@plus 1fil%
\@starttoc{lol}%
\@ifundefined{@restonecoltrue}{}{%
\if@restonecol\twocolumn\fi}
}%
\endgroup
}%
% Define the lstlisting for list of listings to be
% spaced the same as LOF and LOT with dotted lines
\def\l@lstlisting#1#2{\@dottedtocline{1}{1.5em}{3.2em}{#1}{#2}}
\makeatother

% Define lstcaptioncont for listings that go across more than 1 page
\newcommand{\lstcaptioncont}{\begin{center}
\textbf{Listing \thelstlisting:} Continued
\end{center}
2. Put \lstlistoflistings after \maketoclof in your Title and Approval page file (e.g. tap.tex).

3. Run LaTeX at least 3 times to get all the cross-references and updates correctly in the .lol and .toc.

### Troubleshooting: Listings that extend over several pages

If you have a listing across several pages, then you need to split them by hand. Most listings will only be two pages, so use \lstcaptioncont for the second page of each listing instead of specifying captionpos and caption keyword for the lstlisting as you would for the first page. The new command will take the current counter from the first page of the listing and use "Continued" for the caption with no entry in the List of Listings (.lol). Here is an example of a listing split across two pages:

\clearpage
\lstset{float, frame=single, tabsize=2, breaklines=true, basicstyle=\tiny, language=Java}
\begin{lstlisting}[captionpos=b, caption=Java Method 11]
-----GS-BEGIN-METHOD-11
1 void CMainFrame::ProcessCommandLine()
2 {
3     const CCommandLine pCommandLine = wxGetApp().GetCommandLine();
4     if (!pCommandLine)
5         return;
6
7     wxString site;
8     if (pCommandLine.HasSwitch(CCommandLine.sitemanager))
9     {
10         Show();
11         OpenSiteManager();
12     }
13     else if ((site = pCommandLine.GetOption(CCommandLine.site)) != _T(""))
14     {
15            CSiteManagerItemData_Site pData = CSiteManager.GetSiteByPath(site);
16
17            if (pData)
18            {
19                if (ConnectToSite(pData))
20                {
21                    SetBookmarksFromPath(site);
24                 }
25                 //delete pData;
26             }
27      }
28 \end{lstlisting}

\clearpage
\lstset{float, frame=single, tabsize=2, breaklines=true, basicstyle=\tiny, language=Java}
\begin{lstlisting}
29      if (server.GetLogonType() == ASK ||
30          (server.GetLogonType() == INTERACTIVE && server.GetUser() == _T("")))
31      {
33              return;
34      }
35 }
\end{lstlisting}
\lstcaptioncont

### tocloft for defining List of ...

These steps have to be done by everyone who is using the tocloft package:

1. The tocloft package should be part of your LaTeX installation. Unfortunately if you use this package, it redefines the Table of Contents, List of Figures and List of Tables as defined to meet the requirements for UDThesis. To fix this, download the style file UDtocloft-fix.sty and put it the same folder with your main LaTeX UDThesis file (e.g. main.tex)

2. Define the package declaration in your preamble (after \documentclass {udthesis} and as the last 2 lines before \begin{document}) of your main LaTeX UDThesis file (e.g. main.tex).

\usepackage[titles]{tocloft}
\usepackage{UDtocloft-fix}

3. Now define your list after \begin{document} in your main LaTeX UDThesis file (e.g. main.tex). The example below is what you might use to define a LIST OF EQUATIONS based on using the filename equ and defining \myequations for the captions after each equation you would want to appear in the list.

\newcommand{\listequationsname}{LIST OF EQUATIONS}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
{\ignorespaces #1}}\par}
\setlength{\cftmyequationsnumwidth}{3.2em}
\setlength{\cftmyequationsindent}{1.5em}
\makeatletter
\let\l@equ\l@figure
\renewcommand{\listofmyequations}{%
\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
\fi\chapter*{\listequationsname\@mkboth{\listequationsname}{\listequationsname}}
{\pretolerance=10000\raggedright
\renewcommand{\baselinestretch}{1}\large\normalsize
\parskip\baselineskip
\@starttoc{equ}\if@restonecol\twocolumn\fi}}
\makeatother


It is important to note "equ" will generate a file .equ based on your main LaTeX file, so you need to make sure this is unique and is not used by any other package you are using in LaTeX (i.e. toc, lof, lot, loe, etc. are already defined and used by LaTeX).

4. Now use \myequations{equation caption} to have the equation number and caption appear in your LIST OF EQUATIONS. For example,
$$pw \medspace = C_1 (T_4 - T_5) + C_2.$$
\myequations{PW linear regression computation using AVHRR thermal split window}

5. Put the following lines after \maketoclof in your Title and Approval page file (e.g. tap.tex).
\clearpage
\phantomsection
\listofmyequations

6. Run LaTeX at least 3 times to get all the cross-references and updates correctly in the .equ (this is your newly defined list file for LIST OF EQUATIONS) and .toc.

You can use the above example to create any list based on any counter where you would be able to label and reference.

0 reviews

## Details

Article ID: 883
Created
Mon 10/4/21 3:12 PM
Modified
Wed 12/15/21 11:11 AM