Monday, May 12, 2008

LaTeX caption alignment

Captions usually center justify. The caption package customizes caption alignment with the justification and singlelinecheck parameters of \captionsetup.



\documentclass[10pt]{article}
\usepackage{caption}
\captionsetup{justification=raggedright, singlelinecheck=false}
\begin{document}
\begin{table}[h]
\begin{tabular}{|ccccc|}
\hline
\textit{decimal} && \textit{binary} && \textit{musical} \\
\hline
&&&& \\
$\frac{1}{2^{-1}}$ &=& $\frac{10}{1}$ &=& \lily{c\breve*1/8} \\ [6pt]
$\frac{1}{2^{0}} $ &=& $\frac{1}{1}$ &=& \lily{c1*1/4} \\ [6pt]
$\frac{1}{2^{1}} $ &=& $\frac{1}{10}$ &=& \lily{c2*1/2} \\ [6pt]
$\frac{1}{2^{2}} $ &=& $\frac{1}{100}$ &=& \lily{c4} \\ [6pt]
$\frac{1}{2^{3}} $ &=& $\frac{1}{1000}$ &=& \lily{c8} \\ [6pt]
$\frac{1}{2^{4}} $ &=& $\frac{1}{10000}$ &=& \lily{c16} \\ [6pt]
\hline
\end{tabular}
\caption{Binary equivalences.}
\end{table}
\end{document}

Input without \captionsetup and the caption package centers the caption at page middle, bad for narrow tables.

No comments: