The Latex Document System

Table of Contents

last revision
27 October 2011, 6:33pm
book quality
average

:

This book is about the LaTeX document and typesetting system. Latex is a system for typesetting text documents. This system is mostly used in the academic and scientific world for creating printed theses, journals and other technical documents, but it is probably capable of formatting other types of documents, such as newspapers, personal diaries and general purpose books.

Latex can be seen as the successor to the groff system. While Latex is a flexible and powerful system it is rather like a maze or an entangled forest of distributions, options, packages, fonts etc. Making a path through this forest can be difficult, time consuming and occasionally frustrating. However the end-result or reward are very professional looking documents.

www: http://www.stdout.org/~winston/latex/
a nice cheat-sheet in pdf and latex
www: http://www.ctan.org/
the official site
www: http://www.tex.ac.uk/cgi-bin/texfaq2html
the Ctan frequently asked questions lists. This is a very comprehensive document, which should contain the answers to most questions, if you have enough time to wade through it.
www: http://www.tex.ac.uk/tex-archive/help/uk-tex-faq/
the tex faq in downloadable and printable formats, such as pdf
www: http://www.kronto.org/thesis/tips/
a reasonably good set of tips
www: http://noodle.med.yale.edu/latex/latex2e-html/ltx-2.html
a good site for LaTeX2e
www: http://www.latex-community.org/forum
A forum of questions and answers about latex matters.
www: http://www.stat.ubc.ca/~webmaste/howto/editor/latex.html#wrap
a bit of a latex howto
http://heather.cs.ucdavis.edu/~matloff/LaTeX/LookHereFirst.html

Online Tutorials And Introductions ‹↑›

www: http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/
www: http://www.andy-roberts.net/misc/latex/
a thorough tutorial by a "non-expert"
www: http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/
a simple introduction
Debian packages for latex

deb: texlive-latex-base-doc deb: texlive-latex-extra-doc deb: texlive-latex-recommended-doc

Getting Help ‹↑›

view the manual for latex

 info latex

show package descriptions from the debian package "texlive-latex-extra"

 apt-cache show texlive-latex-extra | grep "\-\-" | less
this package contains a list of useful latex packages

Documentation for a latex package can be generated directly from the package "dtx" file.

generate pdf documentation for a latex "dtx" package

 pdflatex package.dtx

find documentation for latex packages in pdf format

 find /usr/share/doc/ -name '*.pdf'    on a debian system, at least

read the tex newsgroups and ask questions if you want

 comp.text.tex    the principal newsgroup

A Simple Document ‹↑›

possibly the simplest latex document

   \documentclass{article}
   \begin{document}
     Hello \LaTeX{} 
   \end{document}

Another simple latex document

   \documentclass[a4paper,12pt]{article}
   % use packages for extra functionality
   % \usepackage[...]{...}
   % start lines with '%' to write comments in the latex file
   \title{Testing} \author{Donald K} \date{\today}
   \begin{document} 
     Hello \TeX{} and \LaTeX{}
   \end{document}

Gotchas And Traps ‹↑›

The error messages for LaTeX can be very cryptic.

Don't put anything above the \documentclass directive (such as a comment with % for example), since bad things happen

Latex Document Classes ‹↑›

use the "report" class for a document

 \documentclass{report}

common latex document classes

 letter, report, book, article, ltxdoc

some latex document classes

www: ltxdoc
A classes for writing documentation about latex packages. The title, abstract and table of contents all appear on the same page
www: book
A long document with chapters @@

Latex Files Types ‹↑›

The Head Matter And Title Page ‹↑›

indicate the author of the document

 preamble: \author{ Donald Knuth }

create a multi-line author section

  \author{Martin Schr\"oder\\
     5 Northland Rd\\
     Bellevue Lane\\
     mjjb@bumble.sf.net\\ }

indicate the title of the document

 preamble: \title{ The Blue Ocean }

indicate the date that the document was written or published

 preamble: \date{August 1, 2001}
 \date{\today}        use todays date instead

use the files modification date for the document date

 \date{\filedate}

indicate versions of the document or changes which have been made

    % put the most recent change last
    \changes{v0.90}{1998/05/23}{New}
    \changes{v1.00}{1998/08/09}{Documentation improved}
    \changes{v2.00}{1999/08/23}{Redesign}

create a document summary in the preamble

 \begin{abstract} ...  \end{abstract}

Document Titles ‹↑›

make a title page

    \documentclass{article} 
    \title{testing} \author{mjb} \date{\today}
    \begin{document}
      \maketitle
    \end{document}

make a custom title which doesnt take up a whole page

    \centerline{\Large \bf The Blue Sea} \medskip
    \centerline{\bf J Appleby} \bigskip

put a foot note in the title using \thanks

 \title{ The \textsf{Bronte} \thanks{A sydney beach} waves }

including the file version and date

 version \fileversion, last revised \filedate
These commands do not seem part of standard latex, maybe the "ltxdoc" package

Making A Table Of Contents ‹↑›

One of the considerable advantages of the Latex system is that the table of contents is automatically generated from the set of section headings, along with the section and page numbers.

put a table of contents in a document

    % you need to run pdflatex at least twice for the 
    % table of contents to appear
    \documentclass{article} 
    \title{testing}
    \author{mjb}
    \begin{document}
    \tableofcontents
     ...
    \end{document}

display only 2 levels of sections in the table of contents

 \setcounter{tocdepth}{2}  displays sections & subsections

add a list of figures to the document

 \listoffigures

add a list of tables to the document

 \listoftables

change the font and appearance of the table of contents

 \usepackage[titles]{tocloft}  see the section below

make the table of contents a set of links to the sections

 \usepackage{hyperref}
 \usepackage[pdftex]{hyperref}  if compiling to "pdf" format

put a table of contents in an oval box with appropriate spacing

  \documentclass{article}
  \usepackage{fancybox}
  \begin{document}
    \begin{center}
    \setlength\fboxsep{12pt}
    \ovalbox{\begin{minipage}{0.9\textwidth}
       \vspace{0.5cm} \tableofcontents \vspace{0.5cm}
    \end{minipage} }
    \end{center}
  ...
  \end{document}

Multiple Column Tables Of Contents ‹↑›

create a 2 column table of contents with the "multitoc" package

 \usepackage[toc]{multitoc}

another way, but not recommended

    \documentclass{article} 
    \usepackage{multicol}
    \begin{document}
      \begin{multicols}{2} \tableofcontents \end{multicols}
    ...
    \end{document}

Customizing The Table Of Contents ‹↑›

www: http://www.mail-archive.com/lyx-users@lists.lyx.org/msg13159.html
a discussion about the tocloft package
www: http://www.ctan.org/tex-archive/help/Catalogue/entries/tocloft.html
the ctan catalogue entry for the 'tocloft' package
The tocloft package has many options for customizing the appearance and layout of the table of contents, which is generated by the \tableofcontents command, but the documentation for the package is a bit obscure.

some file types (by file-name extension)
aux - contain auxiliary information to compile a latex doc
dtx - a latex package file also contains the package documentation
toc - contains an automatically generated table of contents

change the font of the "section" title in the table of contents

    \usepackage{tocloft}
    \renewcommand\cftsecfont{}

put an underline under the table of contents title

    \usepackage{tocloft}
    \renewcommand{\cftaftertoctitle}{ \vspace{5pt} \hrule}

use an asterix instead of a dot for dotted lines in the table of contents

 \renewcommand{\cftdot}{\ensuremath{\ast}}

set the space between dots in dotted lines to 1 point

 \setlength{\cftdotsep}{1pt}

dont show any dots

 \setlength{\cftdotsep}{\cftnodot}}

make the table of contents title Large, italic title typeset flushright

 \renewcommand{\cfttoctitlefont}{\hfill\Large\itshape}

set the table of contents title font to large and bold

 \renewcommand{\cfttoctitlefont}{\normalfont \large \bfseries}

make the list of figures title Large, italic title typeset flushright

 \renewcommand{\cftloftitlefont}{\hfill\Large\itshape}

a centered, large, bold table of contents title

    \usepackage{tocloft}
    \renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries} together with
    \renewcommand{\cftaftertoctitle}{\hfill}

set the vertical space before section entries in the toc to 0

    usepackage{tocloft}
    \setlength{\cftbeforesecskip}{0pt}

set the vertical space before and after the table of contents title to 0

    usepackage{tocloft}
    \setlength{\cftbeforetoctitleskip}{0cm}
    \setlength{\cftaftertoctitleskip}{0cm}

set the vertical space before list of figures title to 0

  \setlength{\cftbeforeloftitleskip}{0cm}

set the vertical space before sub-sub-sections title to 0

  \setlength{\cftbeforesubsubsecskip}{0cm}

remove any indentation of "subsection" entries in the toc

 \setlength{\cftsubsecindent}{0cm}

set the width of the chapter number entries to 1cm in the table of contents

 \setlength{\cftchapnumwidth}{1cm}

make the section entry page numbers italic

 \renewcommand{\cftsecpagefont}{\itseries}

make chapters in the toc have a dotted line to the page number

 \renewcommand{\cftchapleader}{\cftdotfill{\cftchapdotsep}}

put the text "sect:" before each sub-section entry in the table of contents

 \renewcommand{\cftsubsecpresnum}{sub-sect:}

add a colon after the chapter entry number in the table of contents

 \renewcommand{\cftchapaftersnum}{:}

Paragraphs ‹↑›

set the first line paragraph indent to 0

 \setlength{\parindent}{0pt}

set the space between each paragraph to 2 lines

 \setlength{\parskip}{2ex}

set the entire paragraph indent to 1cm

 setlength{\parindent}{1cm} \hangindent=\parindent
 \parindent0em \hangindent2em \hangafter=0  the same

indent an entire paragraph more than other paragraphs

 \begin{quote} ... \end{quote}

force a new paragraph

 \par

Sections And Chapters ‹↑›

A latex document can and should be divided up into various sections, subsections, sub-subsections and so on. This is useful for organising the document and these section types are then used to generate a table of contents for the document automatically.

tocloft document part names
part \part
chap \chapter
sec \section
subsec \subsection
subsubsec for \subsubsection
para \paragraph
subpara for \subparagraph
fig figure \caption
subfig subfigure \caption
tab table \caption
subtab subtable \caption
,,,

turn off all section numbering

 \setcounter{secnumdepth}{0}    in the preamble

turn of numbering for a particular secton

 \subsection*{Strange Poetry}   the section doesnt show in the toc

create fancy chapter headings

    \documentclass{book}
    % error ???
    %\usepackage[Lenny]{fncychap}
    \begin{document}
      \chapter{Compiler Construction Tools}
    \end{document}

possible chapter heading styles in the "fncychap" package

 Sonny, Lenny, Glenn, Conny, Rejne and Bjarne.

create more compact section headings with less spacing

 \usepackage[small,compact]{titlesec}

replace "Section 5" with s5

 \def\Section {\S}  ##(use the command "\Section 5")

change the font of the "section" headings

    \usepackage{sectsty}
    \sectionfont{\LARGE\textit}

underline "section" headings

    \usepackage{sectsty}
    \sectionrule

The Titlesec Package ‹↑›

www: http://tug.ctan.org/tex-archive/macros/latex/contrib/titlesec/titlesec.pdf
documentation for the "titlesec" package, with good examples at the end in the appendix
The title section package contains many options for customizing section and subsection headings.

create "section" headings with a rule above and the number on the left next to the rule

   \usepackage{titlesec}
   ...
   \titleformat{\section}[block]
     {\normalfont\sffamily}
     {\thesection}{.5em}{\titlerule\\[.8ex]\bfseries}

an italic section title with rule above and the number next to the title

    \titleformat{\section}
    {\titlerule \vspace{.8ex}%
    \normalfont\itshape}
    {\thesection.}{.5em}{}

create a framed "section" heading with the section number in the frame


    \titleformat{\section}[frame]
    {\normalfont}
      {\filright \footnotesize \enspace SECTION \thesection\enspace}
    {8pt} {\Large\bfseries\filcenter}
    % with an 8pt gap between the title and the frame 

framed "section" headings, text on the left, section no. on the right

   \usepackage{titlesec}
   \titleformat{\section}[frame]
   {\normalfont}
     {\filleft \footnotesize \enspace Section \thesection\enspace}
   {3pt} {\bfseries\itshape\filright}

References And Labels ‹↑›

create a label which can then be referenced with "\ref"

 \label{webbook}

reference a label already created with "\label"

 \ref{webbook}

show the page number of a label

 \pageref{webbook}

Footnotes ‹↑›

create a footnote in the normal text of the document

 \footnote{The Linux Cookbook}

create footnotes marked with symbols, rather than numbers

    \renewcommand{\thefootnote}{\fnsymbol{footnote}}
    \thefootnote{Gum Trees}

Rotating Things ‹↑›

>> section types
\part - very large part of say, a book
\chapter - chapter of book; not in {article} style
\section - section of the document
\subsection - sections then broken into subsections
\subsubsection - which can be broken into pieces
\paragraph - which can contain some ``paragraphs''
\subparagraph - which have even smaller pieces

www: http://statweb.calpoly.edu/jdoi/web/reference/latex.html
side by side figures
www: www.perce.de/LaTeX/PDF/rotating.pdf
extensive information about rotating things

Rotating Text ‹↑›

display text which has been rotated vertically , \documentclass{article} \usepackage{rotating} \begin{document} Normal text \begin{sideways} vertical text \end{sideways} More text \end{document}

%% = image/eg-rotating-sideways.png %% ,,,

rotate text by 30 degrees , \documentclass{article} \usepackage{rotating} \begin{document} Normal text \begin{turn}{30} turned 30 degrees \end{turn} More text \end{document}

%% = image/eg-rotating-turn30.png %% ,,,

rotate text by minus 30 degrees (clockwise) , \documentclass{article} \usepackage{rotating} \begin{document} Normal text \begin{turn}{-30} turned -30 degrees \end{turn} More text \end{document} %% = image/eg-rotating-turn-minus30.png %% ,,,

rotate text by 30 degrees anti-clockwise without adding extra space , \documentclass{article} \usepackage{rotating} \begin{document} Normal text \begin{rotate}{30} rotated 30 degrees \end{rotate} More text \end{document} %% = image/eg-rotating-rotate30.png %% ,,,

rotate some bold-italic text by 80 degrees anti-clockwise , \documentclass{article} \usepackage{rotating} \begin{document} Normal text \begin{turn}{80} {\bfseries\itshape rotated } \end{turn} More text \end{document} %% = image/eg-rotating-rotate30.png %% ,,,

scale and reflect text , \documentclass{article} \usepackage{graphicx} \begin{document} Normal text \scalebox{2}{\reflectbox{Scaled and Reflected}} More text \end{document}

%% = image/eg-graphicx-reflectbox.png %% ,,,

rotate text creating extra space (a 'box' of whitespace)

\documentclass{article} \usepackage{graphicx} \begin{document} Normal text \rotatebox{60}{Rotated 60 degrees} More text \end{document} ,,,

multiline rotated text

\documentclass{article} \usepackage{graphicx} \begin{document} Normal text \rotatebox{40}{% because we \textbf{cannot} overwrite some other stuff.% because we \textbf{cannot} overwrite some other stuff.% } More text \end{document} ,,,

Rotating Tables ‹↑›

display a sideways table , \documentclass{article} \usepackage{rotating} \begin{document} % the sideways table always gets put on a new % page, which is not what we want at all. \begin{sidewaystable} \centering \begin{tabular}{ l|c|r| } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ 10 & 11 & 12 \\ \end{tabular} \caption{A rotated table} \end{sidewaystable} \end{document}

%% =0.2 image/eg-rotating-sidewaystable.png %% ,,,

Rotating Images ‹↑›

To rotate an image we can use the 'rotating' package or just the 'graphicx' package.

rotate an image by 45 degrees , \documentclass{article} % \usepackage[pdftex]{graphicx} \usepackage{graphicx} \begin{document} An image rotated by 45 degrees \includegraphics[angle=45]{image/tree.jpg} \end{document}

%% = image/eg-graphicx-angle45.png %% ,,,

Page Layout And Spacing ‹↑›

## the latex default is the us letter which is slightly smaller than A4

packages which rotate
rotating
lscape
graphicx
rotfloat

latex measurement units
in - inches
mm - millimeters
cm - centimeters
pt - points (about 1/72 inch)
em - approximately the width of an "M" in the current font
ex - approximately the height of an "x" in the current font

create 1/2 a centimetre of horizontal space

 \hspace{0.5cm}

create a landscape oriented a4 document

 \usepackage[a4paper,landscape]{geometry}

use more of the page than normal with "fullpage" pre: \documentstyle[12pt,fullpage]{article}

use double spacing in the document and reduce the spacing slightly

pre: \documentstyle[12pt,doublespace]{article} \setstretch{1.7} %% the normal stretch is 2 ,,,

set page margins to 3cm with no header or footer space

  \usepackage[margin=3cm,noheadfoot]{geometry}   in the preamble

