A Few Latex Tips

I’ve been finishing up the final formatting for my thesis this last week at Utah State University. Latex is great when you are provided a style file beforehand. If you have to modify or create your own style however, beware. That is a more time consuming process. I haven’t yet switched back to a traditional word processor (heaven forbid) but I have had a few mornings of pulling hair.

I thought I’d add a few of the things I discovered here:

The beginning document class.

I started with the article document style and then created my own style file that changes the defaults where I need. Here is a list of packages I needed to complete my formatting.

\documentclass[times,12pt]{article}
\usepackage{graphicx} %\includegraphics
\usepackage{latexsym} %\Box, \Join
\usepackage{setspace}
\usepackage{subfigure} % subfigures
\usepackage{amsmath} % equation
\usepackage[titles,subfigure]{tocloft} % table of contents, list of figures etc formatting
\usepackage{lastpage} % total page count
\usepackage{thesis} % my style file (thesis.sty}

Resetting Page Dimensions.

My school requires exact page dimensions. You can change dimensions with the \setlength command in the style file.

% by default, there is 1 inch at the top.
% This makes the bottom 1 inch as well after taking into consideration 1 line for a page number header
\setlength{\textheight}{8.875in}
% be default there is a 1 inch left margin.
% I'm adding 0.5 inches so I need to change the width to 6.0 instead of 6.5
\setlength{\textwidth}{6.0in}
\setlength{\topmargin}{0in}
% add a double space between the header and the 1st line of text
\setlength{\headheight}{12pt}
\setlength{\headsep}{12pt}
\setlength{\parindent}{1em} % paragraph indent size
\setlength{\oddsidemargin}{0.5in} % 1.5 inch left margin
\setlength{\evensidemargin}{0.5in}

Redefining section headers.

You can redefine how section headers are formatted. I redefined subsection, and subsubsection similar to the following in order to get my subsection and subsubsection headers double spaced instead of triple spaced.

\def\subsection{\@startsection {subsection}{2}{\z@}
{1pt}{1pt} {\normalsize\bf}}

The section header was a little more challenging. It needed to say Chapter instead of Section and be centered on the page. You can’t add centering and line formatting by redefining the section command itself. Instead, I had to create a new command and manually call the commands that the section command would have called. In my document, I used Section instead of section.

\newcommand{\Section}[1]{\clearpage % put new chapters on a new page
 \refstepcounter{section} % manually increment the chapter number
% manually add the chapter to the table of contents
 \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}
% and now format the header according to spec.
 \begin{center}
 CHAPTER \thesection

 #1
 \vspace*{12pt}
 \end{center}
}

Table of Contents formatting.

I had to center my table of contents headers. If you just want to change the table of contents title, you can redefine that instead of redefining the command altogether.

\def\tableofcontents{\section*{\centering CONTENTS}\@starttoc{toc}}

Notice that I used the section command instead of my redefined Section command. That is because I didn’t want the Table of contents to be titled with Chapter.

I used the tocloft package to change the formatting of individual Table of Contents parts.

% change section headers and page numbers to normal instead of bold font
\renewcommand{\cftsecfont}{
\normalfont
}
\renewcommand{\cftsecpagefont}{%
\normalfont
}
% use leader dots with section headers (by default, only the subsections had them
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

Widows and Orphans

I found that you can help protect widows and orphans by raising the [widow|club]penalty:

\widowpenalty=1000
\clubpenalty=1000

Citation Format

I had a citation that needed a page number. The spec said it needed to be separated with a “:” instead of a comma. I redefined the cite command as follows:

\def\@cite#1#2{[{#1\if@tempswa:#2\fi}]}

Page Count

On the abstract page, I had to make reference to the total number of pages in the document. After adding the lastpage package, you simply use the \pageref command:

(\pageref{LastPage} pages)

If you happen to be searching around for how to format your CS Thesis at USU, I’d be happy to add additional details. Just leave a comment or feel free to contact me.

This entry was posted in Miscellaneous and tagged , , , , . Bookmark the permalink.

2 Responses to A Few Latex Tips

  1. indeed says:

    Very useful. The cite page number tip in particular for now, but I’m sure the rest will come in handy at some point. Duly Stumbled.

  2. bdubb says:

    Great latex tips! This worked for me but I found that the section titles in the footer/header break (aka dont appear) when redefine my sections as shown above. Any suggestions?

Comments are closed.