Latex tips by A. Fornasiero

additional (La)TeX links

Tex search path

By default, TeX and friends will look for a file in the following locations (in order):

  1. the user tex directory: in my case, ~/texmf (where ~ stands for the home directory);
  2. the local tex directory: /usr/local/share/texmf
  3. the main tex directory: /usr/share/texmf

The defaults are set in the file texmf.cnf (in our system, the complete path is /usr/share/texmf/web2c/texmf.cnf).
If you want to install a tex file, copy it in a suitable subdirectory of ~/texmf (e.g., you will copy a Latex .sty file in a subdirectory of ~/texmf/tex/latex/), and then re-build the database, using the comand texhash . from inside ~/texmf (note the dot).

Suppose now that you want to modify the search path. We will consider the following case: you want tex to search (in order) your texmf directory, the texmf directory of the user fornasiero (me), and then the "system" texmf directories. Of course, we will assume that you can read the contents of the directory /home/fornasiero/texmf. You have to set the system variable $TEXMF. Assume that your home is /home/pippo. With the value
TEXMF= {!!/home/pippo/texmf,!!/usr/local/share/texmf,!!/usr/share/texmf}
you obtain the default behaviour described above. You have to modify TEXMF, and obtain:
TEXMF= {!!home/pippo/texmf,!!/home/fornasiero/texmf,!!/usr/local/share/texmf,!!/usr/share/texmf}

Method: for a temporary change, write (on you shell: we will assume that you use the bash shell)
export TEXMF='{!!$HOME/texmf,!!/home/fornasiero/texmf,!!/usr/local/share/texmf,!!/usr/share/texmf}'
for a permanent change, add the above line to your .bashrc file (it should be in your home directory; if it is not there, create one containing the above line).

Interesting packages

adding for hyphenation and changing names (ad es. section -> sezione)
amsmath amssymb amsthm
AMS maths packages. amssymb for symbols (greek letters, \prod, etc.) amsthm for theorem environments
for better looking "small" fractions
case construction with numeration of every formula
better enumeration environment
\begin{enumerate}[{punto }a.]
enumerates using the format punto a, punto b etc. You can use I for roman etc.
You could use instead \renewcommand{\enumi}{punto \alph{enumi}}
indexing package
allows many different indexes
defines the command \xspace
NewCentury, AvantGarde, Courier fonts
additional fonts: gothic, etc. allows to use \textfrak and \textswab
to enlarge the space between letters:
\letterspace to 1.5\naturalwidth{abcdefghijklmnopqrstuvwxyz}
prints the alphabet with large space between letters
embeds hyperlinks nel file dvi (o pdf) should be installed as the last one but before using \newtheorem
bookmark entries can be given in another argument of the sectioning commands, for compatibility with pdftex
simulates some commands in hyperref, for compatibility with hyperref
activates source specials for forward searching
previews the dvi file in the emacs buffer; works with AUCTeX and (X)Emacs
show key labels in the dvi file



ensures to be in math mode
\newcommand[2][normal]{\pippo}{text #1 #2d}
defines the commands \pippo, with 2 arguments, the first optional, and with default value normal.
text first second
defines the command \pippo, if it does not already exists; otherwise, does nothing
redefines the command \pippo, if it does not already exists; otherwise, gives error
inserts the contents of file nomefile as it is
start a new page and inputs nomefile. You cannot \include inside an included file (bu you can use \input instead)
\includeonly{file1,file2}(in the preamble)
tells to use only the files file1 and file2 among the ones mentioned by the \include However, it keeps page numbering and labels as if all files were included


\makeindex \makeglossary (in the preamble)
create index and glossary files
\printindex (in the text)
print the index
\index{$\exp$|see{exponential}} (in the text, at any point, better at the beginnig)
create the index entry $\exp$ (a symbol), with the caption see exponential
\index{$\exp$}(in the text)
add the current page to the $\exp$ entry
add the common subetry to the length entry
\index{exponential|(} many pages of text ... text \index{exponential|)}
add a page-range to the exponential entry
index filename
or index -s indextyle filename
e.g. index -s plan
creates an index file for plan.tex using the style


Mathematics fonts

CALLIGRAPHIC; only uppercase letters
Blackboard BOLD; only uppercase letters
Zapf chancery
Text inside math formula

Text fonts

Small caps
emphasized (italics)

Font sizes


Math operators, spacing and dimension

normal symbol (eg. a)
binary operator
\mathopen \mathclose
\left \middle \right
size changing symbols
\bigl \bigm \bigr
large size symbols

For example

(1) parentheses of variable height
(1) big parentheses
[1] parentheses of variable height
[1] big parentheses

Citations and references

create a new label
insert a reference to the label
insert a reference to a bibliographical item
insert the bibliography from the surreals.bib database
uses the abbrv style for the bibliography
insert label1 an label2 works in the bibliography, even if not actually cited in the text
inserts all works in the database
bibtex filename.tex
print a table of contents
add the chapter Index to the table of contents. E.g.
will create an index and put the entry Index 117 in the Table of Contents (if, say, the index appears at page 117). You might want to use \cleadoublepage instead of \clearpage. Sometimes, no \clearpage is needed.
Thank to Jan Somorcik for a correction.


\hyphenation{Ar-chi-me-dean De-de-kind sche-ma-ta}
tell how to hyphenate Archimedean, etc.
define the \hyph command (using the amsmath package). \hyph prints a hyphen that does not prevent hyphenation.
E.g. non\hyph Archimedean $p$\hyph adic prints non-Archimedean p-adic and can be now hyphenated normally


print in output the definition of the command \commandname
print a space if necessary. E.g. \newcommand{\namely}{namely\xspace}
\namely x=y
prints namely x=y
\namely, x=y
prints namely, x=y
note that the spacing is correct in both cases.
There is a problem if before \xspace there is a point: TeX puts some extra space after a point. You can either use \frenchspacing to get rid of this space everywhere. Or you can disable it with \newcommand{\ie}{i.e.\@\xspace} or \newcommand{\ie}{i.e\mbox{.}\xspace} Ulrike Fischer.
Back to homepage
Valid XHTML 1.0! Valid CSS!
Please write me if you have suggestions, find mistakes and/or some links are not working.

My e-mail address is fornasiero at
This page address:

Last modified: Mon Jan 9 12:02:43 CET 2012 by A. Fornasiero