Fonts for Math in LaTeX

Similar to fonts for textual content, there are formatting styles or fonts that can be used on math expressions in LaTeX. For example, the set of real numbers R is typically written with what is called a blackboard bold font.

The formatting styles for math in LaTeX are:

mathnormal: This is the default for math expressions. The letters are italicized a bit. No need to apply it explicitly.
mathrm:     Non-italicized version of normal.
mathit:     Italicized like normal, but suits words better.
mathbf:     Bold. Use for vectors and so on.
mathsf:     Sans serif.
mathtt:     Fixed-width.
mathfrak:   Fraktur. Used for lie algebras.
mathcal:    Calligraphic.
mathbb:     Used for real sets.
mathscr:    Script.

A table of these fonts applied on symbols can be seen here.

Tried with: Ubuntu 14.04


Vim-LaTeX plugin for Vim

There are many LaTeX plugins for Vim which can make editing and compiling LaTeX files easier. The most popular among these plugins is Vim-LaTeX. It can be installed from its Github page here using your favorite Vim plugin manager.

The main features I use in Vim-LaTeX is:

  • Compile currently open LaTeX file by typing \ll. Compilation errors are displayed in a buffer below and you can jump to the error line from there.

  • View compiled PDF file by typing \lv.

Tried with: Vim 7.4 and Ubuntu 14.04

How to specify size of image in LaTeX

An image is inserted into a LaTeX document using the includegraphics command. The size of the image can be specified in a variety of techniques:

  • Specify height or width or both in terms of cm:


width=3cm, height=10cm
  • Specify width as fraction of width of text column:

  • Specify scale of image:

Tried with: Ubuntu 14.04

How to insert figure sideways in LaTeX

In a LaTeX document, you might sometimes want to insert an image sideways, rotated by 90 degrees, along with its caption. For example, consider this figure:

\caption{This is a figure of Foo.}

You can use the rotating package to insert this image sideways in the page. The same figure as above inserted sideways:


\caption{This is a figure of Foo.}

Tried with: Ubuntu 14.04

How to convert LaTeX to HTML

The LaTeX2HTML tool can be used to convert any LaTeX document into HTML format. It generates HTML pages in the form of a book. All mathematical symbols and equations are converted into images.

Install the LaTeX2HTML package:

$ sudo apt install latex2html

Convert LaTeX to HTML:

$ latex2html foo.tex

Open the generated HTML file in browser:

$ xdg-open foo/index.html

Tried with: Ubuntu 14.04

How to add subfigures using subfigure package

Multiple figures are sometimes arranged together in a single figure in a paper or book written in LaTeX. This can be done using subfig and subfloat packages. I recently discovered the subfigure package which can be used to achieve the same with less code!

Below is LaTeX code to arrange three subfigures in two rows, one figure in top row and two figures in bottom row:

Tried with: Ubuntu 14.04

How to create index in LaTeX

If you are writing a report or a book using LaTeX, it might be a good idea to generate an index or glossary of key terms at the end. The typical method to do this is using the makeidx package. Place its makeindex command in the preamble at the beginning of the document to indicate that an index should be generated. Use the index command and pass it the name of the index entry whenever a key term is used. Finally, place the printindex command at the end of the document to print the generated index at that location.

Tried with: Ubuntu 14.04

Document classes for book in LaTeX

Here are some of the document classes that can be used to create a book using LaTeX:


The default class. Looks dated and ugly.



Looks modern. Better than the default book.



Looks good, but can only be used for math books. This is because all headings are centered (not left-aligned) and all text is center-justified too.



This is from the European designed KOMA package which looks modern and the fonts are nice. While their article class is nice, I did not like the book class that much.



Using this gave me compilation errors which I could not resolve. Thats a pity because this style looks almost like the books from Tufte.


Beautiful book class and my favorite.



Produces beautiful pocket books.



Another nice looking book class.