# 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 use LaTeX for text rendering in Matplotlib

By default, Matplotlib does not use LaTeX to render the text in its plots. For certain documents, it may be necessary to use LaTeX for text rendering.

Matplotlib can be requested to use LaTeX using:

from matplotlib import rc
rc('text', usetex=True)


Tried with: Matplotlib 1.3.1 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=5cm

height=3cm

width=3cm, height=10cm

• Specify width as fraction of width of text column:
width=0.9\linewidth

width=0.7\textwidth

• Specify scale of image:
scale=0.5


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:

\begin{figure}
\centering
\includegraphics[scale=0.8]{foo.png}
\caption{This is a figure of Foo.}
\label{fig:foo}
\end{figure}


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

\usepackage{rotating}

\begin{sidewaysfigure}
\centering
\includegraphics[scale=0.8]{foo.png}
\caption{This is a figure of Foo.}
\label{fig:foo}
\end{sidewaysfigure}


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 add bibliography to TOC in LaTeX

By default, the table of contents (TOC), bibliography and index sections of a book do not appear in the TOC. They do not appear in the TOC that is shown in the PDF reader in a sidewindow either. To make them appear in TOC add the package tocbibind to the preamble.

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:

# Book

The default class. Looks dated and ugly.

documentclass{book}


# Memoir

Looks modern. Better than the default book.

documentclass{memoir}


# AMSBook

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.

documentclass{amsbook}


# ScrBook

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.

documentclass{scrbook}


# Tufte-LaTeX

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

# Bookest

Beautiful book class and my favorite.

documentclass{bookest}


# Octavo

Produces beautiful pocket books.

documentclass{octavo}


# Caesar

Another nice looking book class.

documentclass{caesar_book}