Useful LaTeX

Some snippets of LaTeX that I have used at some point or another, and may be useful to anyone else.

Package: hyperref

Simply including this package will make your table of contents have clickable links to pages in the document.

Package: todonotes

This package was an absolute life saver during my dissertation.

It provides the use of todo{} tags, which place a marker on the page with a virtual ‘sticky note’ showing your to-do item text, and also provides a listoftodos command, which creates a list of all your to-do notes.

Furthermore, with the hyperref package included in your document, the to-do item list will have links to their respective pages!

usepackage{todonotes}

% ========================= %
% ==== REMOVE ON FINAL ==== %
listoftodos
pagebreak
% ==== REMOVE ON FINAL ==== %
% ========================= %

Text text, texty text…
todo{This is a to-do note!}%
Stuff stuffs… list of stuff.

todo{This is another one!}%

Shorter List Style

The default list style in latex I found to be excessively spacious, and in any list heavy sections, the page numbers started to rack up!

To remedy this, I defined a new environment for a thinner list style

% This makes list spacing much better.
%
newenvironment{thinlist}{
begin{itemize
}
setlength{itemsep}{1pt}
setlength{parskip}{0pt}
setlength{parsep}{0pt}
}{
end{itemize
}
}

begin{thinlist}
item Item one
item Item two
item …
item Further items
end{thinlist}

Package: makerobust

During the course of writing my dissertation, I came across the problem of not being able to put url{} commands inside a footnote{} command, this is due to the way latex handles URLs, as the command is not considered to be ‘robust’.

Long story short, I searched around, and found the ‘makerobust’ package, which wraps non-robust commands in a robust frame, making them robust, as can be seen in the snippet below

usepackage{makerobust}

% Make the damn url command work in caption’s
%
MakeRobustCommandurl

Package: listings

I’m a computer scientist, so having code listings in a document is par for the course. To support this, I used the ‘listings’ package to nicely format my code.

usepackage{listings}

% Magic listing style!
%
lstset{basicstyle=tiny, tabsize=1, numbers=left}

The lstset{} command in the snippet above sets the basic style for code listings – I had a few large sections of code to include, so I set the font to tiny and a tab size of 1 space. You may wish to edit this to suit.

The full manual for the package can be found here: ctan.org’s copy of the listings manual

Package: pdflscape, pdfpages

My gantt charts for the dissertation were generated from Microsoft Project (The best I could get at the time! No hate mail plase!) in PDF format, so to include them in the Appendix, I used pdflscape.

This is nothing particularly spectacular, but I’m putting it here in case someone else stumbles upon it.

usepackage{pdfpages}
usepackage{pdflscape}

begin{landscape}
includepdf[pages={1,2},landscape=true]{gantt/gantt_chart.pdf}
end{landscape}

Note that you can include specific pages with the optional ‘pages’ argument.

This Post Has Been Viewed 95 Times




No Comments


You can leave the first : )