Latex
Table of Contents
Disclaimer
This page is really a dumping ground for all my Latex related tips/tricks/hacks that I've made and might help someone out there.
Essex PhD Thesis Class
Since I'm studying for my PhD at the University of Essex, I must comply to their submission regulations. I'm only in the draft phase at the moment, but I've been developing a class file that hopefully others will find useful. It is tailored to my needs at the moment (such as file/class name etc.), but hopefully if people contact me with feedback/changes it will become more general and useful to everyone.
Also note I use Scientific Word to write my thesis (I just got used to it and I don't want to switch until I've finished), compiling on a MikTex install, so things like the theorem environments are commented out since apparently Scientific Word requires the definition of the theorems in the actual file being worked on (otherwise it throws a fit).
Feel free to use and distribute the LaTeX class file. If you use Scientific Word/Workplace you'll also need the CST file and latex2.dat file. These files are released under the GPL version 3.
Using \title and \author Title Page Data as PDF Metadata
For a while I've been annoyed the \title, \author, etc.
commands don't set the information in PDF output (the pdfinfo metadata) when using the hyperref package.
The problem being that this data is set inside the document body, where the PDF
metadata is set in the document preamble.
The simple soulution is to define new commands that provide the required
text, and call them when configuring hyperref and the titlepage
data. However, this makes the document more cumbersome to maintain, and a pain
in the backside when using a tool like Scientific Word/Workplace.
After a flash of inspiration, I realised there's a nice simple alternative to
this that minimally intrudes into the document since it uses
the hyperref.cfg file do all the work for you. Essentially on
each compilation it generates a new configuration file with the required
settings to be picked up by the next compilation cycle, akin to the requirement
of multiple runs for indexes, bibliographies, etc.
In place of (or in addition to, see the package manual for information on the
precedence of settings) a \hypersetup command, simply add this code to the preamble of your document
(or just use the PhD thesis class file above):
\newcommand{\hyperrefconfig}[3]{
\newwrite\outputstream
\immediate\openout\outputstream=hyperref.cfg
\immediate\write\outputstream{%
\string\hypersetup{%
pdftitle={#1},%
pdfauthor={#2},%
pdfsubject={#3},%
pdfdisplaydoctitle=true,%
bookmarksnumbered=true,%
plainpages=false,%
pdffitwindow=true,%
pdfstartview={FitH},%
pdfnewwindow=true,%
colorlinks=true,%
linkcolor=black,%
citecolor=black,%
filecolor=black,%
urlcolor=cyan%
}%
}
\immediate\closeout\outputstream
}
This command, which takes three arguments for title, author and subject
respectively, will generate the settings file that the hyperref package will
automatically pick up as its configuration settings. You can change the above code in accordance to how you wish to configure
the package, presented are the settings I in my PhD thesis class file.
Finally just add this code anywhere inside your document body, as long as it
appears after the \@title, \@author, etc. strings have been set:
\hyperrefconfig{\@title}%
{\@author}%
{Subject of the document}
In the PhD thesis class I add this command to my title page definition, which is generated manually, ensuring it'll always be executed, always be after the data being set, and minimises any addition to the main document file.
Simply recompile your document a few times and the resulting PDF should be linked as desired and include the specified metadata.
So far I have discovered one limitation: break commands such
as \linebreak in the document title etc. rather buggers things up.
I've tried a few things to solve the problem, but nothing really solves the problem.
Luckily I don't have an imediate issue with this, but I'd be very interested if anyone
can spot a simple way to solve this. And as always, all feedback welcome.
Microsoft Word-like underline
See the ulem package, and if that's not what you need then read on.
Latex is great, but not so much when underlining text. Especially problematic is underlining a word like "hello" as opposed to "help", the underline will always be pushed down so it never intersects the text. Of course this isn't always the desired feature, perhaps you want the line to sit consistently under the text in the same location, or for it to appear directly beneath the text as it does in Microsoft Word. Here are my (not wonderful) solutions:
Line consistently below text
\newlength{\somelength}
\newcommand{\ul}[1]{
\settowidth{\somelength}{p}
\underline{#1\kern -\somelength\phantom{p}}
}
Where the hidden "p" (the width of which we obtain dynamically) consistently forces the underline to the same position below the lowest point of the text (under a phantom "p" character).
Microsoft Word style underline
\newcommand{\ul}[1]{
\leavevmode
\setbox0=\hbox{#1}
\underline{\hspace{\wd0}}
\kern-\wd0\box0
}
Where there is an invisible box which is underlined, and then the text is written on top of that same space. This version is inspired from an implementation of poor man's bold that I found, and allows the underline to consistently appear directly below the text similar to how it would appear in Microsoft Word.
This site has been optimized for use on mobile browsers, to see the full site in all its glory please visit again from a non-mobile browser.
Thank you.


