Praveen Chandrashekar

Centre for Applicable Mathematics, TIFR, Bangalore

[ People | News | Codes | Talks | Teaching | Publications | Calendar | Hiking | Contact ]

Latex style guide

An excellent editor for Latex is TeXStudio. VSCode with LaTeX Workshop plugin is also good.

  1. Put some comment lines between sections, etc., for easier reading and navigation, e.g.,
    %------------------------------------------------------------------------------
    
  2. Do not use any indenting or tab in the tex files.
  3. Do not put explicit line break using \\ unless you have a really good reason to do so.
  4. A blank line creates a new paragraph. Put a blank line only if you need a new paragraph.
  5. Do not use ~, \hspace and \vspace unless it is absolutely required. Spacing must be automatically determined by Latex.
  6. Do not use bold font unless really needed to highlight an important point.
  7. Section headings must be lower case except the first letter and proper nouns
    \section{Rising thermal bubble}
    \section{Radial Raleigh-Taylor instability}
    
  8. How to put a figure
    \begin{figure}
    \begin{center}
    \includegraphics[width=0.8\textwidth]{figure}
    \caption{This is a figure}
    \label{fig:figlabel}
    \end{center}
    \end{figure}
    
    DO NOT PUT FILENAME EXTENSION.
  9. Always use \textwidth to specify figure size.
  10. NEVER specify both width and height, unless you have a really good reason to do so.
  11. Figure file formats must be either eps or pdf; NEVER use png or jpg files.
  12. Use tabular within figure to put several figures side-by-side
    \begin{figure}
    \begin{center}
    \begin{tabular}{cc}
    \includegraphics[width=0.48\textwidth]{fig1} &
    \includegraphics[width=0.48\textwidth]{fig2} \\
    (a) & (b)
    \end{tabular}
    \caption{This is a figure: (a) pressure, (b) Mach}
    \label{fig:figlabel}
    \end{center}
    \end{figure}
    
    The sum of widths must not exceed one.
  13. How to put a table
    \begin{table}
    \begin{center}
    \begin{tabular}{|c|c|c|}
    \hline
    % other stuff
    \hline
    \end{tabular}
    \caption{This is a table}
    \label{tab:tablabel}
    \end{center}
    \end{table}
    
  14. Do not use [h] or [ht] for tables and figures; they must be allowed to float.
  15. Equation, figure and table labels must be of the form \label{eq:foo}, \label{fig:foo}, \label{tab:foo}, respectively. Do not use spaces in label names.
  16. While quoting figure, table, etc., add a tilde to make the number appear on same line.
    as shown in figure~\ref{fig:foo}, the solution ...
    as shown in table~\ref{tab:foo}, the solution ...
    
  17. Do not put comma/dot/period/full stop at end of equations.
  18. Do not put comma/period inside inlined equations. This is not correct
    ... we define $a=(1,1).$ Then we can see that ...
    
    Put it like this
    ... we define $a=(1,1)$. Then we can see that ...
    
  19. A un-numbered equation can be put as
    \[
    a = b + c
    \]
    
    or
    \begin{equation*}
    a = b + c
    \end{equation*}
    
  20. An equation must be numbered ONLY if you refer to the equation number within the text.
  21. Equations must be refered as \eqref{eq:foo} or (\ref{eq:foo}).
  22. Put space between math symbols and operators. This is unreadable
    \[
    f(x)=x+\sin(x)+\exp(2x)-\log(100x)
    \]
    
    Put spaces like this
    \[
    f(x) = x + \sin(x) + \exp(2 x) - \log(100 x)
    \]
    
  23. Inline math must be completely enclosed in dollars
    ... and the EOS is $p = \rho R T$ ...
    ... where we use the value $\gamma = 1.4$ and $R = 1.0$ in the computations ...
    
  24. To put space in equation
    \[
    a = b + c, \quad x = y + z
    \]
    
    To put more space
    \[
    a = b + c, \qquad x = y + z
    \]
    
  25. To use bigger brackets do
    a = \left[ 1 + \frac{1}{2}b \right]
    
    Do not use \bigg[, etc. unless there is a good reason to do so (may be required inside eqnarray).
  26. To use bold math fonts, use the bm package and then
    \bm{v} = \frac{d \bm{x}}{dt}
    
  27. To put a conditional equation, use cases
    \[
    u(x) = \begin{cases}
    1, & \textrm{if } x < 0 \\
    0, & \textrm{otherwise}
    \end{cases}
    \]
    
  28. Different equation styles
    \[
    a = b
    \]
    
    \begin{equation}
    a = b
    \end{equation}
    
    \begin{equation}
    \begin{aligned}
    a &= b \\
    c &= d
    \end{aligned}
    \end{equation}
    
    \begin{equation}
    \begin{split}
    a &= b \\
    c &= d
    \end{split}
    \end{equation}
    
    \begin{eqnarray}
    a &=& b \\
    c &=& d
    \end{eqnarray}
    
    \begin{align}
    a &= b \\
    c &= d
    \end{align}
    
    \begin{align}
    a &= b   &   f &= g \\
    c &= d   &   h &= k
    \end{align}
    
    \begin{gather}
    a = b \\
    c = d
    \end{gather}
    
    \begin{multline}
    a = b + c + e \\
        + f + g + h
    \end{multline}
    
  29. Cite references like this
    ... has been developed in~\cite{ref1,ref2}, and further extended to ...
    
    Do not put brackets () around cite, do not use "see" in "see \cite{ref1,ref2} ...".