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.

LaTeX guillemets

French guillemets are possible together with English open- and close-quotes. Use babel together with \og and \fg.



\documentclass[10pt]{article}
\usepackage[french]{babel}
\begin{document}
L\`a dans \textit{Le marteau sans ma\^itre,
\og Artisanat furieux \fg} o\`u se trouve \dots
\end{document}

Five lines above give a minimal example.

Tuesday, May 6, 2008

LaTeX landscape

Rendering LaTeX in landscape means mucking with dvips and ps2pdf on most systems. These four lines work under OSX.

`which latex` foo.tex
`which dvips` -Ppdf -t landscape foo.dvi
`which ps2pdf` foo.ps
open foo.pdf

Make sure the LaTeX source starts with something like \documentclass[landscape,letterpaper]{article} and make sure the which subshells return real applications.

LaTeX line "justification"

Start with \hyphenpenalty=10000 to forbid hyphenation (almost) completely and you'll get fully-justified lines (which is good) and -- sometimes -- words that extend beyond the right margin (which is unacceptable). Add \tolerance=10000 and LaTeX will "tolerate" interword spacing and flush both left and right margins again.