Category Archives: LaTeX
My programming journey
When clearing out some of my old programming books the other day I realised how far I’d come with programming over the years, and the number of different technologies that I have used over time. I thought I’d do a little summary post going from first programming experience to now – and it’s amazing what’s changed.
My First Programming Experience
My first proper programming experience was with a BBC Micro computer. You can tell how old I am (fairly young I know, but relatively old in computing terms) that when I was at primary school we had four computers – three BBC Micros and one Acorn machine. The machine I was using had a 5 1/4″ floppy drive (as pictured above), but the book that I used to teach me how to program assumed that I’d be using an audio cassette recorder to store my programs on – how awesome is that? Old-school yes, but practical, after all, most people had a tape recorder available (in those days at least). Anyway I managed to find a book called BBC Basic for Beginners which taught me how to write simple programs – think guessing games, simple asking questions programs (“What is your name?”, “Hello <NAME>”). I distinctly remember trying to persuade a friend to stay in during break time and write a program with me. He wasn’t interested – but oh well.
Moving further – but still staying rather BASIC
In my final year of primary school, when I was aged 10, we got our first computer at home. It ran Windows 98 (fairly new at that time) and I think it had an amazing 450Mhz processor! We also had access to the internet via dial-up, where it only took 20 minutes to download a 1Mb file – at the time that seemed amazing! Anyway, on this computer I discovered that there was a similar programming language to BBC Basic called QBasic. This had many of the same ways of writing things as BBC Basic, but was far more powerful. I had great fun writing a number of programs using QBasic – I distinctly remember writing a number of maths programs (printing multiplication tables, calculating prime numbers etc) and a few menu-based programs. I managed to find The QBasic Bible in the library one day, and couldn’t stop reading it for about three days. I remember running up to my Dad and telling him, very excitedly, about this new SELECT CASE statement that I’d come across that would remove the need for nested if statements.
Visual-ing it up
The natural progression from QBasic was to Visual Basic, and it so happened that a friend of my Grandparents gave me a copy of Visual Basic 6 Learning Edition. He’d been using it for a while but had upgraded to the Professional Edition as some features he needed were only available there. With this I discovered the joy (at least I thought it was joy then!) of GUI programming. I started off without any textbooks (our library hadn’t got that up-to-date then…) and followed a lot of tutorials. It was then that I realised that following a tutorial and just typing in the code didn’t really teach me anything – I needed to try and play around with the code, change it and see what happened, and truly try and understand it. I remember writing a painting program (without really understanding it – but being amazed at the OnPaint method and how that worked) and GUI versions of my maths programs.
An internet sideline – plus some office tools
My father is an IT (sorry, ICT) teacher, and I often managed to borrow some of his textbooks/workbooks and learnt a number of useful skills: programming in Visual Basic for Applications in Excel and Access and writing HTML. I wrote HTML pages with no server to host them on – just running them locally on my computer – and produced a project for school entirely in HTML – which amazed the teachers!
Finally – a useful use?
It seems hard to believe, but this must have taken me to the end of secondary school. I think I must have had a break from programming while doing my GCSEs, as I can’t really remember writing anything then. I think I probably dabbled in PHP a bit (a sin we’re all guilty of, I’m sure) and I remember playing with Pascal for a few days, but nothing else really. This changed when I got to Sixth Form College, and took A-Level Computing. For my A2 coursework I had to produce a piece of software for a real end-user – and I chose the person who managed the internal bookshop at my father’s school. I assessed requirements, implemented and tested code and wrote user guides. I remember feeling very impressed with myself when I worked out how to interface with the Amazon website so that I could look up book details from their ISBN numbers. (Yes I know the screenshot above is terrible – it’s the only one I could find, and is one sent by the user to show a bug – that is, that I allowed the application to be maximised and didn’t resize the controls on the screen once the user had done it). I think it must have been as part of the pseudo-assembly language that we learnt that I got interested in C and started playing around a bit. This, of course, led to a bit of C++ and a little bit more of an understanding of object-oriented programming.
A literary aside
It was around this time that I started getting very interested in reading about programming – both online and in paper format. I was a huge (understatement) fan of Joel on Software and Coding Horror and started to touch on a few of Paul Graham‘s posts too. I bought a number of programming books, ranging from the specific (ActiveX Data Objects in Visual Basic 6) to the general (Algorithms and Data Structures).
My coding goes nuclear
After Sixth Form college I took a gap year through the wonderful Year in Industry organisation, who placed me with British Energy – a company who run nuclear power stations. I spent my year writing two pieces of software to run at Sizewell B Nuclear Power Station as part of the control and safety systems. Obviously I can’t say a huge amount about what I did – but the screenshot above is allowed to be shown in public, and shows one of the sections of the software that I was most proud of. It is a live status screen showing the position and movement of a number of moveable detectors inside the reactor, and took a long time to program correctly.
It was during my Year in Industry that I learnt to program in the .NET framework – we were (for our sins) using Visual C++ .NET, which combined (again, for my sins – whatever hellish crimes they were) managed .NET C++ code with unmanaged standard C/C++ code. I got into electronics and drivers (for dealing with serial communications), writing my own graphical controls (particularly for the live status screen) and proper object-oriented design. I read Knuth (parts of) and the Gang of Four book (all of), and learnt a huge amount.
University – a scientific focus?

