Jeremy Sanders
October 2011
I'm not going to give a complete introduction to LATEX here: I am leaving that to books and the short reference guide I have given to you. It can be quite a complex program and few people understand it fully, however with limited knowledge you can achieve quite a bit.
If the latex command prints out that it should be run a second time, you should do that. It prints messages like:
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.latex needs to be run more than once to fix up references (stored in the .aux file) (as it only processes the text forwards). Some documents may need to be processed three times.
To get A4 paper output in ps2pdf, use ps2pdf -sPAPERSIZE=a4 paper.ps
Here are examples
# use inpaper.tex to generate inpaper.ps latexmk -ps inpaper # use inpaper.tex to generate inpaper.pdf using pdflatex latexmk -pdf inpaper # use inpaper.tex to generate inpaper.pdf using dvips then ps2pdf latexmk -pdfps inpaper # every time inpaper.tex changes regenerate inpaper.ps # open up a viewing program to view inpaper.ps and tell # it to update when inpaper.ps changes latexmk -ps -pvc inpaper
! Undefined control sequence.
l.84 \ssassasaq
?
The text after the ``!'' is a message explaining what the problem
is. The next line shows the line with the problem, shown after the
line number (printed l.linenumber, here the 84th line of the file). At
the prompt you can do various things. Quite often you should press
x[enter] to stop processing, and then you will go back to the original
document and fix it. You can optionally continue by pressing [enter]
(press ``?'' for other options).
% the first line specifies what sort of document it is
% (here article) and options
% article specifies the `style file'
\documentclass[a4paper,12pt]{article}
% now we include various packages to get extra features
\usepackage{times} % get times font
\usepackage{graphicx} % allow us to insert figures
% you could get wider margins with something like
% \usepackage[a4paper,margin=2cm]{geometry}
% now we start the document
\begin{document}
% optional abstract
\begin{abstract}
hi there
\end{abstract}
% set what is going to go into the title
\title{Document structure}
\author{Jeremy Sanders}
\date{October 2011}
\maketitle % actually put the title in the output
\section{This is a section heading}
Here is some text below that heading
\subsection{A subsection}
More text. Here is some text. blah blah
blah blah. More text.
A different paragraph...
% now we end the document
\end{document}
In fact, most of this is optional. The shortest document is similar to:
\documentclass{article}
\begin{document}
Hi there!
\end{document}
PDFLaTeX supports JPEG (good for photographs), PNG (good for line diagram/solid colour bitmaps) and PDF (good for line diagrams/figures) figures. You can convert EPS figures to PDF using ps2pdf:
> ps2pdf -dEPSCrop in.eps out.pdfYou can convert EPS files to bitmaps using ImageMagick (a.k.a. the convert command) -- see the Plotting and Graphics notes:
> convert in.eps out.png
If you are using PDFLaTeX, graphicx needs to be included with the pdftex option:
\usepackage[pdftex]{graphicx}
If you are submitting to arxiv.org, then you need the line
\pdfoutput=1after the documentclass statement in the .tex file.
Figures are included normally (see the Plotting and Graphics notes), e.g.
\begin{figure}
\centering
\includegraphics[width=0.99\columnwidth]{mypicture.jpg}
\caption{My nice photo.}
\label{fig:photo}
\end{figure}
@ARTICLE{2008MNRAS.390L..93S,
author = {{Sanders}, J.~S. and {Fabian}, A.~C.},
title = "{Sound waves in the intracluster medium of
the Centaurus cluster}",
journal = {\mnras},
archivePrefix = "arXiv",
eprint = {0808.2384},
keywords = {galaxies: clusters: individual: Centaurus cluster,
cooling flows, intergalactic medium, X-rays: galaxies},
year = 2008,
month = oct,
volume = 390,
pages = {L93-L97},
doi = {10.1111/j.1745-3933.2008.00549.x},
adsurl = {http://adsabs.harvard.edu/abs/2008MNRAS.390L..93S},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
Many of these fields are not used typically, but can be useful if you
need to find out more about the paper. The text
``2008MNRAS.390L..93S'' is the name of the paper in the BibTeX
database provided by ADS by default. I always change the name given to
be more memorable, e.g. ``SandersSound08''.
You can then use your bibliography in your document in the following way:
\documentclass{article}
% the natbib package improves latex's default cite command
\usepackage{natbib}
\begin{document}
\section{Test document}
We can refer to the paper in the following ways using the natbib
bibliography package:
% write "Sanders et al (2008) is a great paper!"
\cite{SandersSound08} is a great paper!
% write "(Sanders et al 2008)"
\citep{SandersSound08}
% write "(Sanders et al 2007; Fred et al 2010)"
\citep{SandersSound08,Fred10}
% write (e.g. Fred et al. 2010)
\citep[e.g.][]{Fred10}
% write Fred et al. 2010
\citealt{Fred10}
% this section writes out the bibiliography section
% mnras is the style: requires mnras.bst
\bibliographystyle{mnras}
% refs.bib is the name of your bibtex database
\bibliography{refs}
\end{document}
The great thing about BibTeX is that you can just keep adding interesting papers to your database file. BibTeX will only put them in the references list if you use the citation in the document. It will also sort out the order of papers within the reference list and add suffixes such as ``a'' or ``b'' to the year if necessary.
latexmk -bibtex mypaper.tex or latexk -bibtex -pdf -bibtex mypaper.texNote that you may not need to use the -bibtex option if latexmk is configured to run this automatically. It is difficult to get the ordering of the commands you type in to run bibtex otherwise. If you do it by hand, you need to type at the prompt
# the latex command creates a .aux file containing the references used latex mypaper # the bibtex command creates a .bbl file containing the list of # references which appear in the references section bibtex mypaper # puts the references into the text where cite is used latex mypaper # fixes up the references if the references have moved around latex mypaper
This document was generated using the LaTeX2HTML translator Version 2008 (1.71)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 0 -font_size 10pt -no_navigation latex_intro.tex
The translation was initiated by Jeremy Sanders on 2011-10-02