set vertical and horizontal margins with the geometry package

\usepackage[pdftex]{geometry} \geometry{twoside=false,a4paper,hmargin={1cm,1cm},vmargin={1cm,1cm}} ,,,

set each of the page margins separately with no header or footer space

pre: \usepackage[left=2cm,top=1cm,right=3cm,nohead,nofoot]{geometry} ,,,

fill the page with vertical whitespace

 \vfill  the following text will be close to the bottom of the page

Line Breaks ‹↑›

force a line break to occur at the end of a line

 \\ or \linebreak   ##("\\" may produce an error if there is no line to break)

create a line break with half a centimetre of vertical space

 \\[0.5cm]

Saving Space And Paper ‹↑›

www: http://gurmeetsingh.wordpress.com/2008/09/20/latex-tips-n-tricks-for-conference-papers/
some tips on saving paper
create more compact section headings with less spacing
 \usepackage[small,compact]{titlesec}

use the times package to save space

 \usepackage{times}

create more compact tables of contents

 \usepackage{tocloft}     see the relevant section
 \usepackage{multitoc}    for a 2 colun toc, see the section

reduce the size of captions

 \usepackage[small,it]{caption}

create more compact and nicer enumerated and definition lists

   \usepackage{enumitem}

Multiple Columns ‹↑›

create a page with two columns with a 1pt width rule and 15pt separation , \documentclass{article} \usepackage{multicol} \setlength{\columnseprule}{1pt} \setlength{\columnsep}{15pt} \begin{document} \begin{multicols}{2} blah...blah \end{multicols} \end{document}

%% = image/eg-multicol-columnsep.png %% ,,,

create a 3 column section with a section heading which spans all columns , \documentclass{article} \usepackage{multicol} \setlength{\columnseprule}{1pt} \setlength{\columnsep}{15pt} \begin{document} \begin{multicols}{3}[\section{The User Interface}] blah...blah \end{multicols} \end{document} %% = image/eg-multicol-span3.png %% ,,,

immediately break a column with 'columnbreak' , \documentclass{article} \usepackage{multicol} \setlength{\columnseprule}{1pt} \begin{document} \begin{multicols}{2} This text is in the 1st Column \columnbreak % the following blank line is necessary for the % columnbreak command to work

But this text should be in the 2nd \end{multicols} \end{document} %% = image/eg-multicol-columnbreak.png %% ,,,

some text in the 1st column, and an image in the 2nd , \documentclass{article} \usepackage{multicol, graphicx} \setlength{\columnseprule}{1pt} \setlength{\columnsep}{15pt} \begin{document} \begin{multicols}{2} blah...blah \columnbreak

\includegraphics{image/tree.jpg} \end{multicols} \end{document} %% = image/eg-multicols-columnbreak-image.png %% ,,,

a code listing in the 1st column, and an image in the 2nd

    \documentclass{article} 
    \usepackage{multicol, graphicx}
    \usepackage{listings}
    \lstset{basicstyle=\ttfamily, numbers=left, frame=single} 
    \setlength{\columnseprule}{1pt}
    \setlength{\columnsep}{15pt}
    \begin{document}
      \begin{multicols}{2}
       % the 'breakline' option is necessary to stop the 
       % code spilling into the next column
       %
       \begin{lstlisting}[breaklines=true]
         for i = 1 to 20 print why is this so; end
       \end{lstlisting}

      \columnbreak

      \includegraphics{image/tree.jpg}
      \end{multicols}
    \end{document}

create a 2 column table of contents

    \documentclass{article} 
    \usepackage{multicol}
    \begin{document}
      \begin{multicols}{2} \tableofcontents \end{multicols}
     ....
    \end{document}

less common units
pc - pica (12pt/pc)
bp - big pt (72bp/in)
dd - didôt (1157dd=1238pt)
cc - cîcero (12dd/cc)
sp - scaled point (65536sp/pt)

Newspaper Style Documents ‹↑›

create a newspaper type of document

 \usepackage{paperTex}

Lists ‹↑›

## By default 4 levels of list nesting is allowed in LaTeX

create a bullet list (similar to HTML <ul>) , \documentclass{article} \begin{document} \begin{itemize} \item First item \item Second item \item Second item \end{itemize} \end{document} %% =0.2 image/eg-itemize.png %% ,,,

label a bullet list with stars instead of bullets

 \renewcommand{\labelitemi}{$\star$}

display a numbered or enumerated list , \documentclass{article} \begin{document} \begin{enumerate} \item First item \item Second item \item Third item \end{enumerate} \end{document} %% =0.2 image/eg-enumerate.png %% ,,,

use uppercase letters for level 1 and lower case letters for level 2 lists

\renewcommand{\labelenumi}{\Alph{enumi}} \renewcommand{\labelenumii}{\alph{enumii}} ,,,

Definition Or Description Lists ‹↑›

# A definition or description list consists of a set of terms # and a related description or definition.

make a "description" list (similar to html <dl>) , \documentclass{article} \begin{document} \begin{description} \item[trees] producers of oxygen \item[animal] producers of gas \item[plant] greenery \end{description} \end{document} %% =0.2 image/eg-description-list.png %% ,,,

