LaTeX
LaTeX is the default standard for formatting documents in astronomy. Journals
now generally also accept Microsoft Word as well as LaTeX, but the use of
LaTeX is extremely widespread. Note that LaTeX differs from Word in that it is
not WYSIWYG; it gets processed from an input file into an output format
(usually PDF).
Note that LaTeX is an extension of the more fundamental TeX, but it is rare
to see pure TeX used these days.
Basic LaTeX: source file with extension .tex, that includes:
- \documentclass{class}, e.g., article, letter, book, others (see AASTeX below, which provides aastex and emulateapj)
- Preamble
- package setup: \usepackage{package}, e.g. graphicx, amsmath, hyperref, color
- command aliases, e.g., \newcommand{\mh}[0]{[M/H]}
- \begin{document}
- \section{title},
\subsection{subtitle},
\subsubsection{subtitle}
- text formatting: \textit, \textbf, etc
- math mode (e.g., reference: $ and $$, superscript, subscript, greek letters, math symbols, etc. (note use
in iPython notebooks!)
- various environments:
- itemize, enumerate : lists
- tabular : tables
- center : positioning
- figure, table, equation: ``numbered" environments
- Figures with \usepackage{graphicx}, \includegraphics
\begin{itemize} % Use enumerate for numbered list
\item Item 1
\item Item 2
\end{itemize}
\begin{figure}
\includegraphics[width=0.5 \textwidth]{cfig.pdf}
\caption{caption here}
\label{fig:cfig} (see below)
\end{figure}
Refer to Figure \ref{fig:cfig} in the text to automatically get the correct number!
\begin{table}
\begin{tabular}{llcr}
obj1 & data1 & text1 & number1 \\
obj2 & data2 & text2 & number2 \\
\end{tabular}
\label{tab:data}
\end{table}
Refer to Table \ref{tab:data} in the text to automatically get the correct number!
- \end{document}
AASTeX:
documentclass for astronomical publications, e.g., aastex, emulateapj.
deluxetable environment for tables (including multi-page). See
authors guide .
Labels for numbered objects
To allow for arbitrary moving/addition/deletion of figures, tables,
sections, etc., do not build in numbering into the text. Instead use the
\label{labelname} command to label each entity,
and automatically reference the correct numerical identification using
\ref{labelname}. Note that using these will require
two passes through latex, to register the labels correctly. Note that, in the
figure environment, the label command must come after the caption command!
References in LaTeX
Instead of building in explicit references in text, perhaps
repeating multiple times, and then adding full reference in reference section,
use bibitems: create the reference once, give it an identifier, and reference
it in the text by the identifier using \citep, \citet,
\citealt (the natbib package provides an extension beyond
the standard LaTeX commands). You can
create the bibitem manually (\bibitem{identifier} reference), or, better
yet, use BiBTeX reference information (available from ADS!) and automatically
create the bibitems.
- manual bibitem: \begin{thebibliography}, \bibitem...., \end{thebibliography}
- bibtex: create reffile.bib file with bibtex entries (e.g., this file), use
\bibliography{reffile} in latex file, then latex file, bibtex, latex file, latex
file to put it all together. See discussion on ADS; for astronomical journal reference style, you
may want to use the apj bibliography style, using the apj.bst
or perhaps the newer
aasjournal.bst
file.
Refer to an article inline (with year in parenthesis) using \citet{id}. Refer
to an article where author and year are both in parenthees using \citep{id}.
\bibliography{ref} % at end of document
Reference for putting it all together
For examples of everything, see the AASTEX authors guide .
``Compiling" LaTeX
Convert a .tex file into PDF:
pdflatex file
Using bibtex, sequence is: prepare a doc.text file with the document and a ref.bib
file with a bunch of BibTeX entries (e.g., from ADS), then:
pdflatex doc
bibtex doc
pdflatex doc
pdflatex doc
Can use a Makefile to simplify!
latex editors/environment: kile. On line resources for sharing/editing/viewing
LaTeX: sharelatex /
overleaf ,
authorea , etc.
spell checking: aspell, hunspell. ALWAYS SPELL CHECK YOUR DOCUMENTS
Practice: create a LaTeX document. Add tables, figures, references, etc.!