March 2007

\caption and \label for a LaTeX table

When using both \caption and \label for a LaTeX table, always put \caption before \label; otherwise the labels may not refere the right thing.

For example, use

\begin{table}
  \begin{tabular}{lll}
   ...
  \end{tabular}
  \caption{Table of maxima and minima}
  \label{tab:MaxMinTable}
\end{table}

and not

\begin{table}
  \begin{tabular}{lll}
   ...
  \end{tabular}
  \label{tab:MaxMinTable}
  \caption{Table of maxima and minima}
\end{table}

A simple way to remember this to note that caption comes before label alphabetically.

LaTeX

Comments (0)

Permalink

Getting umask

In unix/linux, the system call umask() sets a umask value and returns the old one. So, in order to get the current umask value without changing it, one can do

#include <sys/types.h>
#include <sys/stat.h>

mode_t get_umask()
{
   mode_t mask = umask(0);
   umask(mask);
   return mask;
}

C/C++

Comments (0)

Permalink