Showing posts with label LaTeX. Show all posts
Showing posts with label LaTeX. Show all posts

Tuesday, January 13, 2009

Turning off the first page number in LaTeX

The standard command to turn off page numbering in LaTeX is

\pagestyle{empty}

which fails to work for the first page.

The standard command to turn off page numbering for the first page is

\thispagestyle{empty}

which also fails to work for the first page unless you place the command immediately after \maketitle.

Taken from here.

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.

Tuesday, April 15, 2008

Mixed French, German & English LaTeX

Unicode characters enter easily into any LaTeX document using inputenc correctly. But different languages style and space punctuation and other typographic elements differently. The LaTeX babel package and the \selectlanguage command account for typographic differences between languages.

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[german, french, english]{babel}

\begin{document}
\begin{enumerate}
\item \selectlanguage{english} Taken together ...
\item \selectlanguage{french} Cette combinaison ...
\item \selectlanguage{german}Zusammen ...
\end{enumerate}
\end{document}




So multilingual LaTeX documents require two things. The LaTeX inputenc and babel packages. And repeated calls to the \selectlanguage command inline.

Using LaTeX setstretch

LaTeX single spaces text by default.

\documentclass[10pt]{article}


\begin{document}
`Curiouser and curiouser!' cried Alice ...
\end{document}




LaTeX offers different line spacing options. The setspace package implements \setstretch.

\documentclass[10pt]{article}
\usepackage{setspace}
\setstretch{1.4}

\begin{document}
`Curiouser and curiouser!' cried Alice ...
\end{document}




The sort of scaling factor mirrors the idea of single- and double-spacing but differs from type leading.

Friday, April 11, 2008

Invoking lilypond-book

A minimal LaTeX file contains these four lines.

\documentclass[10pt]{article}
\begin{document}
hello!
\end{document}

A minimal lilypond-book file contains these seven lines.

\documentclass[10pt]{article}
\begin{document}
hello!
\begin{lilypond}
\new Staff { c'4 }
\end{lilypond}
\end{document}

The lilypond context inserts in .tex documents directly.

Process lilypond-book docs like this.

lilypond-book --pdf --output=out test.tex
cd out
pdflatex test.tex
open test.pdf

Invoking lilypond-book with the --pdf option tells lilypond-book to generate a postprocessed version of test.tex named test.tex together with a number of helper files necessary to create some final .pdf.

Note that invoking lilypond-book with the --pdf option does not tell lilypond-book to create a .pdf directly; further processing with pdflatex is still required.