Scripts$Murdoch James Gabbay I mostly use Linux (an operating system) and LaTeX (a professional typesetting language). One of the charming things about these systems is their configurability. Often this is by means of scripts; short programs to automate repetitive tasks. The dollar sign$ is not a reference to money, but to the hackers’ interactive promptserving humanity since punched tape went out of fashion. These scripts are provided free under the GPL for your convenience.
I cannot guarantee that this code will do what you expect, nor that this code will not do what you would not expect—like e-mail itself to your friends, wipe your data, blow smoke, and die laughing. Therefore what these scripts do to you, your data, or your material possessions, is your responsibility and not mine.
If you would like such guarantees to become possible — then fund computer science research.

Convert for web

Let’s start with something simple. I have used this bash script to convert my photos to 1600×1200 for the web:

for i in *.dir/*[.jpg,.JPG];
do convert -size 1600x1200 $i -resize 1600x1200 -quality 65$i;
echo Converted $i; done chmod -R o+x *.dir chmod -R o+R *.dir/*  Convert pdf to djvu Djvu (pronounced ‘dejaview’) is a document format which is more compact and faster to view than pdf. Converting pdf to djvu used to be difficult, so I developed a script adapted from pdfs2djvu which uses code kindly supplied by Sebastien Carlier. Click here to download the pdftodjvu script I include it for completeness; you might be better off using the better-written pdf2djvu package (which if you use Debian you can install by typing sudo apt-get install pdf2djvu). No margins in LaTeX Am I the only one to be irritated by small letters and wide margins in documents onscreen? So I use the LaTeX geometry package to adjust minimise set to zero and eliminate the margins, thus extirpating that pesky white space around the edges … like so — %Small pagesize and no margins = nice big letters onscreen. \usepackage[paperheight=7in,paperwidth=4.7in,margin=.01in]{geometry}  — and the document fits nicely on my desktop screen in dual page mode. Here are example pdf files: with margins and without margins. The text is an excerpt from my brother’s PhD thesis. Read double page spread on small (notebook) screen Notebook computers tend to have small screens and (for the moment) relatively low resolutions. Every pixel counts, and every square centimeter too. So people like me, who write academic papers while travelling, will have problems with reading on-screen: modern “wide aspect ratio” screens are the wrong shape, and the margins may waste precious screen real estate too. Add this to your preamble to get a nice readable double page spread: \usepackage[height=5.42in,width=3.8in, paperheight=5.42in,paperwidth=3.8in, noheadfoot]{geometry}  The numbers above are good for a 1024x768 (i.e. 4:3) screen; you may wish to adjust the numbers to suit you. Here is an article using the modified page layout and using the default page layout. Compact bibliographies in LaTeX OK. So now you’ve typeset your paper and it’s 16 pages long (one page over the limit) — because of the generous separation between items in the bibliography. The bibliography is not intended for reading as a continuous piece of text, and we should not typeset it as if this were the case. This works like a charm: %Compact bibliography, due to Axel Reichert. \let\oldthebibliography=\thebibliography \let\endoldthebibliography=\endthebibliography \renewenvironment{thebibliography}[1]{% \begin{oldthebibliography}{#1}% \setlength{\parskip}{0ex}% \setlength{\itemsep}{0ex}% \fontsize{8.4}{9.4} %Change these numbers to %change font size \selectfont }% {% \end{oldthebibliography}% }  I got it from here. Put ‘DRAFT’ on your draft papers in LaTeX So you want to share a draft pdf with a colleague, but you’re worried about incomplete versions of your paper being leaked? You can use the draftcopy package but that is not compatible with pdflatex. I add this to my LaTeX preamble, to put “DRAFT” in the background of every page: %Put "DRAFT" in the background. Due to Filox \usepackage{graphics} %or \usepackage{graphicx} \usepackage{type1cm} \usepackage{eso-pic} \makeatletter \AddToShipoutPicture{% \setlength{\@tempdimb}{.5\paperwidth}% \setlength{\@tempdimc}{.5\paperheight}% \setlength{\unitlength}{1pt}% \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){% \makebox(0,0){\rotatebox{55}{% {\fontsize{7cm}{7cm}\selectfont{DRAFT}}}}% %Adjust 7cm to desired font size as necessary }% } \makeatother  I got it from here; it’s somebody’s blog, and I know nothing whatsoever about them aside from hypothesising that they are a male Croatian science student who has been blogging since November 2007. No, I’m not Sherlock Holmes, I can just follow a link. Lists in LaTeX The spacing of lists in LaTeX tends to be a little generous. The mdwlist package offers compact list environments enumerate* and itemize*. On this topic you might also like to check out the paralist package. Rounded boxes in LaTeX OK, now you want to emphasise parts of some equation by putting them in nice rounded boxes, like this: \usepackage{etex} %avoid error messages from tikz due to bug \usepackage{tikz} \definecolor{shade}{HTML}{F4F4FF}%light blue shade \newcommand\shademath[1] { \raisebox{-6pt}{\begin{tikzpicture} \node [fill=shade,rounded corners=3pt] {$#1$}; \end{tikzpicture}} }  Then using the shademath command you can can get this: I adapted this from here. Align equations in LaTeX across multiple lines of text This has been a real bugbear for me. You want equations separated by lines or paragraphs of text, to line up. In certain circumstances you can use intertext, but that’s far from perfect. Here’s what I came up with: %in preamble %in preamble \usepackage{array} \newcolumntype{L}[1]{>{$}p{#1}<{$}} \newcolumntype{C}[1]{>{\centering$}p{#1}<{$}} \newcolumntype{R}[1]{>{\raggedleft$}p{#1}<{\$}}
\newcommand\maketab[2]
{\newenvironment{#1}
{\begin{quote}\noindent\begin{tabular}{#2}}
{\end{tabular}\end{quote}}
\newenvironment{#1noquote}{\noindent\begin{tabular}{#2}}{\end{tabular}}
}
...
%in document body
\maketab{tab4}{L{13em}C{1.5em}L{13em}}

\begin{tab4}
g([a]X, [a]a) = g([d]c, [d]d) & \Longrightarrow
& [a]X = [d]c, [a]a = [d]d
\end{tab4}

... lots of other text ...

\begin{tab4}
f([a]b,  Z,  X) = f([d]b,  [a]a,  Y) & \Longrightarrow
& [a]b = [d]b,\  Z = [a]a,\  X = Y
\end{tab4}

You get this perfectly aligned pair of equations:

Consecutive numbering of theorems and lemmas in LaTeX

Many publishers’ style files number Theorems, Lemmas, Remarks, and so on distinctly; so you can have Theorem 1, Remark 1, Lemma 1, Lemma 2, Lemma 3, Remark 3, Theorem 2, Corollary 1, etcetera. It’s dreadful.

How to fix this elegantly depends on whether you are using llncs or ams class files (the two classes on which most other class files are based, at least in my area of research). Here is some LaTeX you can drop into place to give you nice, well typeset, consecutively numbered theorems and lemmas. I have this at the head of every one of my papers:

%for llncs
\spnewtheorem{thrm}{Theorem}[section]{\sc }{\itshape}
\spnewtheorem{lemm}[thrm]{Lemma}{\sc }{\itshape}
\spnewtheorem{prop}[thrm]{Proposition}{\sc }{\itshape}
\spnewtheorem{corr}[thrm]{Corollary}{\sc }{\itshape}

\spnewtheorem{nttn}[thrm]{Notation}{\sc }{}
\spnewtheorem{defn}[thrm]{Definition}{\sc }{}
\spnewtheorem{xmpl}[thrm]{Example}{\sc }{}
\spnewtheorem{rmrk}[thrm]{Remark}{\sc }{}

... or this ...
%for amsthm
\newtheoremstyle{jamiestyle}% name of the style to be used
{4pt}% measure of space to leave above the theorem. E.g.: 3pt
{0pt}% measure of space to leave below the theorem. E.g.: 3pt
{\it}% name of font to use in the body of the theorem
{0pt}% measure of space to indent
{.}% punctuation between head and body
{ }% space after theorem head; " " = normal interword space
\theoremstyle{jamiestyle}
\newtheorem{thrm}{Theorem}[section]
\newtheorem{prop}[thrm]{Proposition}
\newtheorem{lemm}[thrm]{Lemma}
\newtheorem{corr}[thrm]{Corollary}
\newtheoremstyle{jamienfstyle}% name of the style to be used
{4pt}% measure of space to leave above the theorem. E.g.: 3pt
{0pt}% measure of space to leave below the theorem. E.g.: 3pt
{\normalfont}% name of font to use in the body of the theorem
{0pt}% measure of space to indent