## Drawing power crosses in LaTeX

Posted: 10th September 2015 by Tim in LaTeX, Optics
Tags: , , , , , , , ,

Power crosses are useful diagrams for doing lens power calculations in optics. Drawing the power crosses in LaTeX can be tedious, especially if you need to draw multiple power crosses in the same document. The code below creates a new command, \powercross{front@90}{front@180}{back@90}{back@180}, which will draw the power crosses for you and calculate the final lens […]

## LaTeX style (.sty) files

Posted: 27th June 2014 by Tim in LaTeX
Tags: , , , , , ,

When writing LaTeX documents, you may find yourself copying and pasting some common settings such as margins, fonts and paragraph indentation. This is not only tedious, it can be a real headache if you’re writing multiple documents that you want to look the same. To solve this problem, you can use a style (.sty) file. […]

Posted: 11th March 2014 by Tim in LaTeX
Tags: , , , , , , , , , ,

When working with large documents with tens (or hundreds) of pages, it’s useful to be able to scroll directly to the section you’re interested in by clicking the section in the table of contents. In LaTeX, this functionality can be added quickly and easily in just a few lines using the hyperref package (and the […]

## Displaying code in LaTeX documents

Posted: 27th January 2014 by Tim in C++, Java, LaTeX
Tags: , , , , , , ,

There are a few ways to do this, but one of the simplest ways to pretty-print code in LaTeX documents is to use the listings package. The package can be configured to use specific colors for different parts of the code, with many programming languages supported. The following document will display code for both C++ […]

## Math product symbol in LaTeX

Posted: 28th August 2013 by Tim in LaTeX
Tags: , , , , ,

In a similar manner to the summation symbol, the product symbol can easily be added to a LaTeX document using the \prod notation. The sybmol can be compressed to fit on one line (useful for small equations displayed within a text block), or enlarged to make it more readable. For example, to print the formula […]

## Writing kanji with furigana (hiragana) above in LaTeX

Posted: 28th December 2012 by Tim in Japanese, LaTeX
Tags: , , , , , , , , , , , ,

When using kanji in a document which is non-standard or rare, it is common for hiragana or katakana characters to be printed above (or beside for vertical text) the kanji to aid pronunciation. This is also common in children’s books and other Japanese learning material. This post explains how to do that using LaTeX. This […]

## Small caps in LaTeX

Posted: 21st January 2012 by Tim in LaTeX
Tags: , , , , ,

Writing text in smallcaps in LaTeX is quite easy – just wrap your text in the \textsc{<text>} tag. For example: \textsc{This text is in small caps} Will create This text is in small caps

## Japanese characters in LaTeX documents

Posted: 8th January 2012 by Tim in Japanese, LaTeX, Ubuntu
Tags: , , , , , , , , ,

Japanese, like many other Asian languages, is written using a variety of symbols which are not found in the standard ASCII table. Fortunately, you can include these symbols in LaTeX documents using the CJK package. In ubuntu this can be installed via the sudo apt-get install latex-cjk-japanese command. I’m not sure about Windows, Mac or […]

## Adding music notation to LaTeX with LilyPond

Posted: 27th December 2011 by Tim in LaTeX, LilyPond
Tags: , , , , , , , , , , ,

Ever wanted to add some music to a document? It’s not really a big feature for most word processors and most solutions involve creating an image using some third party software and copying that image into the document. The idea is the same in LaTeX, but it’s much easier to manage. LilyPond is a free […]

## Math case definitions in LaTeX

Posted: 12th December 2011 by Tim in LaTeX
Tags: , , , , , , , , , ,

When writing a math definition of a function, for example, the function may have different results depending on the value of the inputs. These are called cases and are grouped together with a large left curly brace. If you’re trying to typeset this in LaTeX, the cases environment makes this nice and easy. It’s easiest […]

## Adding text in math mode in LaTeX

Posted: 4th December 2011 by Tim in LaTeX
Tags: , , , , , ,

Occasionally you’ll want to add some text to a maths equation in LaTeX. By default, any text is written in italics, and white space is ignored. The solution is quite simple; put the text in a \text{…} block like so: $$x = \sqrt{x^2} \text{ : where x is positive}$$ As you can see, you can […]

## Spanning columns in LaTeX tables

Posted: 27th November 2011 by Tim in LaTeX
Tags: , , , , , , ,

Tables are a fairly important part of LaTeX. Often you will want data to span multiple columns of the table, similar to colspan in HTML. In LaTeX it’s pretty easy too, using the \multicolumn{<cols>}{<format>}{<cell_text>} command, where <cols> is the number of columns to span and <format> is the cell format (l, c or r for […]

## Using colors in LaTeX

Posted: 21st October 2011 by Tim in LaTeX
Tags: , , , , , , , , ,

If you want to add a bit of color to your LaTeX document, you can do this quite easily with the color package. This package works with both pdflatex and latex and gives you the following color options: blue cyan green magenta red yellow To use the colors, simply include the color package and wrap […]

## Using gnuplot with LaTeX

Posted: 28th July 2011 by Tim in Gnuplot, LaTeX
Tags: , , , , , , , , , , ,

Gnuplot is a great tool for creating plots. LaTeX is a great tool for creating documents. Both are (or at least can be) created using a text editor and compiling the source. Both work with Windows, linux/unix and Mac. Wouldn’t it be great if you could include a gnuplot plot in a LaTeX document without […]

## LaTeX table and figure numbering style

Posted: 18th July 2011 by Tim in LaTeX
Tags: , , , , , , , , , , ,

In LaTeX, by default, tables are numbered Table 1, Table 2, Table 3 an so on (or Table 1.1, Table 1.2, Table 2.1, etc if you’re using chapters). Sometimes you may want to change the way these are numbered. The solution is very similar to changing list numbering styles using different keywords. Like enumeration lists, […]

## Definition list in LaTeX

Posted: 14th June 2011 by Tim in LaTeX
Tags: , , , , , , , ,

If you want to include a glossary, definitions or some other descriptive list in your LaTeX document, you can make use of the description list type. This is a lot like the other list types except that \item can take an argument, the item `name’, in square brackets (ie: \item[Tim Murphy] Author of http://timmurphy.org). In […]

## LaTeX align right or left

Posted: 24th April 2011 by Tim in LaTeX
Tags: , , , , , ,

Occasionally you may want to have text right-aligned in a LaTeX document. Other times you may want a block of left-aligned text next to a block of right-aligned text. LaTeX provides this functionality with the \hfill keyword. \hfill is a horizontal fill keyword. It tells LaTeX that you want to expand the space between the […]

## Using an organisation name as an author in BibTeX

Posted: 15th February 2011 by Tim in LaTeX
Tags: , , , , , , ,

BibTeX is great in that it ensures all of the entries are output in the same style. The most noticeable formatting change is the Author field; John Smith becomes Smith, J for example. Useful, unless your author is not a normal name. Let’s say that you’ve got an article written by the Reserve Bank of […]

## Splitting up LaTeX documents

Posted: 14th November 2010 by Tim in LaTeX
Tags: , , , , , , ,

If you’re writing a large LaTeX document like a book or a thesis, you probably don’t want to have the whole thing in one massive file. It’s the same principle as general programming; splitting the program into smaller components makes it easier to work with, maintain and test. In Microsoft Word you can do this […]

## My third LaTeX document

Posted: 30th August 2010 by Tim in LaTeX
Tags: , , , , , , , , , , , , , , , , ,

This tutorial is for those who have gone through the first and second LaTeX tutorials, and should give you the knowledge required to understand more specific LaTeX tips both on this site and on other websites. This tutorial will cover Packages and the basics of math mode. Packages Much like in programming, additional functionality can […]

## Drawing pictures in LaTeX

Posted: 20th August 2010 by Tim in LaTeX
Tags: , , , , , , , , , , , , , , , , , ,

LaTeX has the ability to draw images out of the box. The drawing functionality is pretty basic — lines, circles, boxes and the like — but perfect for most simple diagrams. This tutorial will be split into three sections: configuring the environment, different ways of drawing shapes, and a description of the shapes themselves. Configuring […]

## Headers and Footers in LaTeX using fancyhdr

Posted: 7th August 2010 by Tim in LaTeX
Tags: , , , , , , , , , ,

There are a number of ways to change the document header and footer styles in LaTeX. One of the easiest and most flexible options is to use the fancyhdr package. fancyhdr is a massive package with a crazy number of tweaks and modifications available for your document’s header and footer styles. This tutorial will only […]

## Changing itemize bullet styles in LaTeX

Posted: 5th July 2010 by Tim in LaTeX
Tags: , , , , , , , , , , , ,

Latex allows the creation of itemized (unordered) lists up to four deep. The numbering styles for each depth can be styled to suit your needs using the \renewcommand{label}{style} command, where label is the list depth being styled and style is how you want that number to be shown. label may be any of the following: […]

## Changing enumerate number styles in LaTeX

Posted: 2nd July 2010 by Tim in LaTeX
Tags: , , , , , , , , ,

Latex allows the creation of enumerated (ordered) lists up to four deep. The numbering styles for each depth can be styled to suit your needs using the \renewcommand{label}{style} command, where label is the list depth being styled and style is how you want that number to be shown. label may be any of the following: […]

## Adding a two-column section to a LaTeX document

Posted: 23rd June 2010 by Tim in LaTeX
Tags: , , , , ,

There are times when you want to have multiple columns on part of a page. You could use tables to get such a layout, but that’s a bit dirty. A nice, clean method is to use the minipage environment. Minipages are defined with a width parameter. If you have multiple minipages defined immediately after each […]