Everyone at British Energy assumed I’d go off to university to study Computer Science, but I shocked them by studying Geography at the University of Southampton. I left my professional programming behind to focus on rivers, glaciers, cities and poverty – but I found a way to get programming back in. During my second year I took a course in Remote Sensing – basically satellite imaging – and was amazed by what was possible. I found the software easy to use, and found that I could start extending it with my programming experience. In fact, I took my programming scientific in many ways – learning a number of new languages so that I could use various scientific tools. These included R (for statistics), Python (for use with NumPy) and IDL – a language that no-one seems to have heard of, but which is a very useful array-based scientific language, which is well integrated with a popular satellite imaging tool.
I spent the summers of my undergraduate degree doing research bursary placements (including, of course, some programming), and then used significant amounts of programming in my undergraduate dissertation. I then decided – on Christmas Eve of all days – to release a number of the pieces of code that I wrote to help me do the data processing for my dissertation as an open-source extension for a piece of satellite imaging software. I was incredibly excited to release my first bit of proper software ‘into the wild’ – and was amazed when I got to 10 downloads! The last few versions combined have had over 150 downloads now – and it is used in universities in continental Europe, environmental consultancies in Australia and by police forces in the US.
During my time at university I’ve also got more into a number of web languages and frameworks. I’ve (just about) learnt CSS, so I can produce a vaguely serviceable website, and I got very into Ruby – both as a general scripting language and as a web framework (with and without Ruby on Rails).
Piling on the workload
I’m now doing a PhD, and have returned to lower-level programming as part of my training during my first year. I took a course in parallel programming (very interesting; very difficult – think pointers but ten times harder), machine learning (it’s amazing what you can get computers to do with a bit of maths) and more (yes more) remote sensing. And, I’m really enjoying myself. My code is working (most of the time) and being used by other people, and it’s helping me write papers that – hopefully – will get published soon. I have a website, and a blog (which you’re reading).
So – how to summarise?
I’ve really enjoyed programming over the years, and have journeyed a long way from my first programming experiences. Yes, I learnt to program in BASIC, and some people say that means I’ll never be a good programmer, but I beg to differ. It gave me a great starting point which I have built-on, and I’m very glad that programming is part of my life. In fact, writing this article – and finding the screenshots to illustrate it – has made me quite nostalgic for my early programming experiences – just seeing QBasic again or VB6 has triggered so many memories. Anyway, just to finish, I’ll attempt to give a list of the various languages and frameworks that I have used over the years – I’m sure I’m missing some, but here’s a flavour:
- BBC Basic
- QBasic
- QuickBasic (the successor to QBasic – a little bit of ncurses-style GUI)
- Visual Basic 6
- ActiveX and OCX (through Visual Basic – mostly as extra GUI controls)
- Object-Oriented programming (originally through Visual Basic…yes I know…)
- HTML
- Pascal
- C
- C++
- C# .NET
- C++ .NET
- Python (particularly with NumPy)
- Ruby
- Ruby on Rails
- CSS
- IDL
- R
So, programming has done me well – and I look forward to updating this list in another 15 years time!
An ode to PDFs (and PDFs as a first class filetype)
Ahhh PDFs…., or more formally, Portable Document Format files. I remember the days when I thought that PDFs were only for instruction manuals downloaded from the internet, or electronic copies of things that you don’t want people to be able to alter. Not so – I have recently discovered the joys of PDFs, particularly through my use of Mac OS X. I will explain more below:
1. PDFs are a vector filetype. That means that when there is text in a PDF document it is stored as text, with details of the font, size and location. When there is a line in a PDF document it is stored as a line from one location to another, with details of colour, width etc. This has a number of benefits – principally that PDFs maintain their quality no matter how much you zoom into them. You never get the horrible pixelated look that you can get with raster graphics files (such as JPEG and PNG). For scientific documents this is great – it means I can generate a graph, and then with one file I can produce an A3 sized copy for use in a poster and a 6″ x 4″ copy for inclusion in the paper. Not only that, but the 6″ x 4″ copy actually looks good – it looks professional, clean and high quality. Recently I had to include a PNG graph in a LaTeX document that I was writing – I hated it, all of the lines were blurry, I couldn’t resize it and it generally looked un-professional. Of course, I’m not suggesting you should store your holiday snaps as PDFs – that’s not what they’re designed for – but for diagrams, graphs and other technical drawings they are perfect.
2. PDFs are cross platform. Nearly every system can read PDFs these days. The standard is now open (ISO 32000-1). There are readers for Windows, Linux, OS X, Android, iOS, Palm, BSD, BeOS – you name it, it’ll probably have a PDF reader. Google Chrome even has a built-in reader these days – and many websites have stopped saying “This is a PDF file. If you don’t have a program to view them please download Adobe Reader”.
3. PDFs can be included in LaTeX documents extremely easily. Yes, I know you can include PNG files just as easily, and possibly it’s even easier to use PostScript files (although who doesn’t use PdfTex these days?). As mentioned above, raster files for graphs just look horrible, particularly when included in a LaTeX document in which (as is nearly always the case with LaTeX) all of the rest of the design and typography is near-perfect.
4. PDFs do not have to be A4 sized (or Letter, for those in the US). I know – I didn’t realise this until very recently, but you can crop PDFs to any size. In fact, there is a great perl script called pdfcrop which will crop a PDF file to the minimum bounding rectangle of the contents – taking your A4-sized PDF with a 6″ x 4″ graph in it down to a 6″ x 4″ PDF – perfect for inclusion in a LaTeX document, for example.
5. PDFs can be annotated easily. For example, as the text in a PDF document is stored as text, it can be selected just like text in a word processor, and then highlighted just as easily. Of course you can also add extra text or vector illustrations (such as circles around important features in a diagram). This is great for making notes on, and highlighting papers, articles and e-books.
6. PDFs are a first class filetype in OS X. I never knew how much I’d value this until I started using OS X. By default so many things are PDF. For example, PDF export is built into the standard OS X print dialog box. On Windows you’d have to install something like CutePDF to do that – but OS X does it by default. In fact, if you use the Print Preview function in the print dialog box, OS X simply prints to a PDF and shows you the PDF in the aptly-named Preview application. In fact, this application – which can display almost any graphical filetype – is also a powerful PDF editor. Using Preview you can re-order PDF pages, merge PDFs, annotate PDFs and crop PDFs. PDFs are a first class filetype in other ways too – all Spotlight searching by default searches within text in PDF files, and there is a separate section in the Spotlight dropdown for PDF files. Overall, Apple just seem to ‘get’ PDF.
My LaTeX preamble
Since I started my PhD I have forced myself to use LaTeX for all of the documents that I write (yes, absolutely everything), and this has really helped me get to grips with how to do things in LaTeX. Overall I have been very impressed – my documents now look really professional, and LaTeX actually works really well and isn’t that hard to get to grips with.
I thought I’d write this post to explain the various packages that I always load in my LaTeX preamble. I’ve often been meaning to put all of my preamble into a style file so that I can load it in one line, but I’ve never quite got round to it. Maybe I’ll write another blog post about this when I get round to doing it…
Anyway, without further ado, below is my standard LaTeX preamble, with brief comments explaining the packages I’ve loaded. Below the code I go into further detail about the packages I use most.
\documentclass[12pt]{article}
% Pretty much all of the ams maths packages
\usepackage{amsmath,amsthm,amssymb,amsfonts}
% Allows you to manipulate the page a bit
\usepackage[a4paper]{geometry}
% Pulls the page out a bit - makes it look better (in my opinion)
\usepackage{a4wide}
% Removes paragraph indentation (not needed most of the time now)
\usepackage{parskip}
% Allows inclusion of graphics easily and configurably
\usepackage{graphicx}
% Provides ways to make nice looking tables
\usepackage{booktabs}
% Allows you to rotate tables and figures
\usepackage{rotating}
% Allows shading of table cells
\usepackage{colortbl}
% Define a simple command to use at the start of a table row to make it have a shaded background
\newcommand{\gray}{\rowcolor[gray]{.9}}
\usepackage{textcomp}
% Provides commands to make subfigures (figures with (a), (b) and (c))
\usepackage{subfigure}
% Typesets URLs sensibly - with tt font, clickable in PDFs, and not breaking across lines
\usepackage{url}
% Makes references hyperlinks in PDF output
\usepackage{hyperref}
% Provides ways to include syntax-highlighted source code
\usepackage{listings}
\lstset{frame=single, basicstyle=\ttfamily}
% Provides Harvard-style referencing
\usepackage{natbib}
\bibpunct{(}{)}{;}{a}{,}{,}
% Provides good access to colours
\usepackage{color}
\usepackage{xcolor}
% Simple command I defined to allow me to mark TODO items in red
\newcommand{\todo}[1] {\textbf{\textcolor{red}{#1}}}
% Allows fancy stuff in the page header
\usepackage{fancyhdr}
\pagestyle{fancy}
% Vastly improves the standard formatting of captions
\usepackage[margin=10pt,font=small,labelfont=bf, labelsep=endash]{caption}
% Standard title, author etc.
\title{COMP6024\\Model Specification based on \citet{Telfer:2010}}
\author{Robin Wilson\\ID: 21985588}
\date{}
% Put text on the left-hand and right-hand side of the header
\fancyhead{}
\lhead{COMP6024}
\rhead{Robin Wilson}
\chead{}
So, which of those are most important, and why do I use them:
- amsmath – This is a package by the American Mathematical Society for typesetting mathematics sensibly. I’m not a mathematician, but I often have to include maths in my documents. Nearly all of the tutorials you read on the internet for doing maths in LaTeX will be for amsmath, and it generally gives very good results (and every possibly mathematical symbol/feature you will ever need).
- parskip – I hate indented paragraphs in wordprocessed documents – I’m sure there are various typsetting rules against doing it. Anyway, this removes all paragraph indentation without screwing anything else up!
- booktabs, rotating and colortbl – These provide everything I need to produce good quality tables. Booktabs gives me a number of different options for alignment, as well as providing
\topruleand\bottomrulewhich give thicker lines for the top and bottom of tables. Rotating allows you to produce sideways tables and figures when they won’t fit properly on a portrait page, and. Colortbl allows shading of tables cells. I’ve defined my own command here because I often want to shade a table cell with a light gray. This command (\gray) is simply replaced with\rowcolor[gray]{.9}. - subfigure – This gives a really simple way to include various image files as one figure, labelling each one as (a), (b), (c), with different captions. Simple, but works really well.
- url – Again, this does one very simple thing very well: it typsets URLs sensibly. Simply wrap the url in
\url{}and it typesets it in typewriter font, makes it into a clickable link (in PDF files) and stops it breaking over lines - caption – This is one of the most important packages in my list. It allows you to style the captions produced for tables and figures to make them actually look different from the rest of the text. This is very important to help guide the reader around the page. The way I call the package is
\usepackage[margin=10pt,font=small,labelfont=bf, labelsep=endash]{caption}, and this makes the caption indented, in a smaller font, with the label (eg. Figure 10) in bold and separated from the rest of the caption by a dash. Again, this really tidies up the appearance of documents. - fancyhdr – This lets you put useful things in the header of the document. For example, for my university work I put my name on the right-hand side of the header, and the course code on the left-hand side of the header. The simple
\lheadand\rheadcommands do that for me easily.
I haven’t been through all of my packages above, but the rest of them are fairly easily understandable. In my view, they are the really key packages for almost any type of LaTeX document.



