Tools for Scientific Writing with LAT E X Johan Carlson Luleå University of Technology Dept. of CSEE EISLAB Email: johanc@csee.ltu.se Tools for Scientific Writing Lecture no. 2 1
Last lecture What is L A T E X? Setting up a working environment. A first document. Sectioning of a document. Labels and references. Placing figures. Tools for Scientific Writing Lecture no. 2 2
Today s menu Bibliography references \bibitem The BIBTEX database system. Writing equations. Simple equations. Useful packages. Tools for Scientific Writing Lecture no. 2 3
Bilbliography references Citations can be added in two ways: 1. \bibitem Manually add bibliography lists at end of a document. Manually typset the list. 2. BibTeX databases. All references are stored in a database. The list is automatically generated and typset according to a BibTeX style file (.bst). Tools for Scientific Writing Lecture no. 2 4
The \bibitem method The thebibliography environment defines a list of references, a \bibitem list \begin{thebibliography}{widest_entry} \bibitem[label1]{cite_key1} Bibliographic information \bibitem[label2]{cite_key2} Bibliographic information... \end{thebibliography} The widest entry is a text specifying the largest number in the bibliography list. The label is optional, but specifiec how the list items are labeled. Default is a number in square brackets [1]. Tools for Scientific Writing Lecture no. 2 5
The \bibitem method (continued...) An example of a \bibitem list \begin{thebibliography}{99} \bibitem{doe01} J.\ Doe, "A journal paper," \textit{the Journal}, vol.\ 78, no.\ 8, pp.\ 1155--1157, 2001. \bibitem{doe02} J.\ Doe, "Another journal paper," \textit{the Journal}, vol.\ 79, no.\ 1, pp.\ 1--5, 2002. \end{thebibliography} Tools for Scientific Writing Lecture no. 2 6
BibTeX databases With \bibitem lists, the references have to be typeset manually. Since the style is different for different conferences and journals, this is not very effective. A better way of managing bibliography references is the BibTeX database system. All references are stored in a database file, and the reference list is created automatically, and typset according to a specified template. Tools for Scientific Writing Lecture no. 2 7
The BibTeX database The entries of the BibTeX file (a text file) consist of three parts: An entry type, e.g.: book, article or inproceedings. A user chosen keyword identifying the publication. If you want to cite a publication, the cite key of the \cite command should be identical to this keyword. A series of fields consisting of a field identifier and its data. Tools for Scientific Writing Lecture no. 2 8
A BibTeX entry Many editors (e.g. WinEdt, Kile, and Emacs) have built-in functions for BibTeX entries. Also, see the book (reference on course web page). This is an example of an article entry: @Article{BSF01, author = {M. Burns and H. Simpson and N. Flanders}, title = {Life in Springfield}, journal = {Fiction}, year = {2001}, volume = {1}, number = {1}, pages = {1--10}} Tools for Scientific Writing Lecture no. 2 9
Citing a reference To cite a reference, use the \cite{key} command, where key is the reference key specified in either the BibTeX database entry or in the \bibitem list entry. Tools for Scientific Writing Lecture no. 2 10
Using BibTeX in your document \documentclass[a4paper,titlepage,11pt]{article} \usepackage{...}... \bibliographystyle{plain}... \begin{document} Life in Springfield is described in \cite{bsf01}...... \bibliography{mybib_db} \end{document} Tools for Scientific Writing Lecture no. 2 11
Bibliography styles There are numerous style files available also for BibTeX formatting. Some examples are: plain Entries sorted alphabetically with numbered labels. unsrt Same as plain, but unsorted. alpha Standard BibTeX style. Labels are formed from author s name and publication year. ieeetr IEEE Transaction style references. Tools for Scientific Writing Lecture no. 2 12
How to typeset BibTeX Once you have your database file and you wish to generate a bibliography list: Compile your document with L A T E X. Run BibTeX on your document (.aux file). Run L A T E X again, twice, to include the bibliography in the document and get the correct citations in the text. Tools for Scientific Writing Lecture no. 2 13
Organizing your BibTeX database Most L A T E X adapted editors can provide templates for the BibTeX entries, but how do I keep track of all reference keys? Is there a clever naming convention to use? Type in all your database entries in your file, and give them a unique reference key (temporary). Create a document that uses the alpha bibliography style that cites all references. The alpha bibliography style automatically labels the list items with a key constructed from the authors names and the publication year. Change all reference keys to the same as this label. In this way you can print an alphabetical listing of your BibTeX database, with the reference keys given in the margin. Tools for Scientific Writing Lecture no. 2 14
Printing your BibTeX database \documentclass[a4paper,titlepage,11pt]{article} \usepackage{a4wide} \bibliographystyle{alpha} \begin{document} \nocite{*} \bibliography{my_publ} \end{document} Tools for Scientific Writing Lecture no. 2 15
Equations Simple one-line equations are defined with the equation environment. Refer to them with the \ref{eqlabel} command. Eq. (1) is given by N n=1 \begin{equation} \sum_{n=1}^{n} \frac{1}{n} x^{2}. \label{eq:myfirsteq} \end{equation} 1 n x2. (1) Tools for Scientific Writing Lecture no. 2 16
Equation environments (continued...) A slightly more advanced example { x 1 x 2, x 1 x 2 f(x 1, x 2 ) = x 2 1 + x 2 (2) 2, x 1 > x 2 \begin{equation} f(x_1, x_2) = \left\lbrace \begin{array}{ll} x_1 - x_2, & x_1 \leq x_2\\ x_1^2 + x_2^2, & x_1 > x_2 \end{array}\right. \end{equation} Tools for Scientific Writing Lecture no. 2 17
Multiline equation environments The simplest one is eqnarray. Columns are separated with & and newline is given by \\. \begin{eqnarray} x_1 - x_2 & = & A \label{eq:line1}\\ x_1 + 2x_2 & = & B \label{eq:line2} \end{eqnarray} x 1 x 2 = A (3) x 1 + 2x 2 = B (4) Tools for Scientific Writing Lecture no. 2 18
Other multiline equation environments The amsmath package contains several multiline equation environments, with different row alignment properties. The * means unnumbered equation. multline and multline* split and split* gather and gather* See book for details. Tools for Scientific Writing Lecture no. 2 19
Inline math It is also possible to write inline math, that is, inside the text. Let us define f(x 1, x 2 ) = x 2 1 + x 2 2, where x 1 = 1... 5 and x 2 = π... π. Let us define $f(x_1,x_2)=x_1^2+x_2^2$, where $x_1=1\ldots 5$ and $x_2=-\pi \ldots \pi$. Tools for Scientific Writing Lecture no. 2 20
Tools for math writing Writing math in L A T E X can be a tedious task. Most L A T E X-friendly editors have menus or buttons that help adding mathematical symbols or environments. There are also graphical tools to draw equation and then export the L A T E X code. On a Windows system, Scientific Workplace can be used for this, although it might be a bit too advanced for most purposes. Tools for Scientific Writing Lecture no. 2 21
Homework assignments Generate a BibTeX database with your own publications and a file that prints the list with the alpha style. Write a few equations of your choice, label them and add references to them in the text. Look on the web for equation editors that can help generate the L A T E X code for your math stuff. Start thinking about a suitable final project. What type of document are you prepared to attack and convert to L A T E X (or write a new, if you don t have a good one)? Tools for Scientific Writing Lecture no. 2 22
Next lecture Tables and matrices. Presentation in L A T E X. Tweaking the layout. Assigning final projects. Tools for Scientific Writing Lecture no. 2 23