put urls within the \item section of a definition list , \documentclass{article} \usepackage{url} \begin{document} \begin{description} \item[\url{http://www.stdout.org/~winston/latex/}] a cheat-sheet for latex \item[\url{http://www.ctan.org/}] the official site for TeX and Latex \end{description} \end{document} %% = image/eg-description-list-url.png %% ,,,

put links within the \item section of a definition list

\documentclass{article} \usepackage{hyperref} \begin{document} \begin{description} % to create clickable urls \usepackage{hyperref} \item[\url{http://www.stdout.org/~winston/latex/}] a cheat-sheet for latex \item[\url{http://www.ctan.org/}] the official site for TeX and Latex \end{description} ,,,

make more compact lists

pre: \usepackage{paralist} body: ,,,

The Enumitem Package For Lists ‹↑›

more compact lists with "enumitem" package by the author of "titlesec"

www: www.tex.ac.uk/tex-archive/macros/latex/contrib/enumitem/enumitem.pdf
documentation for the "enumitem" package
www: www.tex-tipografia.com/enumitem.html
home page of the package author
create a list with less item separation but with indentation , \documentclass{article} \usepackage{enumitem} \setlist{noitemsep} \begin{document} \begin{enumerate}[labelindent=\parindent,leftmargin=*] \item A deluded knight, \item as thin as a greyhound, \item tilting at windmills \end{enumerate} \end{document} %% =0.25 image/eg-enumitem-noitemsep.png %% ,,,

a list with the number labels boxed , \documentclass{article} \usepackage{enumitem} \begin{document} \begin{enumerate}[label=\fbox{\arabic*}] \item A deluded knight, \item as thin as a greyhound, \item tilting at windmills \end{enumerate} \end{document}

%% = image/eg-enumitem-box.png %% ,,,

a description list with descriptions on the next line indented 1 cm , \documentclass{article} \usepackage{enumitem} \begin{document} \begin{description} [font=\sffamily\bfseries, leftmargin=1cm, style=nextline] \item[Concepts] the ideas which have been developed, \item[Second Point] an in depth elaboration, \item[Final matter] the conclusion of the list. \end{description} \end{document}

%% = image/eg-enumitem-gloss.png %% ,,,

a definition list, indented by the same as the paragraph with definitions indented 2cm and placed on the next line , \documentclass{article} \usepackage{enumitem} \begin{document} \begin{description} [labelindent=\parindent, leftmargin=2cm, style=nextline] \item[Concepts] the ideas which have been developed, \item[Second Point] an in depth elaboration, \end{description} \end{document}

%% = image/eg-enumitem-indent.png %%

,,,

Creating A New List Command ‹↑›

create a new command for a compact list which takes up less space

\newcommand{\compactlist}{ \begin{list}{$\bullet$} { \setlength{\itemsep}{0pt} \setlength{\parsep}{3pt} \setlength{\topsep}{3pt} \setlength{\partopsep}{0pt} \setlength{\leftmargin}{1.5em} \setlength{\labelwidth}{1em} \setlength{\labelsep}{0.5em} } }

\newcommand{\compactlistend}{ \end{list} } ,,,

use the new compact list

    \compactlist  
    \item First item
    \item Second item
    \compactlistend    

Latex Fonts ‹↑›

www: http://www.tug.dk/FontCatalogue/
A catalogue with examples of fonts which are normally available on a Latex distribution.
www: http://www.tug.org/pracjourn/2006-1/schmidt/schmidt.pdf
A paper about font selection
www: http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/fonts.html
basic tex font information
Multicol package options
\raggedcolumns - dont align the bottoms of the columns
\columnbreak - immediately start the next column

find out where some "standard" fonts are for pdflatex

 sudo find /* -name "psnfss" | less

list some standard font packages for a "tetex" latex distribution

 ls /usr/share/texmf-tetex/tex/latex/psnfss/*.sty
##(these packages can be used with "\usepackage{name}" without the ".sty")

use a standard psnfss font package

 \usepackage{helvet}

Font Types ‹↑›

the 3 styles within a font family
font family -
font shape -
font series -

use the "bookman" font in the document

 \usepackage{bookman}
this changes only the roman font, not monospace, or sans serif

display "very" in italics and the rest of the text in normal font

 It's \textit{very} provoking
 It's \em very \rm provoking    the old latex version

display only the word "very" in fixed pitch font

 It is \texttt{very} blue

The old form of the font type names was "\tt", "\it" etc

some typically installed font families
times Times, Helvetica, Courier
pslatex This is preferred over Times because of the way it handles Courier.
newcent New Century Schoolbook, Avant Garde, Courier
palatino Palatino, Helevetica, Courier
palatcm changes the Roman to Palatino only, but uses CM mathematics
helvet

emphasise text

 this \emph{is emphasised}

display "a big forest" in bold, italic, sanserif font

 walking in  {\bfseries\itshape\sffamily a big forest}

display "tree" in bold, italic

 the green {\bfseries\itshape tree}
 the green \textbf{\textit{tree}}  the same

displays "the tree" in small capital text

 small capitals: \textsc{the tree}   small cap

[= image/eg-textsc.png]

Font Size ‹↑›

make some text large

 Some {\LARGE large text} here

latex font type names
\emph - (LaTeX2e emphasis command)
\textrm \rm - Roman.
\textit \it - Italics.
\textem \em - Emphasis (toggles between \it and \rm).
\textbf \bf - Boldface.
\textsl \sl - Slanted.
\textsf \sf - Sans serif.
\textsc \sc - Small capital letters.
\texttt \tt - fixed pitch 'typewriter' font

use relative font sizes

    \documentclass{article}
    \usepackage{relsize}
    \begin{document}
      \medskip
      \textsc{isbn 90-6464-659-7}
      \bigskip
      \smaller Author 
    \end{document}

Urls And Hyperlinks ‹↑›

www: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=setURL
The tex faq about typesetting URLs
www: http://www.kronto.org/thesis/tips/url-formatting.html
Using the "url" package in footnotes
packages: url, hyperref

format URLs in documents , \documentclass{article} \usepackage{url} \begin{document} see the website \url{http://bumble.sf.net/books/~who#this?is%20} \end{document} %% = image/eg-url.png %% ,,,

# The \url can contain LaTeX special characters "# % ^ & ~ _ $" # but '\' must be escaped and "{" "}" seem to be completely fatal.

The Hyperref Package ‹↑›

www: http://www.laqee.unal.edu.co/tex-archive/macros/latex/contrib/hyperref/doc/manual.html
manual for the "Hyperref" package in html format
www: http://en.wikibooks.org/wiki/LaTeX/Hyperlinks
about the hyperref package
www: http://www.math.uakron.edu/~dpstory/tutorial/pdfmarks/hyper.pdf
a nicely formatted pdf article about using colour and hyperlinks
www: http://www.mpch-mainz.mpg.de/~joeckel/pdflatex/
hints for using the hyperref package
put \usepackage{hyperref} LAST in the package list The hyperref package automatically turns the table of contents into links labels created with "\label" are also turned into clickable links

use coloured hyperlinks (instead of a coloured box around the link)

    \usepackage[colorlinks=true, linkcolor=green, filecolor=red,
                citecolor=red, urlcolor=green]{hyperref}

make a clickable hyperlink in a pdf document

    pre: \usepackage[pdftex]{hyperref}
    body: \href{URL} 
the option "pdftex" is for compiling with "pdfLatex"

make a clickable hyperlink which has a display text not the URL

    \documentclass{article}
    \usepackage{hyperref}
    \begin{document}
       click this \href{URL}{text}
    \end{document}

make a clickable hyperlink which displays the url in fixed pitch font

    pre: \usepackage{hyperref}
    body: \url{URL}

put a greenish border around links in the file (the default in red)

    \documentclass{article}
    \usepackage[linkbordercolor={0 1 0}]{hyperref}
    \begin{document}
      A page: \url{http://xx.org/book/doc.html#chap1}
    \end{document}
the border color is in the format {red green blue}

indicate pdf document information with the "hyperref" package

    \usepackage
    [pdftitle={Using LaTeX to Create Quality PDF Documents},
     pdfauthor={D. P. Story},
     pdfsubject={How to use hyperref, color packages},
     pdfkeywords={LaTeX hyperref pdf}]{hyperref}

it is possible to set package options with

 \hypersetup{option=value, ...}

create a pdf with an Acrobat "bookmarks" tab which is initially open

    \usepackage{hyperref}
    \hypersetup{pdftex, bookmarks=true, pdfpagemode=UseOutlines}
the "pdftex" option indicates that the "pdflatex" compiler will be used

create a pdf with a "bookmarks" tab open and the bookmarks "expanded"

    \usepackage{hyperref}
    \hypersetup{pdftex, bookmarks=true, bookmarksopen=true,
                pdfpagemode=UseOutlines}

create a pdf with a "bookmarks" tab closed and the bookmarks "unexpanded"

    \usepackage{hyperref}
    \hypersetup{pdftex, bookmarks=true, bookmarksopen=false,
                pdfpagemode=None}

latex font sizes
\tiny 5pt
\scriptsize 7pt
\footnotesize 8pt
\small 9pt
\normalsize 10pt
\large 12pt
\Large 14pt 14.40pt
\LARGE 18pt, 17.28pt
\huge 20pt 20.74pt
\Huge 24pt 24.88pt

Colours ‹↑›

www: http://www.ukern.de/tex/xcolor.html
the home page for the "xcolor" package
www: http://www.tex.ac.uk/tex-archive/macros/latex/contrib/xcolor/xcolor.pdf
documentation for xcolor
A colour model is a way of describing colours suitable to a particular output device.

## generally colour names must be defined before using them

some "hyperref" package options
ps2pdf - required for LaTeX -> dvips -Ppdf -> ps2pdf
pdftex - required for pdfLaTeX
bookmarks=true - generates bookmarks for entries in the table of contents
bookmarksnumbered=true - includes section numbers in the "Table of Contents".
hypertexnames=false - necessary to get the hyper-links to the figures right?
breaklinks=true - allows hyper-references (links) exceeding a single line
linkbordercolor={0 0 1} - but blue frames around the linksj
pdfborder={0 0 112.0} - (set width of frames in pixels)
pdfpagemode=None - the section list in the "bookmarks" tab is unexpanded
pdfpagemode=UseOutlines - the list in the "bookmarks" tab is expanded

documentation for the "color" package

 grfguide.dvi

predefined colours with the "color" package

 black, white, red, green, blue, cyan, magenta and yellow

when compiling with pdftex it may be better to use

 \usepackage[pdftex]{color}

display some text in a pinkish colour , \documentclass{article} \usepackage{color} \definecolor{pink}{rgb}{1,0.5,0.5} \begin{document} Testing text \textcolor{pink}{colours} \end{document} %% = image/eg-color-textcolor.png %% ,,,

define a lightgrey colour using the "gray" colour model

 \definecolor{light-gray}{gray}{0.95}

define an orangy colour using the "Cyan, Magenta, Yellow, Black" colour model

 \definecolor{orange}{cmyk}{0,0.5,1,0}

define a more pleasant looking green than the default

    \documentclass{article}
      \usepackage{color}
      \definecolor{webgreen}{rgb}{0,.5,0}
    \begin{document}
    ...

define a more pleasant looking brown than the default

    \documentclass{article}
      \usepackage{color}
      \definecolor{webbrown}{rgb}{.6,0,0}
    \begin{document}

display the text "point." in a yellow box with no border

    \documentclass{article}
     \usepackage{color}
    \begin{document}
     \colorbox{yellow}{point.}  % the text colour is black

Colour Boxes ‹↑›

display the text "Tree" in a green box with a blue border , \documentclass{article} \usepackage{color} \begin{document} Testing boxes: \fcolorbox{blue}{green}{Tree} \end{document} %% =0.2 image/eg-color-fcolorbox-simple.png %% ,,,

display the text "Tree" in a pale green box with a blue border , \documentclass{article} % using xcolor allow more control over the colours \usepackage{xcolor} \begin{document} An xcolor box: \fcolorbox{blue!80}{green!25}{Tree} \end{document} %% =0.2 image/eg-xcolor-fcolorbox-simple.png %% ,,,

change the width of the border of the box to 2.5 points , \documentclass{article} \usepackage{xcolor} \begin{document} \setlength{\fboxrule}{2.5pt} The Box Frame Width: \fcolorbox{blue!25}{green}{Tree} \end{document} %% = image/eg-xcolor-fboxrule.png %% ,,,

The Xcolor Package ‹↑›

www: http://www.ukern.de/tex/xcolor.html
some info about the xcolor package
color packages
color - allow color definitions and 7 built in colours
xcolor - many more colour options
chroma - uses xcolor

Basic Usage ‹↑›

set the text colour to be 40% green and 60% yellow

 \color{green!40!yellow})

display the text 'big' with a colour defined with the cmy model

    \documentclass{article}
    \usepackage{xcolor}
    \begin{document}
    \textcolor[cmy]{0.9,0.9,0.3}{big}
    \end{document}

display some text with one word coloured and the others black , \documentclass{article} \usepackage{xcolor} \begin{document} some \textcolor{blue!30!yellow}{coloured} text \end{document} %% =@ image/eg-xcolor-textcolor %% ,,,

print 'foo' in a pale greeny colour using an 'html' definition

 \textcolor[HTML]{AFFE90}{foo}  html is a type of 'rgb'

use the colour which is light-waves of 485 nano meters

 \color[wave]{485}

set the text colour to be 50% red, 20% green, 30% blue

   \color{red!50!green!20!blue}

Links And Hyperreferences ‹↑›

use the xcolor package with the hyperref package

 \usepackage[hyperref]{xcolor}

define the url color to be the complement of 50% green

 \hypersetup{urlcolor=-green!50}

Complementary Colours ‹↑›

use the colour which is complementary to 40% green, 60% yello

 \color{-green!40!yellow}

print the text 'flower' in the complement of the text colour

 \textcolor{-.}{flower}

Intensity ‹↑›

print 'tree' at 50% intensity in the current text colour

 \textcolor{.!50}{tree}

define a colour that dimishes in intensity

 \def\Test{\color{.!80}Test}
 \textcolor{blue}{\Test\Test\Test\Test\Test}

Defining Colours ‹↑›

redefine the colour 'red' using the red, green, blue model

 \definecolor{red}{rgb}{1,0,0}

define a 'red' colour using either 'rgb' or 'cmyk' model

 \definecolor{red}{rgb/cmyk}{1,0,0/0,1,1,0}

like above but translate to hsb

 \definecolor{red}{hsb:rgb/cmyk}{1,0,0/0,1,1,0},

define 3 colours in one go

 \definecolorset{rgb}{}{}{red,1,0,0;green,0,1,0;blue,0,0,1}

define a colour which has 2 thirds the intensity of another

 \definecolor{new}  \color{new!75}

Mixing Colours ‹↑›

mix 4 parts of red with 2 of green and 1 of yellow

 \color{rgb:red,4;green,2;yellow,1}.

display text in yellow in the red, green, blue colour model

 \color{rgb:yellow,1}

Calculating Colours ‹↑›

save the current text colour with the name 'cur'

 \colorlet{cur}{.}

define and use a 'colorseries' (a set of colours)


  \definecolorseries{foo}{rgb}{last}{red}{blue}
  \resetcolorseries[10]{foo}
  \color{foo!!+}   % access the next colour in the series

Colour Models ‹↑›

set all colour values to use the 'cmyk' colour model

 \usepackage[cmyk]{xcolor}
 \selectcolormodel{cmyk}     the same

mix 50 percent yellow with the current text colour and print 'big'

 \textcolor{yellow!50!.}{big}

print a row of test colours with values

    \begin{testcolors}[rgb,cmyk,hsb,HTML,gray]
    \testcolor{olive}
    \testcolor{red!50!green}    % this is the same color
    \end{testcolors}

Test Colours ‹↑›

display a table of test colours and values


  \sffamily
  \begin{testcolors}[rgb,cmyk,hsb,HTML,gray]
  \testcolor{olive}
  \testcolor{red!50!green}
  \testcolor{-cyan!50!magenta}
  \testcolor[cmyk]{0,0,1,0.5}
  \testcolor[cmyk]{0,0,.5,.5}
  \testcolor[rgb:cmyk]{0,0,.5,.5}
  \end{testcolors}

Mathematical Equations ‹↑›

typeset a mathematical equation with a label

    \documentclass{article}
    \begin{document}
      \begin{equation}
        $x^2+y^2=1$ 
      \label{eq:xxyyeq1}
      \end{equation}
    \end{document}

Verbatim Text ‹↑›

display verbatim text

 \verb/_{}$^/     will print "_{}$^"
 \verb|_{}$^|     this is the same, any character can be used to delimit
 \verb*_{}$^*     the same again, but this gives me an error ?

watch out, you can't put a \verb command in a macro command

 \section{\verb=~=}   this produces an Error!
 \item[\verb=~=]      so does this

display multiline verbatim text

\begin{verbatim} this text is $ verbatim \end{verbatim} ,,,

display quoted verbatim text

\begin{quote} \begin{verbatim} ... \end{verbatim} \end{quote} ,,,

Latex Special Characters ‹↑›

display text within curly quotes

 ``Text between curly quotes''

escaping special character with \verb|...| causes problems within other commands

these are the main special characters

   #^{}$~\_%&

colour models
Pantone - a proprietary model
hks - another proprietary model
rgb - red green blue
html - a version of 'rgb' 6 letters long
hsb - hue saturation brightness
thsb - tuned hsb
cmyk - cyan magenta yellow ?
cmy - cyan magenta yellow
gray - greyscale
wave - visible wavelength of light 400–750 nm
,,,

if there is an unescaped "#" somewhere in the document you may get the message

 Illegal parameter number in definition of \Hy@tempa
this is nice and cryptic

Latex Special Symbols ‹↑›

www: http://newton.ex.ac.uk/research/qsystems/people/sque/symbols/
a list of maths symbols and their html entity equivalent
www: http://www.eng.cam.ac.uk/help/tpl/textprocessing/latex_advanced/node14.html
a list of symbols which can be used
www: http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf
a comprehensive list of symbols
www: http://stackoverflow.com/questions/256457/how-does-one-insert-a-backslash-or-a-tilde-into-latex
some good advice
To display math mode symbols use
 $...$ or \begin{math} ... \end{math}

display a greek beta character in the text

 $\beta$   the "$" signs put latex into math mode

disply an English "pound" sign

 \pounds the "$" signs are not needed because its not a math mode command

to follow a symbol command with a space use an extra "\"

 \LaTeX\

latex special characters
\ The command character, $\backslash$ \textbackslash
$ Math typesetting delimiter, \$
% The comment character, \%
^ Math superscript character, \^
^ Actual carrot, \^{}, \verb*^*
& Tabular column separator, \&
_ Math superscript character, \_
~ Non-breaking space; to put the tilde over a letter, \verb*~*jdoe
~ Actual tilde character, \~{}, $\sim$ \textasciitilde
# Macro parameter symbol, \#
{ Argument start delimiter, $\{$
} Argument end delimiter, $\}$

non-math mode symbol commands
\dtag - a dagger
\TeX\ - the "TeX" logo with an extraspace
\LaTeX\ - the "TeX" logo with an extraspace
\ddag - a double dagger
\S - a section symbol
\pounds - an English pound sterling sign
\copyright - a copyright symbol
\"{o} - an "o" with an umlaut above it

White Space ‹↑›

Unicode And Foreign Languages ‹↑›

deb: latex-cjk xelatex

Japanese ‹↑›

I never really got the 'cjk' packages working, but I believe that the 'xelatex' compiler (as opposed to the 'pdflatex' tool) should solve many unicode text problems.

www: http://blogs.fsfe.org/ciaran/?p=150
this is the answer.
www: http://www-alg.ist.hokudai.ac.jp/~jan/japfonts.html
some advice about cjk with an example document
www: http://tug.org/TUGboat/Articles/tb18-3/cjkintro600.pdf
an article about using the cjk package
www: http://www.math.nus.edu.sg/aslaksen/cs/cjk.html
an example document with Japanese. Encoded in euc-jp character set

\documentclass[12pt]{scrartcl} \usepackage{CJK} \begin{document} \begin{CJK*}[dnp]{JIS}{min} \section{What I learned today} I can write this 私はキランです in Japanese. \end{CJK*} \end{document} ,,,

documents need to be encoded as euc-jp

 recode utf8..eucjp test.tex
 iconv  an older tool

change the character encoding without affecting the original file

 recode utf8..eucjp < test.tex > test.euc.tex

recode from the local character set to eucjp

 recode ..eucjp test.tex

generate the pdf file with kanji

 pdflatex test.tex

Images ‹↑›

When you compile a latex document with "pdflatex" the images must be one of the formats jpeg, png or pdf. If the image file does not exist pdflatex goes into an annoying loop asking for a new image filename and refusing to exit (use '-interaction batchmode' to stop this)

the image file name extension may not be necessary

 \includegraphics{eg}       ##(includes 'eg.png' etc}
 \includegraphics{eg.png}   the same, but less ambiguous

If '\usepackage{graphicx}' is not included in the preamble, youll get

 !Undefined control sequence.
 l.9 \includegraphics       or something similar

convert an image 'eg.gif' to a "png" image with imagemagick convert

 convert eg.gif eg.png  'eg.png' can now be used with pdflatex

When compiling with 'latex' (as opposed to 'pdflatex') images must be in the 'eps' format (encapsulated postscript)

include an image 'tree.jpg' and at 1/2 of its original size,, , \documentclass{article} \usepackage{graphicx} \begin{document} % the images display side by side \includegraphics[scale=0.5]{image/tree.jpg} \includegraphics{image/tree.jpg} \end{document} %% =0.4 image/eg-graphicx-scale.png %% ,,,

include an image taking up 2 thirds of the current page width

\documentclass{article} \usepackage{graphicx} ... \begin{document} \includegraphics[width=0.75\textwidth]{image/test.jpg} \end{document} ,,,

display an image 1/2 its normal size and upside down

 \includegraphics[scale=0.5, angle=180]{chick}

create a box around the image 'eg.jpg'

\setlength\fboxsep{0pt} \setlength\fboxrule{0.5pt} \fbox{\includegraphics{eg}} ,,,

tell latex to look for images in the folder "/var/lib/images"

 \graphicspath{{/var/lib/images/}}

float an image to the right, taking up half the page, with a caption at the bottom,,

\documentclass[a4paper,12pt]{article} \usepackage{wrapfig, graphicx} \begin{document} \begin{wrapfigure}{r}{0.5\textwidth} \centering \includegraphics[width=0.45\textwidth]{image/tree.jpg} \caption{The image caption} \end{wrapfigure} This is some example text which will wrap around the image ... This is some example text which will wrap around the image ... This is some example text which will wrap around the image ... This is some example text which will wrap around the image ... \end{document} ,,,

Notes:

The 'wrapfigure' textwidth is slightly greater than the 'includegraphics' textwidth to ensure some space between the image and the surrounding text.

the \centering or \begin{center} ... \end{center} are needed to center the image above the caption.

include 2 images side by side using "minipages"

\begin{figure}[htb] \centering \begin{minipage}[c]{0.38\textwidth} \centering \includegraphics[width=\textwidth]{img/tree} \end{minipage} \begin{minipage}[c]{0.58\textwidth} \includegraphics[width=\textwidth]{img/leaf} \end{minipage} \end{figure} ,,,

put a caption at the side of an image 'tree.jpg'

\documentclass{article} \usepackage[pdftex]{graphicx} \usepackage{sidecap} \begin{document} \begin{SCfigure} \centering \includegraphics[width=0.55\textwidth]{image/tree.jpg} \caption{ A tree } \end{SCfigure} \end{document} ,,,

Boxes ‹↑›

www: http://latex.computersci.org/Reference/TextBoxes
some thoughts on non-fancy boxes
www: ftp://ctan.tug.org/tex-archive/macros/latex/contrib/fancybox/fancybox.pdf
documentation for the fancybox package
math mode symbol commands
\dots - three dots in a row an "elipsis"
\Rightarrow - a doubled right pointing arrow symbol
\rightarrow - a single right pointing arrow symbol
\clubsuit - a clubs symbol
\approx - approximately equal to (a wavy equal sign)
and many more

make an unframed box as wide as the page with text centered

 \makebox[\textwidth]{c e n t r a l}

an unframed box with text spread over the whole page width

 \makebox[\textwidth][s]{s p r e a d}

a framed box a little large than the text width

 \framebox[1.1\width]{Guess I’m framed now!}

create a centered table with a framed box around it


   \documentclass{article}
   \begin{document}

    \begin{table}[h]
    \begin{center}
    \fbox{%
    \begin{minipage}{.8\textwidth}
    \begin{center}
    \begin{tabular}{rl}
    foo & bar
    \end{tabular}
    \end{center}
    \caption{A table of foo and bar.}
    \end{minipage}}
    \end{center}
    \end{table}
   \end{document}

the table must go within a minipage within the "fbox"

Dashed Boxes ‹↑›

draw boxes with dashes , \documentclass{article} \usepackage{dashbox} \begin{document} % \dashbox{dash_length}(width,height){...} Before \dashbox{Text in a Dashed box} and after \end{document}

%% = image/eg-dashbox.png %% ,,,

The Fancybox Package ‹↑›

different box commands
\fbox{this} - a box with a frame adjusted to the width of the text
\mbox{some text} - a box withh no frame adjusted to the text width
\makebox[3cm][l]{text} - like a frame box but without the frame
\framebox[3cm][l]{like so} - a box with a frame 3cm wide, left aligned
\parbox[pos]{width}{...} - a box with lots of text (several lines)

create a box with a shadow , \documentclass{article} \usepackage{fancybox} \begin{document} \shadowbox{\large\bf The Big Tree} \end{document} %% =0.3 image/eg-fancybox-shadow.png %% ,,,

create a box with a doubled border , \documentclass{article} \usepackage{fancybox} \begin{document} \doublebox{\large\bf The Big Tree} \end{document} %% =0.3 image/eg-fancybox-double.png %% ,,,

create a box with rounded corners , \documentclass{article} \usepackage{fancybox} \begin{document} \ovalbox{\large\bf The Big Tree} \end{document} %% =0.3 image/eg-fancybox-oval.png %% ,,,

Rounded Corners ‹↑›

The 'listings' package can also make frames with rounded corners

create a round-corner box with 8 point distance between frame and content , \documentclass{article} \usepackage{fancybox} \begin{document} \ovalbox{\large\bf No Spacing} \setlength\fboxsep{8pt} \ovalbox{\large\bf 8pt Box Spacing} \end{document} %% =0.4 image/eg-fancybox-fboxsep.png %% ,,,

create a box with rounded corners with a thicker line

\documentclass{article} \usepackage{fancybox} \begin{document} \ovalbox{\large\bf Normal Lines} \Ovalbox{\large\bf Thick Lines} \end{document}

%% = image/eg-fancybox-thicklines.png %% ,,,

set the rounded corner radius for the box

\documentclass{article} \usepackage{fancybox} \setlength{\parindent}{0pt} \begin{document} \cornersize{0.1} \Ovalbox{\large\bf Rounded 0.1} \\ \cornersize{0.5} \Ovalbox{\large\bf Rounded 0.5} \\ \cornersize{1} \Ovalbox{\large\bf Rounded 1} \end{document} %% = image/eg-fancybox-rounded.png %% ,,,

the cornersize values are limited, the following values are possible

 0, 0.1, 0.5, 1

To make section heading have a rounded frame use the 'titlesec' package.

display 2 oval boxes side by side

 \ovalbox{on the left} \ovalbox{on the right}

display 2 oval boxes underneath one another

 \ovalbox{above} \\ \ovalbox{below}

put an oval box around a two column table of contents

\documentclass[a4paper,12pt]{article} \usepackage{multicol} \usepackage{fancybox} \begin{document}

\ovalbox{\begin{minipage}{\linewidth} \begin{multicols}{2} \tableofcontents \end{multicols} \end{minipage} }

\end{document} ,,,

display a shadow box

 \shabox defined in the shadow package

Coloured Boxes ‹↑›

show a box with pale blue frame, pale green background

\fboxrule6pt \fcolorbox {blue!20}{green!30} {Test \textcolor{red!75}{Test}} ,,,

display nested coloured boxes

\fboxrule6pt \fcolorbox {red!70!green}% outer frame {yellow!30!blue}% outer background TestTestTest {\fcolorbox {-yellow!30!blue}% inner frame {-red!70!green}% inner background {Test\textcolor{red!72.75}{Test}\color{-green}Test}} ,,,

Page Headings And Footers ‹↑›

www: http://texblog.wordpress.com/2007/11/07/headerfooter-in-latex-with-fancyhdr/
some info about fancy headers.
dont show any page headers or footers
 \pagestyle{empty}

show just the page number at the foot of the document, no header

 \pagestyle{plain}

show page number and section information etc

 \pagestyle{headings}

similar to "headings" but customizable

 \pagestyle{myheadings}

suppress all page header and footers for the current page only

 \thispagestyle{empty}

print the page and section name at the top of the page , \documentclass{article} \usepackage{fancyhdr} \pagestyle{fancy} \fancyfoot{} \begin{document} \section{Part One} Test fancy headings blah...blah \end{document}

%% =0.4 image/eg-fancyhdr-simple.png %% ,,,

fancybox parameters
\fboxsep - the distance between the box and the frame
\shadowsize - the width of the shadow of a shadow box
\fboxrule - the width of the box frame line for shadowbox and doublebox

fancy header format specifiers
E - Even page
O - Odd page
L - Left field
C - Center field
R - Right field
H - Header
F - Footer

special fancy header commands
\thepage - number of the current page
\leftmark - current chapter name eg "CHAPTER 3. SMALL CARS"
\rightmark - current section name "1.6. BIODIESEL"
\thesection - current section number

print the text '--draft--' in the center of the top of each page , \documentclass{article} \usepackage{fancyhdr} \pagestyle{fancy} \fancyhead[CO,CE]{---Draft---} \fancyfoot{} \begin{document} \section{Part One} Test fancy headings blah...blah \end{document}

%% =0.4 image/eg-fancyhdr-topcenter.png %% ,,,

change the header with rhead, lhead etc, use todays date , \documentclass{article} \usepackage{fancyhdr} \pagestyle{fancy} \fancyfoot{} % no footer \fancyhead{} \rhead{\bfseries The Report (page \thepage)} \chead{\today} \lhead{To: Dean A. Smith} \renewcommand{\headrulewidth}{0.4pt} % use '\footrulewidth' for the foot rule \begin{document} \section{Part One} Testing fancy headings blah...blah \end{document}

%% = image/eg-fancyhdr-lhead.png %% ,,,

page number at left and right of header, text 'draft', thick rule , \documentclass{article} \usepackage{fancyhdr} \pagestyle{fancy} \fancyfoot{} % clear the default styles \fancyhead{} % this syntax is for 2 side documents \fancyhead[CO,CE]{Draft} \fancyhead[RO,LE] {\thepage} \fancyhead[LO,RE] {\thepage} \renewcommand{\headrulewidth}{3pt} \begin{document} \section{Part One} Test fancy headings blah...blah \end{document} %% = image/eg-fancyhdr-thickrule.png %% ,,,

Figures ‹↑›

Figure Captions ‹↑›

change a figures caption to no label, bold italic font

 \usepackage[labelformat=empty,labelsep=none,textfont={it,bf}]{caption}

make the figure captions italic , \documentclass[a4paper,12pt]{article} \usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption} \usepackage{graphicx} \begin{document} \begin{figure}[htb] \begin{center} \includegraphics[width=0.3\textwidth]{image/tree.jpg} \caption{Testing captions} \end{center} \end{figure} \end{document} %% = image/eg-caption-italic.png %% ,,,

change the automatically generated caption name in figures to "Fig."

 \renewcommand{\figurename}{Fig.}

reduce the amount of white space between an image and its caption , \documentclass[a4paper,12pt]{article} \usepackage{graphicx} \begin{document} \begin{figure}[htb] \begin{center} \includegraphics[width=0.3\textwidth]{image/tree.jpg} \end{center} \caption{a big gap} \end{figure} \begin{figure}[htb] \begin{center} \includegraphics[width=0.3\textwidth]{image/tree.jpg} \end{center} \vspace{-20pt} % the negative value reduces vertical space \caption{a smaller gap} \end{figure} \end{document}

%% =0.2 image/eg-caption-gap.png %% ,,,

Converting Other Formats To Latex ‹↑›

Converting Source Code To Latex ‹↑›

Tools: highlight, http://www.andre-simon.de/ source-highlight,

convert a java file to latex.

  highlight -L -i Test.java -o Test.java.tex

Tables ‹↑›

www: http://www.tug.org/pracjourn/2007-1/mori/mori.pdf
a tutorial about how to make professional tables
www: http://en.wikibooks.org/wiki/LaTeX/Tables
a reasonable wikibook about this topic.
some example fancy header commands
\renewcommand{\headrulewidth}{0.4pt} - set the head rule = 0.4
\renewcommand{\footrulewidth}{1.4pt} - set the foot rule = 0.4

Gotchas ‹↑›

If the number of columns in the body is greater than the number of columns in the header then the document will not compile with pdflatex.

too many columns in a table causes a compile error but too few columns doesnt seem to matter

dont put anything between the last row and \end{tabular}

 \\ \bottomrule \end{tabularx}   wont work

Simple Tables ‹↑›

to get alternate coloured rows in a table see the "xcolor" package

a boxed 2 column table with 1st column left aligned, 2nd center

\documentclass{article} \begin{document} \begin{tabular}{ |l|c| } \hline 6 & spain \\ 4 & euskera \\ 7 & catala \\ \hline \end{tabular} \end{document} ,,,

a simple table with vertical lines , \documentclass{article} \begin{document} % columns aligned: left, center, right \begin{tabular}{ |l|c||r| } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{tabular} \end{document} %% =0.2 image/eg-table-simple.png %% ,,,

If you want a table column to contain a lot of text then the 'p{..}' specifier is necessary in order to make the text wrap to that width.

a table with a 5cm wide paragraph column with bold left column labels

    \documentclass{article}
    \begin{document}
    \begin{center}
      \begin{tabular}{ l|p{5cm}| }
        \textbf{\textit{ pandoc }} & 
        Pandoc is a system using the 'markdown' syntax which
        can transform documents into various output formats 
        \\
        \textbf{\textit{ halibut }} & 
        Halibut is another 'plain-text' documentation system.
        \\
      \end{tabular}
    \end{center}
    \end{document}

a table 1/2 the page width, small capitals 1st col, small text in 2nd

    \documentclass{article}
    \usepackage{tabularx}
    \begin{document}
    % the text in the 'X' column will wrap and be small 
    % the '>{\small}' syntax comes from the 'array' package
    \begin{tabularx}{0.5\textwidth}{ >{\scshape}l | >{\small}X }
      Sastra  & An indonesian word of hindu origin
                which means culture or literature. \\
      Greja   & A word of portuguese origin meaning 
                church. \\
    \end{tabularx}
    \end{document}

a table 1/2 page width, in a 'glossary' style

    \documentclass{article}
    \usepackage{tabularx}
    \begin{document}
    % the text in the 'X' column will wrap and be small 
    \begin{tabularx}{0.5\textwidth}{ >{\scshape}r | >{\itshape}X }
      Unix  & An operating system created in the seventies
              in Bell Labs and North American Universities.  \\
      Linux & A popular free clone of the unix operating system
              created by volunteers \\
    \end{tabularx}
    \end{document}

a glossary style table, 2nd column 6/10ths of the page width

    \documentclass{article}
    \usepackage{array}
    \begin{document}
    \begin{tabular}{ >{\scshape}r | >{\itshape}p{0.6\linewidth} }
      Unix  & An operating system created in the seventies
              in Bell Labs and North American Universities.  \\
      Linux & A popular free clone of the unix operating system
              created by volunteers \\
    \end{tabular}
    \end{document}

a table with a column taking up 1/3 of the page width

    \documentclass{article}
    \begin{document}
    \begin{center}
      \begin{tabular}{ l|p{0.33\textwidth}| }
        \textsc{ pandoc } & 
        Pandoc is a system using the 'markdown' syntax which
        can transform documents into various output formats \\
        \textsc{ halibut } & 
        Halibut is another 'plain-text' documentation system.  \\
      \end{tabular}
    \end{center}
    \end{document}

a simple table with horizontal and vertical lines , \documentclass{article} \begin{document} \begin{tabular}{ l|c|r| } \hline 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \hline \end{tabular} \end{document} %% = 0.2 image/eg-table-lines.png %% ,,,

Table Frames ‹↑›

put an box with rounded corners around a table

\documentclass{article} \usepackage{fancybox} \begin{document} \ovalbox{\begin{minipage}{\linewidth} \begin{tabular}{ l|c } 6 & spain \\ 4 & euskera \\ 7 & catala \\ \end{tabular} \end{minipage} } \end{document} ,,,

put an rounded-corners box around an alternating row colour table

    \documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{fancybox, tabularx}
    \begin{document}
      \rowcolors[]{1}{brown!20}{}
      \ovalbox{\begin{minipage}{0.75\textwidth}
      %% 1st column bold, 2nd column italic
      \begin{tabularx}{\textwidth}{>{\bfseries}l >{\itshape}X }
      Perl & A scripting language popular in the late 90s \\
      Java & A clumsy inefficient virtual machine language \\
      Python & An increasingly trendy language \\
      Sed & A turing complete text editing language \\
      \end{tabularx}
    \end{minipage} }
    \end{document}

alternate row colours and a rounded frame without 'tabularx'

    \documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{fancybox, array}
    \begin{document}
      \rowcolors[]{1}{brown!20}{}
      \ovalbox{\begin{minipage}{0.75\textwidth}
      \begin{tabular}{>{\bfseries}l >{\itshape}l }
      Perl & A scripting language popular in the late 90s \\
      Java & A clumsy inefficient virtual machine language \\
      Python & An increasingly trendy language \\
      Sed & A turing complete text editing language \\
      \end{tabular}
    \end{minipage} }
    \end{document}

put an rounded-corners box around a table, the box wider than the table

    \documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{fancybox, tabularx}
    \begin{document}
      \rowcolors[]{1}{brown!20}{}
      \ovalbox{\begin{minipage}{\textwidth}
      \begin{tabularx}{.75\textwidth}{>{\bfseries}l >{\itshape}X }
      Perl & A scripting language popular in the late 90s \\
      Java & A clumsy inefficient virtual machine language \\
      Python & An increasingly trendy language \\
      Sed & A turing complete text editing language \\
      \end{tabularx}
    \end{minipage} }
    \end{document}

a double nested box around a table , \documentclass{article} \usepackage[table]{xcolor} \usepackage{fancybox, array} \begin{document} \rowcolors[]{1}{brown!20}{} \ovalbox{\begin{minipage}{0.75\textwidth} \ovalbox{\begin{minipage}{0.97\textwidth} \begin{tabular}{>{\bfseries}r >{\itshape}l } look & look up words \\ cut & cut up fields \\ rs & change arrays \\ jot & make data \\ \end{tabular} \end{minipage} } \end{minipage} } \end{document} ,,,

Partial Lines And Multiple Columns ‹↑›

make a partial horizontal line beginning in column 2 and ending col 3

 \cline{2-3}

a table with a partial horizontal line under "octal" , \documentclass{article} \begin{document} \begin{tabular}{|r|l|} \hline 7C0 & hexadecimal \\ 3700 & octal \\ \cline{2-2} 11111000000 & binary \\ \hline \hline 1984 & decimal \\ \hline \end{tabular} \end{document}

%% = 0.35 image/eg-table-partial-line.png %% ,,,

The Header Row ‹↑›

Most tables contain a row (usually at the top of the table) which explains the meaning of the column content.

a boxed 2 column table with bold 'header' row

\documentclass{article} \begin{document} \begin{tabular}{ r l } \textbf{Language} & \textbf{Country} \\ \hline espanol & Spain \\ euskera & Basque \\ warlpiri & Australia \\ pintupi & Australia \\ \hline \end{tabular} \end{document} ,,,

create a center-aligned heading which spans 2 columns

   \documentclass{article}
   \begin{document}
   \begin{tabular}{|r|l|}
    \hline
    \multicolumn{2}{|c|}{Some Tools} \\
    \hline
    feh     & A small image display utility \\
    gnuplot & A program to create graphs and charts \\
    \hline
   \end{tabular}
   \end{document}

create a center-aligned large italic heading spanning 2 columns

   \documentclass{article}
   \begin{document}
   \begin{tabular}{r|l}
    \multicolumn{2}{c}{
      \Large\itshape Some Tools} \\ \\
    \textbf{tool} & \textbf{usage} \\
    \hline
    feh     & A small image display utility \\
    gnuplot & A program to create graphs and charts \\
    \hline
   \end{tabular}
   \end{document}

In the recipe above we use the '\\ \\' to create an empty row which gives more space below the heading. This is all probably better done using a caption to a figure.

rotate the headings in a table

    \documentclass{article}
    \usepackage{rotating}
    \begin{document}
    \begin{tabular}{ll}
        \begin{turn}{80} \textit{Name} \end{turn} & 
        \begin{turn}{80} \textit{Surname} \end{turn} 
      \\
      \hline 
       cell 1 & cell 2 \\
       cell 3 & cell 4 \\
      \hline
    \end{tabular}
    \end{document}

another style of rotated headings in a table

    \documentclass{article}
    \usepackage{rotating}
    \begin{document}
    \begin{tabular}{l|ll}
        \begin{turn}{0}  \textbf{Folder Name} \end{turn} & 
        \begin{turn}{80} \textit{Total Size} \end{turn} &
        \begin{turn}{80} \textit{Last Modified} \end{turn} 
      \\
      \hline 
       /dev & 200M & 4 april \\
       /usr & 20G & 5 april \\
       /bin & 10G & 1 april \\
      \hline
    \end{tabular}
    \end{document}

Column Separator ‹↑›

a table with a dot "." as the column separator

    \documentclass{article}
    \begin{document}
    \begin{tabular}{r@{.}l}
      3 & 14159 \\
      16 & 2 \\
      123 & 456 \\
    \end{tabular}
    \end{document}

use @{} to suppress the space before or after the text in a column.

    \begin{tabular}{|@{}l|l|}
      \hline
       stuff & stuff \\ \hline stuff & stuff \\
      \hline
    \end{tabular}

Bash And Latex Tables ‹↑›

It is possible to use bash and awk to generate latex tables for printing.

a bash function to convert a du listing to pdf

  function test {
    cat << xxx | pdflatex 
      \documentclass{article}
      \usepackage{rotating}
      \begin{document}
      \begin{tabular}{ll}
          \begin{turn}{80} \textit{Total Size} \end{turn} &
          \begin{turn}{80} \textit{File Name} \end{turn} 
      \\\\ \hline 
       $(du -sh * | tr -d '_$' | awk '{print $1" & "$2" \\\\"}')
      \hline
      \end{tabular}
      \end{document}
xxx
     }
     test; evince texput.pdf

In the above function latex special characters such as '$' and '_' must be translated or escaped somehow. Also if the listing is longer than a page then it needs to use the 'longtable' package.

Awk And Tables ‹↑›

It seems that from the bash shell we could write some interesting awk scripts to turn text data into latex tables. using xcolor for alternate row colours, tabularx for column widths, array for column formatting, etc

maybe something like this, but with good syntax

    BEGIN { print '\documentclass' etc etc }
    {for i to $NR { print '&' } print \\ }
    END { print '\end{document}' }

Code Listings In Tables ‹↑›

put a verbatim in a table cell

    \documentclass{article}
    \begin{document}
      \begin{tabular}{ |p{5cm}|c|}
      \hline
      \begin{verbatim}
        for code to protocol 
      \end{verbatim}
      & description
      \\ \hline
      \end{tabular}
    \end{document}

put a code listing in a table cell

    \documentclass{article}
    \usepackage{listings}
    \lstset{basicstyle=\ttfamily, breaklines=true, numbers=left} 
    \begin{document}
      \begin{tabular}{ |p{9cm}|p{3cm}|}
      \hline
      \begin{lstlisting}
        for i = 1 to 20
        do 
          print why is this so;
        end
      \end{lstlisting}
      & a code sample 
      \\ \hline
      \end{tabular}
    \end{document}

Text Alignment ‹↑›

center text vertically within a table cell

    \documentclass{article}
    \usepackage{array}
    \begin{document}
    \begin{tabular}{|m{1in}|m{1in}|}
      \hline cell 1 & cell 2 \\
      \hline cell 3 & cell 4 \\
      \hline
    \end{tabular}
    \end{document}

make text in one column italic with the 'arrays' package

    \documentclass{article}
    \usepackage{array}
    \begin{document}
    \begin{tabular}{|l|>{\itshape}l|}
      \hline one & cell 2 \\
      \hline cell 3 & cell 4 \\
      \hline cell 5 & cell 6 \\
      \hline
    \end{tabular}
    \end{document}

Table Columns ‹↑›

make the first column of a table automatically bold

    \documentclass{article}
    \usepackage{array}
    \begin{document}
    \begin{tabular}{ >{\bfseries}l | p{6cm}}
      zenity  & A tool to create dialog windows \\
      kdialog & The equivalent tool for the kde desktop \\ 
    \end {tabular}
    \end{document}

By default, the text in latex tables does not 'wrap'. To make it wrap you must you the 'p' specifier or the 'array' package.

place 2 hyphens before and after every row in the 1st column

    \documentclass{article}
    \usepackage{array}
    \begin{document}
    %% \begin{turn}{80} \textit{Total Size} \end{turn}
    \begin{tabular}{ >{--} l <{--} | p{6cm}}
      zenity  & A tool to create dialog windows \\
      kdialog & The equivalent tool for the kde desktop \\ 
    \end {tabular}
    \end{document}

attempting to rotate every element of a column

  {>{$}c<{$}}. but this is not working
    \documentclass{article}
    \usepackage{array}
    \begin{document}
    %% \begin{turn}{80} \textit{Total Size} \end{turn}
    \begin{tabular}{ >{\begin{turn}{80}} p{6cm} <{\end{turn}} | p{6cm}}
      zenity  & A tool to create dialog windows \\
      kdialog & The equivalent tool for the kde desktop \\ 
    \end {tabular}
    \end{document}

a table with a paragraph column with a width of 5cm

    \documentclass{article}
    \begin{document}
    \begin{center}
      \begin{tabular}{ l|p{5cm}|}
        Monday & 
        A clear day with lots of sunshine.  
        However, the strong breeze will bring down the temperatures. \\
        Tuesday & 
        Cloudy with rain, across many northern 
        regions. Clear spells across most of Scotland and Northern Ireland, 
        but rain reaching the far northwest. \\
      \end{tabular}
    \end{center}
    \end{document}

a table with a column which spans multiple rows

    \documentclass{article}
    \usepackage{multirow}
    \begin{document}
     \begin{tabular}{|l|l|l|}
     \hline
     \multicolumn{3}{|c|}{Team sheet} \\
     \hline
     Goalkeeper & GK & Paul Robinson \\ \hline
     \multirow{4}{*}{Defenders} & LB & Lucus Radebe \\
      & DC & Michael Duberry \\
      & DC & Dominic Matteo \\
      & RB & Didier Domi \\ \hline
    \end{tabular}
    \end{document}

Table Width ‹↑›

table specific latex packages
longtable - allows table to span more than 1 page and provides headings
booktab - provides heavier top and bottom horizontal rules
colortbl - allows background colours for tables
xcolor - alternate row colours for tables
array - expands column alignment possibilities

create a table 1/2 the page text width, with the 2nd column wrapping

    \documentclass{article}
    \usepackage{tabularx}
    \begin{document}
    \begin{tabularx}{0.5\textwidth}{ l|X }
      \hline
      Vim  & A text editor based apon the 'vi' and 'ed'
             unix text editors. \\
      Sam  & A text editor favoured by some veteran
             unix coders \\
      \hline
    \end{tabularx}
    \end{document}

make a 250pt wide table with 4 columns (2 resizable columns)

 \begin{tabularx}{250pt}{|c|X|c|X|}

a table 1/2 the width of the page, with italic text in 2nd column

    \documentclass{article}
    \usepackage{tabularx}
    \begin{document}
    % the '>{\italic}' syntax comes from the 'array' package
    \begin{tabularx}{0.5\textwidth}{ l | >{\itshape}X }
      Force  & Force is a vector quantity. \\
      Moment & is defined as the cross product of the position vector \\
    \end{tabularx}
    \end{document}

make a column with small capital text which will wrap

 >{\scshape\small}X

Tabularx can have, rowcolours, multiple column rows, footnotes

make a alternate pale brown row-colours, 2/3rds the page width

    \documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{tabularx}
    \begin{document}
      \rowcolors[]{1}{brown!20}{}
      %% 1st column bold
      \begin{tabularx}{.75\textwidth}{>{\bfseries} lX }
      Perl & A scripting language popular in the late 90s \\
      Java & A clumsy inefficient virtual machine language \\
      Python & An increasingly trendy language \\
      Sed & A turing complete text editing language \\
      \end{tabularx}
    \end{document}

In the above table, column-width (not inter-column-spacing) will be adjusted to ensure the correct table width

resize a table to be 8cm wide preserving the original size ratio,,

    \resizebox{8cm}{!} {
      \begin{tabular}...
      \end{tabular}
    }

scale a table to be one half its original size


   \scalebox{0.5}{
    \begin{tabular}...
    \end{tabular}
  }

change the space between columns

 \setlength{\tabcolsep}{5pt}

make a table take up all the page width using 'geometry'

   \documentclass{article}
   \usepackage{tabularx}
   \usepackage[margin=1cm,noheadfoot]{geometry}
   \begin{document}
    %% 3rd column italic
    \begin{tabularx}{\linewidth}{l|l >{\itshape}X}
       {\bfseries\large Identifier} & 
       {\bfseries\large type} & 
       {\bfseries\large What is this used for?} \\
       \hline
       tracing & boolean & Determines whether debugging messages on/off \\
       isOn & boolean & whether the tv is on or off (in standby mode) \\ 
       onBefore & boolean & Whether the tv has been turned on before \\
   \end{tabularx}
   \end{document}

Images In Tables ‹↑›

place an image in a table

    \documentclass{article}
    \usepackage{graphicx}
    \begin{document}
      \begin{tabular}{|c|c|}
      first image & \includegraphics[scale=0.3]{image/tree.jpg} \\
      \newline
      second image & \includegraphics[scale=0.3]{image/tree.jpg} \\
    \end{tabular}
    \end{document}

place a code listing and an image in a table

    \documentclass{article}
    \usepackage{listings, graphicx}
    \begin{document}
      \begin{tabular}{|p{5cm}|c|}
      \hline
      \begin{lstlisting}[breaklines=true]
        for i = 1 to 20
        do 
          print why is this so;
        end
      \end{lstlisting}
      & \includegraphics[scale=0.3]{image/tree.jpg} \\
      \hline
      more text & \includegraphics[scale=0.3]{image/tree.jpg} \\
    \end{tabular}
    \end{document}

Rotating Tables ‹↑›

create a sideways table

   pre:
     \usepackage{rotating}
   body:
     \begin{sidewaystable}
     \begin{tabular}...
     \end{tabular}
     \end{sidewaystable}

place a sideways table exactly in its current position


   \usepackage{rotating}
   \usepackage{rotfloat}

   \begin{sidewaystable}[H]
    \begin{tabular}...
    \end{tabular}
   \end{sidewaystable}

place a caption above the table

    \documentclass{article} 
    \begin{document}
    \begin{table}[h]
      \centering
      \caption{Alphabetic values}
      \begin{tabular}{|r|c|}
        a & b \\ c & d \\
        e & f \\ g & h \\
      \end{tabular}
    \end{table}
    \end{document}

create a table which can be referenced with '\ref{table1}'

    \documentclass{article} 
    \begin{document}
      \begin{table}
      \centering
      \begin{tabular}{ll}
        a & b \\ c & d \\ e & f \\ g & h \\
      \end{tabular}
      \caption{An example of a referenceable table}
      \label{table1}
      \end{table}
      See the table \ref{table1}
    \end{document}
    % run pdflatex at least twice to resolve the references

use parbox to centre an image in a table cell

 \parbox[c]{1em}{\includegraphics{image.png}}

change the table name in captions to "Tab."

 \renewcommand{\tablename}{Tab.}

place 2 tables side by side


  \documentclass{article}
  \begin{document}
    \begin{table}[ht]
    \begin{minipage}[b]{0.5\linewidth}\centering
    \begin{tabular}{|c|c|c|}
    \hline 
      1&1&1\\ 2&2&2\\ 
    \hline
    \end{tabular} 
    \end{minipage}
    \hspace{0.5cm}
    \begin{minipage}[b]{0.5\linewidth}
    \centering
    \begin{tabular}{|c|c|c|}
    \hline 
      1&1&1\\ 2&2&2\\ 
    \hline
    \end{tabular} \end{minipage}
    \end{table}
  \end{document}

place tables or images side by side using "subfigure"

 \usepackage{subfigure}

place footnotes at the bottom of a table

 use "minipage" environment

Colours In Tables ‹↑›

Row Colours ‹↑›

make a alternate pale brown row-colours, 2/3rds the page width

    \documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{tabularx}
    \begin{document}
      \rowcolors[]{1}{brown!20}{}
      %% 1st column bold, 2nd column italic
      \begin{tabularx}{.75\textwidth}{>{\bfseries}l >{\itshape}X }
      Perl & A scripting language popular in the late 90s \\
      Java & A clumsy inefficient virtual machine language \\
      Python & An increasingly trendy language \\
      Sed & A turing complete text editing language \\
      \end{tabularx}
    \end{document}

The following recipe is a nice looking scheme for displaying date which takes up only one line.

alternating pale brown row-colours, with a brownish row lines

    \documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{tabularx}
    \begin{document}
      \arrayrulecolor{brown!70} 
      \rowcolors[\hline]{1}{brown!20}{}
      %% 1st column bold, 2nd column italic
      \begin{tabularx}{.75\textwidth}{>{\bfseries}l >{\itshape}X }
      Perl & A scripting language popular in the late 90s \\
      Java & A clumsy inefficient virtual machine language \\
      Python & An increasingly trendy language \\
      Sed & A turing complete text editing language \\
      \end{tabularx}
    \end{document}

create a gaudy table with alternating row colours

   \documentclass{article}
   \usepackage[table]{xcolor}
   \begin{document}
     \begin{center}
     \rowcolors{1}{green}{pink}
     \begin{tabular}{ll}
       grep   & find text \\ 
       find   & find files \\
       locate & find files faster \\
       du     & find how big the files are \\
     \end{tabular}
     \end{center}
    \end{document}

Use the \hiderowcolors and \showrowcolors commands to turn on and off the colours)

'\usepackage[table]{xcolor}' command depends on the colortbl and xcolor packages for colouring alternate rows of a table.

horizontal row-lines, pale blue & gray. start colours at line 2

 \rowcolors[\hline]{2}{blue!15}{gray!15}

this command goes before the table command

alternate transparent blue and white, starting at row 4

 \rowcolors{4}{blue!10}{}

make alternate green and yellow table lines, with horizontal lines start colouring at the third line , \documentclass[a4paper,12pt]{article} \usepackage[table]{xcolor} \begin{document} \rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray} % colour for the table rules \begin{tabular}{ lcr } % alignment left, centre, right 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ 7 & 8 & 9 \\ \end{tabular} \end{document} %% =0.2 image/eg-xcolor-tablerows.png %% ,,,

make alternate lines green (and white) , \documentclass{article} \usepackage[table]{xcolor} \begin{document} \rowcolors{1}{green!25}{} \begin{tabular}{ lll } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ 7 & 8 & 9 \\ \end{tabular} \end{document} %% =0.2 image/eg-xcolor-alternaterowsgreen.png %% ,,,

a bluey grey colour

 red!75!green!50!blue!25

make very pale alternate blue table rows with row numbers

     \documentclass[a4paper,12pt]{article}
     \usepackage[table]{xcolor}
     \begin{document}
       \rowcolors{1}{blue!15}{} 
       \begin{tabular}{ lll }   
       \number\rownum & cd     & return to the home folder \\
       \number\rownum & cd -   & return to the previous folder \\
       \number\rownum & select & make a selection \\
       \end{tabular}
     \end{document}

display a table which changes horizontal line colour halfway through , \documentclass{article} \usepackage[table]{xcolor} \begin{document} \rowcolors[\hline]{1}{gray!25}{} \arrayrulecolor{red!100} \begin{tabular}{ ll } italy & 2 \\ spain & 5 \\ \arrayrulecolor{black} england & 7 \\ france & 10 \\ \end{tabular} \end{document} %% =0.2 image/eg-xcolor-arrayrulecolor.png %% ,,,

a table with the 3rd row pale green, horizontal black lines , \documentclass[a4paper,12pt]{article} \usepackage[table]{xcolor} \begin{document} \rowcolors[\hline]{1}{}{} \arrayrulecolor{blue} \begin{tabular}{ ll } italy & 2 \\ spain & 5 \\ \rowcolor{green!20} england & 7 \\ france & 10 \\ germany & 7 \\ turkey & 11 \\ \end{tabular} \end{document}

%% =0.2 image/eg-xcolor-rowcolors-1.png %% ,,,

table with alternating pale blue lines, with a dark blue frame , \documentclass[a4paper,12pt]{article} \usepackage[table]{xcolor} \begin{document} \rowcolors{1}{blue!10}{} \arrayrulecolor{blue!75} \begin{tabular}{ | ll | } \hline italy & 2 \\ spain & 5 \\ england & 7 \\ france & 10 \\ \hline \end{tabular} \end{document}

%% =0.2 image/eg-xcolor-tableframe.png %% ,,,

display a table aligned to the right, with text flowing around it , \documentclass{article} \usepackage{wrapfig} \usepackage[table]{xcolor} \begin{document} \rowcolors[\hline]{1}{blue!20}{} % '0.5\textwidth' the wrapped area takes up half the page width \begin{wraptable}{r}{0.5\textwidth} \centering \caption{Country Numbers} \begin{tabular}{ | ll | } italy & 2 \\ spain & 5 \\ england & 7 \\ france & 10 \\ \end{tabular} \end{wraptable} blah...blah \end{document} %% =0.3 image/eg-xcolor-wrappedtable.png %% ,,,

display a table aligned to the right, wrapped using tabularx , \documentclass[a4paper,12pt]{article} \usepackage{wrapfig} \usepackage{tabularx} \usepackage[table]{xcolor} \begin{document} \begin{wraptable}{r}{0.5\textwidth} \centering \rowcolors{1}{blue!10}{} \arrayrulecolor{blue} % % "\rowcolors[\hline]{1}{blue!20}{}" gives lines between rows % "\rowcolors{2}{blue!20}{}" starts colouring at row 2 % "\rowcolors{2}{blue!20}{gray!20}" alternates pale blue/gray rows % % '>{\tiny}' makes the second column very small text % \begin{tabularx}{0.4\textwidth}{ |l>{\tiny}X| } \hline italy & a country known for its pomodoro and rabiata \\ spain & tortilla espanola and some snail eating in catalonia \\ england & not much mor than fish and chips \\ france & various delicacies \\ \hline \end{tabularx} \end{wraptable} blah...blah \end{document} %% =0.4 image/eg-xcolor-tabularx-frame.png %% ,,,

base colour names

    black darkgray  lime    pink   violet
    blue  gray      magenta purple white
    brown green     olive   red    yellow
    cyan  lightgray orange  teal

Colour Series Row Colours ‹↑›

 \definecolorseries{test}{hsb}{step}[hsb]{.575,1,1}{.11,-.05,0}

   rowcolors[\hline]{1}{test!!+}{test!!+}
   \begin{tabular}{c}
   \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
   \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
   \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
   \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
   \end{tabular}

Gotchas ‹↑›

grey is spelled 'gray' not 'grey'

 \rowcolours{1}{grey!25}   No! this is incorrect
 \rowcolours{1}{gray!25}   Correct

you have to have a row start number

 \rowcolors{}{gray!25}{}    No! incorrect
 \rowcolors{1}{gray!25}{}   correct

Long Tables ‹↑›

The long table package allows tables to span more than one page, which is good and necessary.

a bash function to create a table which spans more than one page

  function test {
    cat << xxx | pdflatex 
      \documentclass{article}
      \usepackage{longtable}
      \begin{document}
      \begin{longtable}{ll}
          \textit{Total Size} & \textit{File Name} \\\\
       \hline 
       $(du -sh * | tr -d '_$' | awk '{print $1" & "$2" \\\\"}')
       \hline
      \end{longtable}
      \end{document}
xxx
     }
     test; test; evince texput.pdf

The pdflatex tool may need to be run more than once on the input inorder to properly calculate and display the column widths

a long table with rotated headers (as a bash function)

  function test {
    cat << xxx | pdflatex 
      \documentclass{article}
      \usepackage{rotating}
      \usepackage{longtable}
      \begin{document}
      \begin{longtable}{ll}
       \begin{turn}{80} \textit{Total Size} \end{turn} &
       \begin{turn}{80} \textit{File Name} \end{turn} 
      \\\\ \hline 
       $(du -sh * | tr -d '_$' | awk '{print $1" & "$2" \\\\"}')
      \hline
      \end{longtable}
      \end{document}
xxx
     }
     test; test; evince texput.pdf

number non-empty line of a file and display each as a table row

  function test {
    cat << xxx | pdflatex 
      \documentclass{article}
      \usepackage[margin=2cm,noheadfoot]{geometry} 
      \usepackage{longtable}
      \begin{document}
      \begin{longtable}{ll}
          \textit{No.} & \textit{Phrase} \\\\
       \hline 
       $(nl -bp[a-z] $1 | tr -d '_$' | sed 's/^\s*//;s/\s\+/ \& \\Large /;s/$/ \\\\/')
      \hline
      \end{longtable}
      \end{document}
xxx
     }
     test test.txt; test test.txt; evince texput.pdf

make a long table

\documentclass{article} \usepackage{longtable,booktabs} \begin{document} \begin{longtable}{lrr} \caption[A Caption]{A Caption}\label{lab} \\ \hline Heading 1 & Heading 2 & Heading 3 \\ \hline \endfirsthead %\caption[]{(continued)} \\ \hline Head 1 & Head 2 & Head 3 \\ \hline \endhead \toprule \endfoot %% Put the rows of your table here \end{longtable} \end{document} ,,,

Wrapping Text Around Tables ‹↑›

www: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=textflow
a discussion of the different packages for wrapping text around things
wrap text around a table, centering the table above a caption , \documentclass{article} \usepackage{wrapfig} \begin{document} \begin{wraptable}{r}{0.5\textwidth} \centering \begin{tabular}{ |l|c|r| } \hline 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \hline \end{tabular} \caption{A table wrapped in text} \end{wraptable} \small text blah.blah \end{document}

%% =0.3 image/eg-wrapfig-table.png %% ,,,

Using The Booktabs Package For Tables ‹↑›

www: http://tug.ctan.org/macros/latex/contrib/booktabs/booktabs.pdf
Documentation for the "booktabs" package, which provides heavier top and bottom rules for tables and better spacing under the rules.
create a table which uses heavier top and bottom rules and better spacing , \documentclass[a4paper,12pt]{article} \usepackage{booktabs} \begin{document} \begin{tabular}{llr} \toprule \multicolumn{2}{c}{Item} \\ \cmidrule(r){1-2} Animal & Description & Price (\$) \\ \midrule Gnat & per gram & 13.65 \\ & each & 0.01 \\ Gnu & stuffed & 92.50 \\ Armadillo & frozen & 8.99 \\ \bottomrule \end{tabular} \end{document}

%% =0.2 image/eg-booktabs.png %% ,,,

create a table top rule with a 5 point width

 \toprule[5pt]

draw a table bottom rule (horizontal line) with a width of 3 points

 \bottomrule[3pt]

create a horizontal rule which only spans the 1 and second columns

 \cmdirule{1-2}

draw a horizontal rule spanning columns 1 & 2, with a width of 2 points

 \cmdirule[2pt]{1-2}

a rule on columns 2 & 3, width 2pt, trimmed on the left and on the right .75em

 \cmdirule[2pt](lr{.75em}){2-3}

add 3 points of space just before the bottom line of the table

 \\ \addlinespace[3pt] \bottomrule

Displaying Keystrokes ‹↑›

search for the help file for the 'keystroke' package

 find /usr/share -name 'key-test.pdf'

see the file 'key-test.pdf' for a complete list of the possible keystroke commands.

insert a graphical representation of keyboard keys , \documentclass{article} \usepackage{keystroke} \begin{document} Press the \Esc key \end{document} %% =2.8 image/eg-keystroke-esc.png %% ,,,

insert graphical representations of keyboard keys , \documentclass{article} \usepackage{keystroke} \begin{document} hit the \keystroke{F10} function key

and then \Enter \end{document} %% = image/eg-keystroke-f10.png %% ,,,

Drawing In Latex ‹↑›

packages for changing table width
tabularx - changes column width
tabular* - change spaces between columns

www: http://www.texample.net/tikz/examples/
examples of using tikz and pgf charting tools

Drawing Lines ‹↑›

draw a line at 45 degrees north east, starting at point 0.0

    \documentclass{article}
    \begin{document}
      Testing \LaTeX{} drawing
      \setlength{\unitlength}{5cm}
      \begin{picture}(1,1)
        \put(0,0){\line(1,1){.5}}
      \end{picture}
      With Text
    \end{document}

draw a 1cm line at nearly 45 degrees, starting at point 0,0

    \documentclass{article}
    \begin{document}
      Testing \LaTeX{} drawing
      \setlength{\unitlength}{5cm}   % 1 unit = 5cm
      \begin{picture}(1,1)           % create a 5cm x 5cm drawing box
        \put(0,0){\line(6,5){0.2}}   % start at 0,0 angle 6,5
      \end{picture}
      More Text
    \end{document}

Drawing Arrows ‹↑›

draw some arrows and a line, using different thicknesses , \documentclass{article} \begin{document} \setlength{\unitlength}{10mm} % a 1cm drawing length \begin{picture}(4,4) % a 40mm x 40mm drawing box \put(2,2){\vector(4,1){1}} % an arrow, 1cm length, start 2,2 \thicklines % make all lines thick, from now on \put(2,2){\vector(-4,1){1}} % length 10mm, start 2,2, angle -4,1 \put(0,0){\line(6,5){1}} % length 10mm, start at 0,0 angle 6,5 \thinlines % all lines thin from now on \put(2,2){\vector(-1,-1){1}} % length 10mm, start 2,2, angle -1,-1 \end{picture} \end{document}

%% = image/eg-vector.png %% ,,,

display a 2x2 matrix with arrow pointing in a clock-wise direction

    \documentclass{article} 
    \usepackage{xy}
    % this is not working
    %
    \begin{document}
    \begin{displaymath}
      \xymatrix{ A \ar[r] & B \ar[d] \\
      D \ar[u] & C \ar[l] }
    \end{displaymath}
    \end{document}

Listing Source Code ‹↑›

the simplest way to include source code

     \begin{verbatim}
       source code  
     \end{verbatim}

Using The Listings Package ‹↑›

www: http://stackoverflow.com/questions/741985/latex-source-code-listing-like-in-professional-books
good tips about professional listings
www: http://texblog.wordpress.com/2008/04/02/include-source-code-in-latex-with-listings/

The Gotchas ‹↑›

00- the command \begin{lstlisting} should not have anything after or errors will be produced - The basic style should always include \ttfamily "basicstyle=\ttfamily" - it is probably always a good idea to use "breaklines=true" or just "breaklines" so that the ends of long code lines do not disappear

Simple Usage ‹↑›

list program source code in a latex document , \documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[frame=single, language=bash] for f in $(ls *.txt) do cat $f; file $f done \end{lstlisting} \end{document} %% =0.45 image/eg-listings-simple.png %% ,,,

include an external file of program source code in a latex document

     \documentclass{article}
     \usepackage{listings}
     \begin{document}
       \lstinputlisting{filename.java}
     \end{document}

add line-numbers, fixed pitch font and a frame to the listing , \documentclass{article} \usepackage{listings} % listings should always be 'ttfamily' \lstset{basicstyle=\ttfamily, numbers=left, frame=single} \begin{document} \begin{lstlisting}[language=awk] # Hello BEGIN { print "Hello, World!" } \end{lstlisting} \end{document} %% = image/eg-listings-ttfamily.png %% ,,,

Listings With Frames ‹↑›

frame=none|leftline|topline|bottomline|lines|single|shadowbox

tools to draw and graph in latex
picture - the built in latex drawing tools
xy - simple drawing
TikZ - advanced diagrams
PGF -
gnuplot - an external plotting tool

a java code listing, 5pt wide green left side bar, left margin 1cm

      \documentclass{article}
      \usepackage{color, listings}           
      \lstset{language=java, xleftmargin=1cm,
              framerule=5pt, rulecolor=\color{red}, frame=l}  
      \begin{document}
      \begin{lstlisting} 
       public class Main 
       {
         public static void main(String[] args)
           { System.out.println(Math.ceil(5.5)); }
       }
       \end{lstlisting}
       \end{document}

display a listing with a frame, double frame on the bottom and left

    \documentclass{article}
    \usepackage{listings}
    \begin{document}
      \begin{lstlisting}[frame=trBL]
       for i:=maxint to 0 do
        begin { do nothing } end;
      \end{lstlisting}
    \end{document}

create a shadow box with a blue shadow with code in fixed pitch font

    \documentclass{article}
    \usepackage{color, listings}
    \begin{document}
    \lstset{basicstyle=\ttfamily, frame=shadowbox, rulesepcolor=\color{blue}}
    \begin{lstlisting}
       for i:=maxint to 0 do begin { do nothing } end;
    \end{lstlisting}
    \end{document}

a code listing with a frame with diagonally opposite corners rounded

    \documentclass{article}
    \usepackage{listings}
    \begin{document}
      \lstset{frameround=ftft}  % ne, se, sw, nw
      \begin{lstlisting}[frame=trbl]
        for i:=maxint to 0 do
          begin { do nothing } end;
      \end{lstlisting}
    \end{document}

Breaking Long Code Lines ‹↑›

It is probably alway advisable to use the "breaklines" or "breaklines=true" (which is the same) when using the listings package, since if you do not, then some code lines will simply be truncated at the right hand side of the page, leading to confusion and frustration for your readers when they try to run the code which you have provided.

00- Some problems - you cant use math symbols in the "postbreak" or "prebreak" options direction, in other words "postbreak=$\Rightarrow$" gives an error when compiling with latex. So you have to use ~"\mbox{$\mathsymbol$}" -

break long code lines, mark the start of each broken line with a dagger

    \documentclass{article}
    \usepackage{listings}
    \begin{document}
      \begin{lstlisting}[breaklines, postbreak=\dag]
        for i:=maxint to 0 do begin { ...a long line... } end;
      \end{lstlisting}
    \end{document}

break long lines, mark the start of broken lines with a diagonal arrow

    \documentclass{article}
    \usepackage{listings}
    \begin{document}
    % how to use math symbols with "postbreak" or "prebreak"
    \begin{lstlisting}[breaklines=true, postbreak=\mbox{\tiny$\searrow$}]
      for i:=maxint to 0 do begin { ...a long line... } end;
    \end{lstlisting}
    \end{document}

break long lines, mark the end of broken lines with a blue right arrow

    \documentclass{article}
    \usepackage{color, listings}
    \begin{document}
    \begin{lstlisting}[breaklines,prebreak=\mbox{{\color{blue}\tiny$\rightarrow$}}]
      for i:=maxint to 0 do begin { ...a long line... } end;
    \end{lstlisting}
    \end{document}

break long lines, mark broken lines with double blue right arrow + space

    \documentclass{article}
    \usepackage{color, listings}
    \begin{document}
    \begin{lstlisting}[breaklines,prebreak=\mbox{{\color{blue}\tiny$\Rightarrow$}\space}]
      for i:=maxint to 0 do begin { ...a long line... } end;
    \end{lstlisting}
    \end{document}

break long lines, and indent the broken lines by 10 points

    \documentclass{article}
    \usepackage{listings}
    \begin{document}
    \begin{lstlisting}[breaklines, breakindent=10pt]
      for i:=maxint to 0 do begin { ...a long line... } end;
    \end{lstlisting}

only break long lines at white space

    \documentclass{article}
    \usepackage{listings} 
    \begin{document}
      \begin{lstlisting}[breaklines, breakatwhitespace]
        for i :=maxintttto0o0dobegin{crypticon..++;}end;fori:=to0o0dobegin{crypticon..++;}end;fori:=maxintto0do 
      \end{lstlisting}

    \end{document}

Listing Specific Languages ‹↑›

specify the language as java for a particular listing , \documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[language=java] import java.util.*; public class HelloDate { public static void main (String[] args) { System.out.println ("Hello"); } } \end{lstlisting} \end{document} %% = image/eg-listings-language.png %% ,,,

turn off syntax highlighting

 language={}

indicate that text between '' and '' should be treated as a comment

 morecomment=[s]{}{}   ##(this should go in the \lstset{...} command)

display text between '~(' and ')~' in grey, italic, fixed pitch font

 moredelim=[s][\color{grey}\itshape\ttfamily]{~(}{)},

select the "77" dialect of Fortran

 language=[77]Fortran

select the "latex" dialect of the TeX typesetting language

 language=[LaTeX]TeX

select the "ansi" dialect of the c programming language

 language=[ANSI]C

some languages defined for the "listings" package

 sh, bash, perl, TeX, Awk, HTML   many more languages a defined

Listings With Captions ‹↑›

some frame options
framerule=2pt set the width of the frame rules to 2 points
rulesep=4pt set the space between double frame rules to 4 points
framesep=3pt set the space between the frame and the listing
rulecolor=\color{blue} set the colour of the frame rules to blue
rulesepcolor= set the colour between double frame rules, or shadows
xmarginleft=1cm a 1cm margin on the left (outside of the frame)
xmarginright=1cm a 1cm margin on the right (outside of the frame)
framexleftmargin=17pt margins inside a frame ?
framexrightmargin=5pt
framexbottommargin=4pt

display a listing with a caption at the bottom, 2 horizontal frame lines , \documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[frame=lines, captionpos=b, caption={basic java}] import java.util.*; public class HelloDate { public static void main (String[] args) { System.out.println ("Hello"); } } \end{lstlisting} \end{document} %% =0.45 image/eg-listings-caption.png %% ,,,

a listing with the caption "A finite loop" but no "Listing" label , \documentclass{article} \usepackage{listings} \begin{document} \lstset{frame=single, language=bash} \begin{lstlisting}[title={A Finite Loop}] for f in *; do sed 's/s/S/g' %f; done \end{lstlisting} \end{document} %% =0.45 image/eg-listings-title.png %% ,,,

a code listing with caption and label, using a reference to the label

    \documentclass{article}
    \usepackage{listings}
    \begin{document}
      \begin{lstlisting}[caption={Some code},label=loop]
        for i:=maxint to 0 do
         begin { ... } end;
      \end{lstlisting}

      % run pdflatex twice to resolve these references
      See listing: \ref{loop}
    \end{document}

define a custom caption class to use with a listing

    % this produces a left align white on grey caption for the listing
    \documentclass{report}
    \usepackage{color}
    \usepackage{xcolor}
    \usepackage{listings}
    \usepackage{caption}
    \DeclareCaptionFont{white}{\color{white}}
    \DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
    \captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
    \begin{document}
    \begin{lstlisting}[label=some-code,caption=Some Code]
      public void here() { goes().the().code() }
    \end{lstlisting}
    \end{document}

Colourful Listings ‹↑›

display a listing with a background colour

\documentclass{article} \usepackage{listings, color} \begin{document} \lstset{backgroundcolor=\color{yellow}} \begin{lstlisting}[frame=single, framerule=0pt] for i:=maxint to 0 do begin j:=square(root(i)); end; \end{lstlisting} \end{document} ,,,

display a listing with pale blue background, using xcolor

\documentclass{article} \usepackage{listings, xcolor} \begin{document} \lstset{backgroundcolor=\color{blue!10}} \begin{lstlisting}[frame=single, framerule=0pt] for i:=maxint to 0 do begin j:=square(root(i)); end; \end{lstlisting} \end{document} ,,,

display a java listing with syntax colour highlight

   \documentclass{article}
   \usepackage{listings, color}
   \begin{document}
   \lstset{ %
    language=Java,
    keywordstyle=\color{blue}, commentstyle=\color{darkgreen},
    stringstyle=\color{red}, basicstyle=\footnotesize, 
    emph={label}}
   \begin{lstlisting}
      public class Main {
        public static void main(String[] args) {
        Float fObj = new Float("10.50");
        }
      }
   \end{lstlisting}
   \end{document}

create a syntax highlighted listing with a background colour

    \documentclass{article}
    \usepackage[pdftex]{color}
    \usepackage{listings} 
    \definecolor{stringcolor}{rgb}{0.20,0.50,0.20}
    \definecolor{commentcolor}{rgb}{0.40,0.40,0.40}
    \definecolor{keywordcolor}{rgb}{0.50,0.10,0.10}
    \definecolor{idcolor}{rgb}{0.10,0.10,0.50}
    \definecolor{bg}{rgb}{0.95,0.95,0.95}
    \lstset{language=C,basicstyle=\ttfamily,keywordstyle=\color{keywordcolor},
    commentstyle={\color{commentcolor}\itshape},
    stringstyle={\color{stringcolor}},
    identifierstyle=\color{idcolor}
    backgroundcolor=\color{bg}}
    \begin{document}
    \begin{lstlisting}[title={\large Calculate pi function}]{calculate_pi_mp}
    ...
    \end{lstlisting}
    \end{document}

Listings Package Options ‹↑›

set options for all the listings in a document

 \lstset{...}

define a style name to be used with the "style" command

\documentclass{report} \usepackage{listings} \lstdefinestyle{javacode}{language=java, frame=lines} \begin{document} \begin{lstlisting}[style=javacode] public void here() { ... } \end{lstlisting} \end{document} ,,,

listing caption options
captionpos=t|b - if the caption is displayed above/below the listing
abovecaptionskip= - the amount of space above the caption
belowcaptionskip= - amount of space below

Defining New Latex Commands ‹↑›

define a command to format file names

 \newcommand*{\file}[1]{\textnormal{\texttt{.#1}}}

Packages ‹↑›

find what latex packages are currently installed locally

 sudo find /* -iname "*.sty" | less

some listings package option examples
basicstyle=\footnotesize\ttfamily - make the text small and fixed pitch
numbers=left - put the numbers on the left
numberstyle=\tiny - make the line numbers tiny
stepnumber=2 - number every second line
numbersep=5pt - make the gap between numbers and text 5 points.
extendedchars=true - allow the display of non-ascii characters (??)
breaklines=true - break long code lines
postbreak=* - put a star character after each broken line
keywordstyle=\color{red} - colour keywords red (with "color" package)
captionpos=b - place the caption at the bottom of the listing
language=java specify the language as java
title={important code} create a caption with no "Listing" label
aboveskip= the amount of space above the listing
belowskip= the amount of space below the listing

Viewing Latex And Compiled Documents ‹↑›

view a "device independent" dvi file

 xdvi travel.dvi

view the postscript document "list.ps"

 gv list.ps

view a pdf document

 xpdf list.pdf
 acroread list.pdf

Compiling And Converting Latex Documents ‹↑›

packages to investigate
tocbibind to change the table of contents
natbib -
thumbpdf to create thumbnails
pdfpages to include other pdf documents in the current one
blindtext ?
\usepackage[T1]{fontenc}

Converting From Latex ‹↑›

programs to convert latex to other formats
dvipdfm convert a dvi to a pdf
epstopdf convert postscript figures to pdf format
convert the "imagemagick" program can convert "dvi" to any imagee format

To Html ‹↑›

tools for converting to latex
dblatex - convert from docbook sources
hevea - latex to html info, or plain text
pandoc - convert to latex from 'markdown' format

translate a latex file to html using "latex2html"

 latex eg.tex; latex2html eg.tex

latex2html can create 'chunked' html files from the latex source.

Converting To Latex ‹↑›

tools for converting to html
debian package: hyperlatex tex4ht
latex2html -
htlatex -
pstoimg - part of latex2html can crop

Interactive Pdflatex Compiling ‹↑›

When something goes wrong with your document the 'pdflatex' compiler will start to ask you a whole series of annoying questions, some of which have no possible answer.

exit the interactive compiler immediately

 X         but if pdflatex wants a filename, this wont work
 xabcde    the same, only the first letter matters

show some possible commands for the pdflatex compiler

 z        any letter which is not a command will do

typing 'quit' and 'exit' dont work at all!

 quit   No! this runs the 'q' run quietly, command
 exit   Noo!! this runs the 'e' edit file command

tools for converting to latex
jadetex - sgml or xml to latex

Compiling Problems And Gotchas ‹↑›

it seems impossible to send the output of pdflatex to standard output (as would be normal with Unix programs)

to get the table of contents and other figures the document must be compiled twice.

if the latex document contains packages using a "pdftex" option, then "pdflatex --output-format dvi file.tex" will produce a "pdf" output file instead of a dvi output file for example: if you have "\usepackage[pdftex]{color}" in the latex file it will not be possible to produce a dvi output file.

If some of the pages are missing at the end of the document do you have an extra \end{document} mistakenly in there somewhere?

continue even if latex encounters errors, print all messages

 \nonstopmode              at the top of the document
 -interaction nonstopmode  the same, but on the command line

continue even if latex encounters errors, print very few messages

 \batchmode                             at the top of the document
 pdflatex -interaction batchmode eg.tex the same but on the command line

convert the latex document 'eg.tex' to a "png" image

 latex eg.tex; convert eg.dvi eg.png

The imagemagick 'convert' tool supports most image formats

compiler commands
X - exit immediately the compiler
H - show help for the immediate problem
R - just try to run and ignore errors
S keep going trying to ignore the problem

Compiling To Pdf Format ‹↑›

The simplest way to compile to pdf is just to use "pdflatex" with no other options. Compiling to pdf using a "tool chain" of several programs is the older method, and probably is now obsolete.

compile to pdf using pdflatex

 pdflatex eg.tex       produces a file "eg.pdf"

compile 'test.tex' and save the pdf file as 'new.pdf'

 pdflatex -jobname new test.tex

compile 'file.tex' to pdf and save as 'out.pdf' using standard input

 cat file.tex | pdflatex -jobname out

compile a latex document to pdf using the full tool chain

 latex eg.tex; dvips -Ppdf eg.dvi; ps2pdf eg.ps
 pdflatex --output-format dvi eg.tex; dvips -Ppdf eg.dvi; ps2pdf eg.ps

compile a latex document to pdf using dvipdfm

 latex eg.tex; dvipdfm eg.dvi  not pdflatex
 pdflatex --output-format dvi eg.tex; dvipdfm eg.dvi
this may be useful if the document contains postscript figures

Compile To Postscript Format ‹↑›

compile a latex document to postscript

 latex eg.tex; dvips eg.dvi
 pdflatex --output-format dvi eg.tex; dvips eg.dvi

Compile To Dvi Format ‹↑›

compile a latex document to dvi

 latex eg.tex
 pdflatex --output-format dvi file  the same

Compile To Image Formats ‹↑›

Use pstoimg, a very capable program.

convert 'old.ps' to a png image

 pstoimg -type png old.ps

convert 'old.ps' to a png image cropping all the whitespace

 pstoimg -type png -crop a old.ps

convert 'old.ps' to a png image making it transparent

 pstoimg -type png -crop a -trans old.ps

convert to gif images, one per page, cropping whitespace

 pstoimg -multi -out bar -type gif -crop a foo.ps

convert 'file.pdf' to a high quality 'png' format file

 convert -density 300 file.pdf file.png

convert 'file.pdf' to a high quality 'png' format file, cropping space

 convert -density 300 -trim file.pdf file.png

Converting Pdf To Other Formats ‹↑›

convert 'file.pdf' to a high quality png image

 convert -density 300 file.pdf file.png

convert 'file.pdf' to a high quality jpg image

 convert -density 300 file.pdf file.jpg

convert 'file.pdf' to a high quality png image, trimming whitespace

 convert -density 300 -trim file.pdf file.png

the same as above, but with the mysterious '+repage'

 convert -density 300 -trim +repage file.pdf file.png

Compiling With Bibtex ‹↑›

compile a document with a bibliography

    pdflatex example.tex
    bibtex example
    pdflatex example.tex
    pdflatex example.tex
    ...

Latex Compiler Error Messages ‹↑›

maybe you havent got a \documentclass directive

 ! LaTeX Error: \usepackage before \documentclass.

Too many columns in a table (or too many "&" column separators)

  Extra alignment tab has been changed to \cr.

 ! LaTeX Error: File `.cls' not found.

maybe you misspelled the \documentclass{...} name of the class (or used a non-existant document class) because pdf latex cant find the associated '.cls' file.

there is an unescaped "#" somewhere in the document

 Illegal parameter number in definition of \Hy@tempa

possibly an unescaped "%" or "{" etc in an \item[] command

 Paragraph ended before \@item was complete.

I got this with an escaped "{" as "$\{$" in a \url{...} argument

 TeX capacity exceeded, sorry [input stack size=1500]

Tds Tex Directory Structure ‹↑›

The tds, or 'tex directory structure' is an attempt at standardising where certain files will be placed in any given tex distribution (such as 'texlive' etc).

'texmf' means the tex installation folder.

possible latex compile modes
batchmode
non‐stopmode
scrollmode -
errorstopmode - stops if an error is encountered

Vim And Latex ‹↑›

If a text document contains a latex document embedded in it then it can be compiled to pdf from within 'vim' the text editor by using custom commands in vim. This capability appears to start to approximate 'literate' programming, which is a style of programming where the documentation is created in an integrated way with the program.

compile to pdf from this to next blank line, save in 'new.pdf'

 :.,/^ *$/w !pdflatex -jobname new

compile to pdf all following lines (latex code) and save as 'texput.pdf'

 :.,/^ *$/w !pdflatex

make an abbreviation which creates a simple latex document

 ab ltxd \documentclass{article}<cr>\begin{document}<cr>\end{document}

Creating New Vim Commands ‹↑›

Since vim has the ability to create new commands, we can create simple commands to compile document fragments with 'pdflatex' and view the result, all without actually leaving vim.

Put these new commands in the /etc/vim/vimrc file to make them permanently available.

'Print' compiles the given line range to pdf, saving the output as 'new.pdf'

 :com! -range -nargs=0 Print <line1>,<line2>w !pdflatex -jobname new
 :com! -range Print <line1>,<line2>w !pdflatex -jobname new   same?

'PP' compiles the line range to pdf, saving the output as 'texput.pdf

 :com! -range Print <line1>,<line2>w !pdflatex
 com! -range Print <line1>,<line2>w !pdflatex  within the 'vimrc' file

use the new command to compile the current paragraph to pdf

 !ap<backspace>Print

'Pdf' compiles a line range to pdf and then views the new file

 :com! -range Pdf <line1>,<line2>w !pdflatex; evince texput.pdf

execute the new 'Pdf' command, using the current paragraph

 !ap<backspace> Pdf     '<backspace>' means hit that key

a command 'PP' which converts stuff between '---' and ',,,' to pdf

 :com PP ?^ *---?+1,/^ *,,,/-1w !pdflatex

The above command 'PP' will move up the document to the first line which starts with '---' and then move one line down (+1). Then the command will search downwards for the first line which starts with ',,,' and once found, will move one line upwards (-1). The command will then pipe this range of lines to the 'pdflatex' command.

create a command which converts a fragment to an image, cropping

 com! Pdfi ?^ *---?+1,/^ *,,,/-1w !sed 's/document}/&\n \\pagestyle{empty}/' | pdflatex; convert -density 300 -trim texput.pdf new.jpg; gthumb new.jpg

I insert a '\pagestyle{empty}' above so that when the pdf file is converted to an image and 'cropped' (whitespace trimmed with '-trim') the page number does not create a large image.

Example Text Using Vim Commands ‹↑›

make a command 'Blah' which inserts 200 words of random text

 com! Blah r !shuf -n 200 /usr/share/dict/words | tr '\n' ' '

make a command 'Blah' which inserts a give number of random words

 com! -nargs=1 Blah r !shuf -n <args> /usr/share/dict/words | tr '\n' ' '

The command above can be executed with ':Blah 30' to insert 30 random words into the document. The text is inserted at the current cursor position. This is useful when you are testing some latex command which requires a considerable amount of example text.

Complex Vim Commands For Latex ‹↑›

a command which compiles/views the latex fragment on the current line

# the command first strips of '#' comment characters at the start # of the line to be compiled, and then adds a basic skeleton document # around the latex code fragment :command! Pdfl .w !sed 's/^ *\#//' | sed 's/^/\\documentclass{article}\n\\begin{document}\n/' | sed '$s/$/\n\\end{document}/' | pdflatex; evince texput.pdf

,,,

a command to create an image out of a latex fragment with cropping

# Command explanation: # make a command 'Cofragment' which; # takes the current line '.w', removes comment '#' characters # from the front and back of the line 's/^ *\#//' etc. Then # adds a latex skeleton document around the fragment. Then # converts this document to pdf with 'pdflatex'. Then uses # imagemagicks 'convert' tool to crop all unnecessary whitespace # and convert to the jpeg format with the name 'new.jp' in the # users image folder. Then views the new image with 'gthumb' #

:com! Cofragment .w !sed 's/^ *\#//; s/\# *$//' | sed 's/^/\\documentclass{article}\n\\pagestyle{empty}\n\\begin{document}\n/' | sed '$s/$/\n\\end{document}/' | pdflatex; convert -density 300 -trim texput.pdf ~/image/new.jpg; gthumb ~/image/new.jpg

,,,

compile a fragment and specify the output image name

:com! -nargs=1 Cofragment .w !sed 's/^ *\#//; s/\# *$//' | sed 's/^/\\documentclass{article}\n\\pagestyle{empty}\n\\begin{document}\n/' | sed '$s/$/\n\\end{document}/' | pdflatex; convert -density 300 -trim texput.pdf ~/image/<args>.jpg; gthumb ~/image/<args>.jpg

,,,

Sed And Latex ‹↑›

It is possible to use the venerable unix stream editor to create latex documents from plain text ones. This is the idea behind 'markdown' and 'pandoc' but sometimes writing your own little sed script maybe the way to achieve the result. As usual gnused is assumed.

convert '[=image-file.ext]' to a centered latex image

    #!/bin/sed -rf
    s/^ *\[= *([^]]*)\] *$/\
    \\begin{center}\
      \\includegraphics[width=0.4\\textwidth]{\1}\
    \\end{center}/g;

Texlive Extra Packages ‹↑›

some folders
texmf/tex/latex/ - location for '.sty' files
dvips/ps2pdf. convention.

Tex Distributions ‹↑›

www: http://www.tug.org/texlive
the texlive home page
telive, tetex, xetex etc, miktex

Published Books Created With Latex ‹↑›

This list of books created with latex is designed to give the reader and idea of what latex is capable of producing.

Unix, Programacion Avanzada (Marquez, Alphaomega press) This is a extremely well presented technical book about unix programming written in spanish

DOCUMENT-NOTES:

the texlive latex extra packages
ESIEEcv - Curriculum vit for French.
GuIT - The GuIT package.
HA-prosper - Patches and improvements for prosper.
Tabbing - Tabbing with accented letters.
a0poster - Support for designing posters on large paper.
abstract - Control the typesetting of the abstract environment.
achemso - LaTeX and BibTeX style for American Chemical Society.
acronym - Expand acronyms at least once.
adrconv - BibTeX styles to implement an address database.
adrlist - Using address lists in LaTeX.
akletter - Comprehensive letter support.
altfont - No caption.
answers - Styles for setting questions (or exercises) and answers.
appendix - Extra control of appendices.
arcs - Draw arcs over and under text
arrayjob - Array data structures for (La)TeX.
assignment - A class file for typesetting homework and lab assignments
attachfile - Attach arbitrary files to a PDF document
authorindex - Indexing citations by author names.
autotab - Generating tabular setups.
begriff - Typeset Begriffschrift.
beton - Use Concrete fonts.
bez123 - Support for Bezier curves.
bezos - Packages by Javier Bezos.
binomexp - The binomexp package.
bizcard - Typeset business cards.
blindtext - Producing 'blind' text for testing.
boites - Boxes that may break across pages
booklet - Aids for printing simple booklets.
bophook - Provides AtBeginPage hook.
boxhandler - The boxhandler package.
breakurl - Line-breakable \url-like links in hyperref when compiling via
bussproofs - The bussproofs package.
calendar - A package for calendars and timetables.
calrsfs - Nicer calligraphic letters.
calxxxx - Prints a card-size calendar for any year.
captcont - Retain float number accross several floats.
casyl - Typeset Cree/Inuktitut in Canadian Aboriginal Syllabics.
cbcoptic - Coptic fonts and LaTeX macros for usage and for philology.
ccaption - Continuation headings and legends for floats.
cd - Typeset CD covers.
cd-cover - The cd-cover package.
cdpbundl - Business letters in the Italian style
cellspace - The cellspace package.
changebar - Generate changebars in LaTeX documents.
chappg - The chappg package.
chapterfolder - Package that simplifies working with folder structure
circ - Macros for typesetting circuit diagrams.
cjw - A bundle of packages and classes.
clefval - Key/value support with a hash.
clock - Graphical and textual clocks for TeX and LaTeX.
cmdtrack - Check used commands
cmsd - A package including additional fd files.
codepage - Support for variant code pages.
colorinfo - Retrieve color model and values for defined colors.
combine - Bundle individual documents into a single document.
comment - Selectively include/excludes portions of text.
concprog - Concert programmes.
contour - Print a coloured contour around text.
cooking - Typeset recipes.
cool - The cool package.
coollist - The coollist package.
coolstr - The coolstr package.
cooltooltips - The cooltooltips package.
coordsys - Draw cartesian coordinate systems.
count1to - Set count1 to count9.
courseoutline - Prepare university course outlines
coursepaper - Prepare university course papers
coverpage - The coverpage package.
crossreference - Crossreferences within documents
crosswrd - Macros for typesetting crossword puzzles..
csquotes - Context sensitive quotation marks.
csvtools - Reading data from CSV files
cuisine - Typeset recipes.
currvita - Typeset a curriculum vitae.
cursor - No caption.
cv - A package for creating a curriculum vitae.
cwpuzzle - Typeset crossword puzzles.
dashbox - Draw dashed boxes.
dashrule - Draw dashed rules.
dateiliste - The dateiliste package.
datenumber - Convert a date into a number and vice versa.
datetime - Change format of \today with commands for current time.
decimal - LaTeX package for the traditional English decimal point
deleq - Flexible numbering of equations.
diagnose - A diagnostic tool for a TeX installation.
dialogl - Macros for constructing interactive LaTeX scripts.
dichokey - Construct dichotomous identification keys.
dinbrief - German letter DIN style.
directory - Address book.
dk-bib - Danish variants of standard BibTeX styles.
dnaseq - Format DNA base sequences.
docmfp - Document non-LaTeX code.
dotseqn - Flush left equations with dotted leaders to the numbers.
dpfloat - Support for double-page floats.
draftcopy - Identify draft copies.
draftwatermark - The draftwatermark package.
dropping - Drop first letter of paragraphs.
dtk - The dtk package.
dvdcoll - The dvdcoll package.
eCards - The eCards package.
easy - A collection of ``easy'' to use macros.
ebezier - Device independent picture enhancement
eemeir - Adjust the gender of words in a document.
egplot - No caption.
ellipsis - Fix uneven spacing around ellipses in LaTeX text mode.
elmath - Mathematics in Greek texts.
elpres - The elpres package.
em - The em package.
empheq - EMPHasizing EQuations.
emulateapj - No caption.
endfloat - Move floats to the end with markers where they belong.
endheads - The endheads package.
engpron - Helps to type the pronunciation of English words.
engrec - Enumerate with lower- or uppercase Greek letters.
enumitem - Control layout of itemize enumerate, description.
envbig - Printing addresses on envelopes.
envlab - Facilates addressing envelopes or mailing labels.
epigraph - A package for typesetting epigraphs.
epiolmec - Typesetting the Epi-Olmec Language.
eqlist - Description lists with equal indentation.
eqname - Name tags for equations.
eqparbox - Create equal-widthed parboxes
esdiff - Simplify typesetting of derivatives.
esint - Extended set of integrals for Computer Modern.
esint-type1 - The esint-type1 package.
etaremune - Reverse-counting enumerate environment.
europecv - Unofficial class for European curricula vitae.
everypage - The everypage package.
exam - Package for typesetting exam scripts.
examdesign - LaTeX class for typesetting exams.
examplep - Verbatim phrases and listings in LaTeX.
exercise - A package to typeset exercises problems, etc. and their answers
expdlist - Expanded description environments.
expl3 - Experimental packages demonstrating a possible LaTeX3 programming
export - Import and export values of LaTeX registers.
extract - Extract specific content from a source document and write that to a target document
facsimile - Document class for preparing faxes.
fancybox - Variants of \fbox.
fancynum - Typeset numbers.
figbib - Organize figure databases with BibTeX.
figsize - Auto-size graphics.
filecontents - Extended filecontents and filecontents* environments
fink - The LaTeX2e File Name Keeper.
fixfoot - Multiple use of the same footnote text
fixme - Insert "fixme" notes into draft documents.
flabels - Labels for files and folders.
flagderiv - The flagderiv package.
flashcards - A class for typesetting flashcards.
flippdf - The flippdf package.
floatrow - Extension or addition for float package.
flowfram - Create text frames for posters brochures or magazines.
fmp - Include Functional MetaPost in LaTeX.
fmtcount - Display the value of a LaTeX counter in a variety of formats.
fnbreak - Warn for split footnotes.
fncychap - Six predefined chapter heading styles.
foilhtml - Interface between foiltex and LaTeX2HTML.
footmisc - A range of footnote options
footnpag - Per-page numbering of footnotes.
forloop - The forloop package.
formlett - Letters to multiple recipients.
formular - Create forms containing field for manual entry.
fribrief - A LaTeX class for writing letters.
fullblck - Left-blocking for letter class.
fullpict - Full page pictures.
fundus - Providing LaTeX access to various font families.
g-brief - Letter document class.
gauss - A package for Gaussian operations
genmpage - Generalization of LaTeX's minipages.
ginpenc - Modification of inputenc for German.
gloss - Create glossaries using BibTeX.
glossary - Create a glossary
gmdoc - The gmdoc package.
gmiflink - The gmiflink package.
gmutils - The gmutils package.
gmverb - The gmverb package.
graphicx-psmin - The graphicx-psmin package.
grfpaste - Include fragments of a dvi file.
hanging - Hanging paragraphs.
harpoon - Extra harpoons using the graphics package.
hc - Replacement for the LaTeX classes.
hhtensor - Print vectors matrices, and tensors.
histogr - Draw histograms with the LaTeX picture environment.
hitec - Class for documentation.
hpsdiss - A dissertation class.
hvfloat - Rotating caption and object of floats independently.
hyper - Hypertext cross referencing.
hyperxmp - The hyperxmp package.
hyphenat - Disable/enable hypenation.
ifmslide - Presentation slides for screen and printouts.
interactiveworkbook - latex-based interactive PDF on the web
invoice - Generate invoices.
ipa - No description available.
iso - Typesetting ISO International Standard documents
iso10303 - Typesetting ISO 10303 International Standard documents
isodate - Tune the output format of dates according to language.
isorot - Rotation of document elements.
isotope - A package for type setting isotopes
kalender - Style file for creating a calendar; in German.
kastrup - The kastrup package.
kerntest - Print tables and generate control files to adjust kernings.
keystroke - Graphical representation of keys on keyboard.
labbook - Typeset laboratory journals.
labelcas - The labelcas package.
labels - Print sheets of sticky labels.
lastpage - Reference last page for Page N of M type footers.
latex-tds - The latex-tds package.
layouts - Display various elements of a document's layout.
lazylist - Lists in TeX's "mouth"
lcd - Alphanumerical LCD-style displays.
lcg - Generate random integers.
leaflet - Create small handouts (flyers).
leftidx - Left and right subscripts and superscripts in math mode.
lettre - Letters and faxes in French.
lettrine - Typeset dropped capitals.
lewis - The lewis package.
lhelp - Miscelaneous helper pacakges.
limap - Typeset maps and blocks according to the Information Mapping method.
lipsum - Easy access to the Lorem Ipsum dummy text.
listliketab - Typeset lists as tables.
listofsymbols - Create and manipulate lists of symbols
lkproof - LK Proof figure macros.
localloc - Macros for localizing TeX register allocations.
logpap - Generate logarithmic graph paper with LaTeX.
lsc - The lsc package.
ltablex - Table package extensions.
ltabptch - Bug fix for longtable.
ltxindex - A LaTeX package to typeset indices with GNU's Texindex.
mailing - Macros for mail merging.
makebox - Defines a \makebox* command
makecell - Tabular column heads and multilined cells
makecirc - A METAPOST library for electrical circuit diagrams drawing.
makecmds - The new \makecommand command always (re)defines a command.
makedtx - Perl script to help generate dtx and ins files
makeglos - Include a glossary into a document.
manfnt - LaTeX support for the TeX book symbols.
manuscript - Emulate look of a document typed on a typewriter.
mapcodes - Support for multiple character sets and encodings.
maple - Styles and examples for the MAPLE newsletter.
marginnote - The marginnote package.
maybemath - Make math bold or italic according to context.
mcaption - The mcaption package.
mceinleger - Creating covers for music cassettes.
mcite - No caption.
menu - Typesetting menus.
method - Typeset method and variable declarations.
metre - Support for the work of classicists
mff - Multiple font formats.
mftinc - Pretty-print Metafont source.
minipage-marginpar - The minipage-marginpar package.
minitoc - Produce a table of contents for each chapter.
minutes - Package for writing minutes of meetings.
misc209 - Miscellaneous LaTeX packages
mla-paper - Proper MLA formatting.
moderncv - The moderncv package.
modroman - Write numbers in lower case roman numerals.
morehelp - No caption.
moresize - Allows font sizes up to 35.83pt.
moreverb - Extended verbatim.
movie15 - Multimedia inclusion package.
mparhack - A workaround for a LaTeX bug in marginpars.
msc - Draw MSC diagrams.
msg - A package for LaTeX localisation.
mslapa - Michael Landy's APA citation style.
mtgreek - Use italic and upright greek letters with mathtime
multenum - Multi-column enumerated lists.
multibbl - Multiple bibliographies.
multicap - Format captions inside multicols
multirow - Creates tabular cells spanning multiple rows.
multitoc - Set table of contents in multiple columns.
mwrite - Write information to files.
nag - Detecting and warning about obsolete LaTeX commands
namespc - Rudimentary c++-like namespaces in LaTeX.
ncclatex - An extended general-purpose class
ncctools - A collection of general packages for LaTeX
newfile - User level management of LaTeX input and output.
newlfm - Write letters facsimiles, and memos.
newthm - No caption.
newvbtm - Define your own verbatim-like environment.
noitcrul - The noitcrul package.
nomencl - Produce lists of symbols as in nomenclature.
nomentbl - Nomenclature typeset in a longtable
nonfloat - Non-floating table and figure captions.
notes - Mark sections of a document.
ntabbing - Simple tabbing extension for automatic line numbering.
ntheorem - Enhanced theorem environment.
numprint - Print numbers with separators and exponent if necessary.
ocr-latex - The ocr-latex package.
octavo - The octavo package.
oldstyle - Old style numbers in OT1 encoding.
onlyamsmath - The onlyamsmath package.
opcit - Footnote-style bibliographical references.
outline - List environment for making outlines.
outliner - Change section levels easily.
overpic - Combine LaTeX commands over included graphics.
oxford - A BibTeX style of citations for the humanities.
pageno - Page number-only page styles.
pagenote - Notes at end of document.
paper - Versions of article class tuned for scholarly publications.
papercdcase - The papercdcase package.
papertex - The papertex package.
paralist - Enumerate and itemize within paragraphs.
paresse - Defines macros for greek letters
patch - Macros for package management.
patchcmd - Change the definition of an existing command.
pauldoc - The pauldoc package.
pawpict - Using graphics from PAW.
pbox - A variable-width \parbox command.
pbsheet - Problem sheet class.
pdfcprot - Activating and setting of character protruding using pdflatex.
pdfscreen - Support screen-based document design.
pdfslide - Presentation slides using pdftex.
pdfsync - The pdfsync package.
pdfwin - Customizable windows for screen output.
pecha - A LaTeX class to print Tibetan text in the classic pecha layout style.
perltex - Define LaTeX macros in terms of Perl code
permute - Support for symmetric groups.
photo - A float environment for photographs.
pittetd - Electronic Theses and Dissertations at Pitt.
placeins - Control float placement.
plates - Arrange for "plates" sections of documents.
plweb - The plweb package.
polyglot - A package for LaTeX2e multilingual support.
polynom - Macros for manipulating polynomials.
polytable - Tabular-like environments with named columns.
postcards - Facilitates mass-mailing of postcards (junkmail).
ppr-prv - Prosper preview.
prelim2e - Allows the marking of preliminary versions of a document.
preprint - A bundle of packages provided "as is".
prettyref - Make label references "self-identify".
probsoln - generate problem sheets and their solution sheets
program - Typesetting programs and algorithms.
progress - Creates an overview of a documents' state.
protocol - Typeset meeting protocols.
psfragx - A psfrag eXtension
pst-pdf - The pst-pdf package.
qcm - A LaTeX2e class for making multiple choice questionnaires
qsymbols - Maths symbol abbreviations.
quotchap - Decorative chapter headings.
ragged2e - Alternative versions of "ragged"-type commands
randtext - The randtext package.
rccol - Right-centered optionally rounded numbers in tabular.
rcsinfo - Support for the revision control system.
rectopma - Recycle top matter.
refcheck - Check references (in figures table, equations, etc).
refman - Format technical reference manuals.
refstyle - Advanced formatting of cross references.
regcount - Display the allocation status of the TeX registers.
register - Typeset programmable elements in digital hardware (registers).
relenc - A "relaxed" font encoding.
repeatindex - Repeat items in an index after a page or column break
resume - The resume package.
rlepsf - No caption.
rmpage - A package to help change page layout parameters in LaTeX.
robustcommand - The robustcommand package.
robustindex - Create index with pagerefs.
romannum - Generate roman numerals instead of arabic digits.
rotfloat - Rotate floats.
rotpages - Typeset multiple pages upside-down with page order rearrangement
rst - Drawing rhetorical structure analysis diagrams in LaTeX
rtkinenc - Input encoding with fallback procedures.
sauerj - A bundle of utilities by Jonathan Sauer.
savefnmark - Save name of the footnote mark for reuse.
savesym - Redefine symbols where names conflict.
savetrees - Pack as much text as possible onto each page of a LaTeX document.
scale - Scale document by sqrt(2) or magstep(2).
scalebar - Create scalebars for maps diagrams or photos.
schedule - Weekly schedules.
sciwordconv - Scientific Word/WorkPlace source files with another TeX.
script - Variant report / book styles.
sectionbox - The sectionbox package.
sectsty - Control sectional headers.
semantic - Help for writing programming language semantics.
semioneside - The semioneside package.
seqsplit - The seqsplit package.
sf298 - Standard form 298.
sffms - Typesetting science fiction/fantasy manuscripts.
shadbox - Shade the background of any box.
shadethm - Theorem environments that are shaded.
shapepar - A macro to typeset paragraphs in specific shapes.
shortlst - Compact lists by running several items per line.
shorttoc - Table of contents with different depths.
showdim - Variants on printing dimensions.
showexpl - The showexpl package.
showlabels - Show label commands in the margin.
sidecap - Typeset captions sideways.
slantsc - Access different-shaped small-caps fonts.
slashbox - Dual headings in tabular columns.
slidenotes - No caption.
smalltableof - Create listoffigures etc. in a single chapter.
smartref - Extend LaTeX's \ref capability.
smflatex - Classes conforming to Soci\'et\'e math\'ematique de France.
snapshot - List the external dependencies of a LaTeX document.
soul - Hyphenation for letterspacing underlining, and more.
sparklines - Drawing sparklines: intense simple, wordlike graphics.
splitbib - Split and reorder your bibliography.
splitindex - Unlimited number of indexes.
spotcolor - The spotcolor package.
sprite - Macros to set bitmaps with TeX.
srcltx - Jump between DVI and TEX files.
sseq - Spectral sequence diagrams.
ssqquote - Use the cmssq fonts.
stack - Tools to define and use stacks.
statistik - Store statistics of a document.
stdclsdv - Provide sectioning information for package writers.
stdpage - Standard pages with n lines of at most m characters each.
sttools - Various macros.
subeqn - Package for subequation numbering.
subeqnarray - Equation array with sub numbering.
subfigure - Figures divided into subfigures.
subfloat - Sub-numbering for figures and tables.
substr - Deal with substrings in strings.
supertabular - A multi-page tables package.
svgcolor - The svgcolor package.
svn - Typeset Subversion keywords
svn-multi - The svn-multi package.
svninfo - Typeset Subversion Keywords.
syntax - Drawing syntax diagrams
syntrace - The syntrace package.
synttree - Typeset syntactic trees.
tabto-ltx - The tabto-ltx package.
tabulary - The tabulary package.
talk - The talk package.
taupin - The taupin package.
tcldoc - Old name for tclldoc.
technics - A package to format technical documents.
texlogos - Ready-to-use LaTeX logos.
texmate - Comprehensive chess annotation in LaTeX.
texshade - Package for setting nucleotide and peptide alignments.
textcase - The textcase package.
textfit - Fit text to a desired size.
textmerg - Merge text in TeX and LaTeX.
textpos - Place boxes at absolute positions.
thumb - Thumb marks in documents.
ticket - Make labels visting-cards, pins with LaTeX.
timesht - Package for typesetting time sheets.
timing - Fonts and macro package for drawing timing diagrams.
titlefoot - Add special material to footer of title page.
titlesec - Select alternative section titles.
titling - Control over the typesetting of the \maketitle command.
tocbibind - Add bibliography/index/contents to Table of Contents.
tocloft - Control table of contents figures, etc.
tocvsec2 - Section numbering and table of contents control.
todo - Make a to-do list for a document.
tokenizer - A tokenizer.
toolbox - Macros for writing indices glossaries.
topfloat - Move floats to the top of the page.
totpages - Access last page number and page mark of last page.
tracking - Adjust tracking of strings.
trfsigns - Typeset transform signs.
trsym - The trsym package.
twoup - Print two virtual pages on each physical page.
type1cm - No caption.
typedref - Eliminate errors by enforcing the types of labels.
typogrid - Print a typographic grid.
ulsy - Extra mathematical characters.
umoline - Underline text allowing line breaking.
underlin - Multi-word underlining.
undertilde - Typeset a tilde under one (or many) maths symbols.
units - Typeset units.
upquote - Show "realistic" quotes in verbatim.
ushort - Shorter (and longer) underlines and underbars.
varindex - Luxury frontend to the \index command.
vector - No caption.
versions - Optionally omit pieces of text.
vhistory - The vhistory package.
vita - Configurable class for curricula vitarum.
vmargin - Set various page dimensions.
volumes - Typeset only parts of a document with complete indexes etc.
vpe - The vpe package.
vrsion - Add version number to DVI file.
wallpaper - Easy addition of wallpapers (background images) to LaTeX documents including tiling.
warning - Global warnings at the end of the logfile.
warpcol - Relative alignment of rows in numeric columns in tabulars.
was - A collection of small packages by Walter Schmidt.
webeq - A series of packages for online education.
williams - Miscellaneous macros by Peter Williams.
wordcount - Estimate the number of words in a LaTeX document.
wordlike - The wordlike package.
wrapfig - Produces figures which text can flow around.
xbmc - Skeleton package.
xdoc - Extending the LaTeX doc system.
xifthen - The xifthen package.
xmpincl - Include "eXtensible Metadata Platform" data in pdflatex
xytree - The xytree package.
yafoot - Miscellaneous footnote commands.
yplan - Daily planner type calendar.
zed-csp - Typesetting Z and CSP format specifications.
bin-perltex - Define LaTeX macros using Perl
xmlplay - Typeset Shakespeare's plays as marked up by Bosak.
bigfoot - The bigfoot package.