A blog by Rob J Hyndman 

Twitter Gplus RSS

My standard LaTeX preamble

Published on 21 March 2010

When I was a PhD stu­dent, I found I needed a lot of LaTeX func­tion­al­ity that did not then exist. So I wrote my own pack­age which has served me well for about 20 years. It is called HyTeX.sty (the name being a shame­less take-​​off of LaTeX from Leslie Lamport as well as a homonym of High-​​Tech). The advan­tage of hav­ing my own pack­age is that almost every file starts with

\documentclass{article}
\usepackage{hytex}
\begin{document}

All the other pack­ages that I use are called from within HyTeX.sty.

After 20 years of using HyTeX, I’ve decided it is time to put it to rest. Most of the func­tion­al­ity in the pack­age is now avail­able in pack­ages on CTAN, and usu­ally with more fea­tures and facil­i­ties. Fur­ther, when I work with coau­thors, I need to send them the lat­est ver­sion of HyTeX as well (as I revise it from time to time).

So from now on, I’m only using pack­ages from CTAN. These are auto­mat­i­cally avail­able to all my coau­thors so we don’t have any issue with dif­fer­ent ver­sions (pro­vided they keep their TeX imple­men­ta­tion up to date!).

An imme­di­ate con­se­quence of this is that I need to replace my stan­dard pre­am­ble. After exper­i­ment­ing a lit­tle, here is what I am now using:

\usepackage{graphicx,hyperref,amsmath,natbib,bm,url}
\usepackage{microtype,todonotes}
\usepackage[australian]{babel}
\usepackage[a4paper,text={16.5cm,25.2cm},centering]{geometry}
\usepackage[compact,small]{titlesec}
\setlength{\parskip}{1.2ex}
\setlength{\parindent}{0em}
\clubpenalty = 10000
\widowpenalty = 10000
\usepackage{kpfonts}
\usepackage[T1]{fontenc}

A few words of expla­na­tion may be in order.

  • The first line loads a lot of stan­dard pack­ages that I use all the time.
  • The latex default page size is awful, so I load geom­e­try to set up the page to some­thing more sensible.
  • The latex default sec­tion head­ings seem too large and too widely spaced to me, hence the use of titlesec. This pack­age also allows me to do a lot of addi­tional fine-​​tuning if required.
  • I pre­fer para­graphs with spaces between them and no inden­ta­tion; this is achieved by set­ting the lengths of \parskip and \parindent accordingly.
  • The set­tings for \clubpenalty and \widowpenalty pre­vent orphans and wid­ows.
  • One of my pet peeves is the US date for­mat “March 21, 2010″ which seems to me to be in the wrong order. I pre­fer “21 March 2010″ so that the time units increase in size: day month year. I fix this using the babel pack­age with the australian option.
  • Finally, I am sick of the stan­dard LaTeX font “Com­puter Mod­ern Roman”. It’s actu­ally a very good font, but it is used so much I find it tire­some. So I’m using kpfonts instead which includes a com­plete set of fea­tures includ­ing math­e­mat­ics as well as non-​​math char­ac­ters and looks a lit­tle more inter­est­ing with­out being distracting.

I’d be inter­ested to know how this pre­am­ble com­pares with the stan­dard pre­am­bles used by other LaTeX­ers.


Related Posts:


 
Tags:
7 Comments  comments 
  • http://gglanzani.wordpress.com Gio­vanni Lanzani

    I use this as my preamble

    \documentclass[a4paper,10pt,notitlepage,twoside]{article}
    \usepackage[english]{babel}
    \usepackage{graphicx,amsfonts,amssymb,amsmath,hyperref}
    \hypersetup{colorlinks=true}
    \usepackage[right%,final%
    ]{showla­bels}
    \usepackage[text={7in,10in}]{geometry}
    \usepackage{xunicode,fontspec,xltxtra}
    \usepackage{libertine}
    \newcommand{\de}{\mathrm{d}}

    Showla­bels are a very nice com­pan­ion to Auc­tex, and the xuni­code line is because right now I’m using XeTeX to use the lib­er­tine fonts.

  • http://thaitug.daytag.org Sud­chai Boonto

    \documentclass[12pt,dvips=svgnames,dvipsname,openany]{book}
    \usepackage{amsmath,amsthm,amssymb,empheq,cancel,verbatim,dsfont}

    \usepackage{ifpdf}
    \ifpdf % if use pdf­tex
    \usepackage[pdftex]{hyperref}
    \else % if use sim­ple latex
    \usepackage[dvips,hypertex]{hyperref}
    \fi

    \bibliographystyle{kluwer}
    \usepackage{natbib}
    \usepackage[left=1in, right=1in, top=1.5in, bottom=1.5in]{geometry}

    \usepackage[svgnames,dvipsname]{xcolor}
    \ifx\pdfetexversion\undefined %if using TeX
    \usepackage{graphicx}
    \else %if using Pdf­TeX
    \usepackage[pdftex]{graphicx}
    \fi
    \ifpdf %if using Pdf­TeX in PDF mode
    \DeclareGraphicsExtensions{.pdf,.png,.mps}
    \usepackage{pgf}
    \usepackage{tikz}
    \usepackage{pstricks}
    \else %if using TeX or Pdf­TeX in TeX mode
    \usepackage{graphicx}
    \DeclareGraphicsExtensions{.eps,.bmp}
    \DeclareGraphicsRule{.emf}{bmp}{}{}% declare EMF file­name exten­sion
    \DeclareGraphicsRule{.png}{bmp}{}{}% declare PNG file­name exten­sion
    \usepackage{pgf}
    \usepackage{tikz}
    \usepackage{pstricks}%variant: \usepackage{pst-all}
    \fi
    \usepackage{booktabs,subfigure,listings,isomath, aryd­shln}
    \usepackage{multirow,enumitem,pdfsync,fancyhdr}

    % Back­ref
    \usepackage[hyperpageref]{backref}

    Quite long !

  • Adel

    \doc­u­ment­class {myclc}
    \begin{document}
    .
    .
    .
    \end{document}

  • Char­lie Sharpsteen

    I typ­i­cally use the mem­oir doc­u­ment class– it inte­grates a wide range of func­tion­al­ity into one pack­age and gives me incred­i­ble con­trol over the doc­u­ments I create.

    The 500+ page man­ual is split into two parts– the first is an excel­lent trea­tise on typog­ra­phy and the sec­ond half con­tains exhaus­tively indexed and cross-​​referenced instruc­tions on how to use the pack­age. Just about every fea­ture is explained with one or sev­eral examples.

    I highly rec­om­mend it.

    In addi­tion to mem­oir, I usu­ally load up:

    * hyper­ref for link­ing and cross-​​referencing

    * nat­bib for bib­li­og­ra­phy typesetting

    * tikz for con­struct­ing and type­set­ting figures

  • karl

    My date for­mat­ting favourite:

    \usepackage[nodayofweek]{datetime}
    \renewcommand{\dateseparator}{-}
    \newcommand{\todayiso}{\twodigit\day \date­sep­a­ra­tor \twodigit\month \date­sep­a­ra­tor \the\year}

  • Pingback: LaTeX templates for Monash | Research tips

  • Peter

    you are right about the wrong order in the date. but as a math­e­mati­cian i argue that your order is still wrong. the high­est value dig­its should be left­most, so i use
    usepackage[iso]{isodate}