This page has moved to
https://wiki.iac.ethz.ch/Public/DissLatex
Remark This document is original written in German
. Because of the success, i decided to translate it to English, but I've to say, that my English isn't very good, sorry. I would be glad about some corrections.
Dissertation with Latex
This isn't a Latex-help in the common sense. But it should help by some specific things around using Latex for writing a dissertation (PhD-Thesis) and other similar documents. The layouts correspond to the styles of the ETH and/or IACETH (the institute where I'm working), but it shouldn't be a problem to use other styles.
At the bottom you will find some examples (which are still in German), which shows and explains the most things.
Computer specific things are related to UNIX/Linux
content
Preparation
Files for Latex may be edited be any text editor. Some of them give special advantages like highlighting of syntax structure. A good one is Xemacs or his brother Emacs. Both are a little bit cryptic but are very fast if you understand them. The same thing is also true for Latex itself.
Many things in latex are outsourced. In this case you have to explain your computer where it can find the different things (eg.: style files). The following settings should work on the IACETH and explain how you have to configure your computer (if it is a UNIX/Linux machine.
- Unix
- Add the following settings to the file ~/.login and do a re-login after it. Probably the settings will also work in files like .cshrc or so.
- Linux
- The environment variable TEXINPUTS needs the following entries: /usr/local/lib/tex/inputs and /home/yourname/tex
structure
It's a good idea to have a short main document. For this you can out-source the single chapters into own files with the command \include{file.tex}. The outsourced files may also contain an other \include statement.
Attention: a imported file always produce a page break!
special chapters
Index
To create an index you need the following things.
- the package makeidx
\usepackage{makeidx}
- Some entries like
The Matterhorn\index{Matterhorn} is a famous mountain in Switzerland.
The text inside the brackets isn't displayed, it is only used for the index. In this case you have to rewrite the word twice (what is sad), on the other hand you can use another form of it (like a singular) for the index-
- The program makeindex. It needs the name of the main Latex file as argument (without the extension .tex)
- At the place, where the index should appear
\printindex
- A three-time compilation (one time before makeindex twice after), see also create
references
You need:
- An information about the layout of the references (inside the document statement)
\bibliographystyle{plain}
where plain may be replaced by many different ref-style files. Some of them are defined by default for all the others you need a refstyle.bst file. Remark: Inside the \bibliographystyle statement the file name is written without the extension .bst.
- The program bibtex, which need the name of your main Latex-file as argument (without the extension .tex.
- Of course a catalog of references itself. To create this you have at least three different ways available:
- Do anything manual, where the example should explain the syntax by itself.
Remark: the editor Xemacs knows the bibtex syntax
- Directly inside the Latex-File where
\begin{thebibliography}
\bibitem{ref}The name of the reference
\end{thebibliography}
is used.
- With the tool wos2bib (by Jörg Mäder),
which is able to convert the output from web of science:
- Collect your references at Web of Science (Mark the papers at the left and press submit marks, repeat as often as necessary)
- Go to the page marked list (Button is at the top).
- Check the option document type (and others if you want).
- Click save to file to create a file on your computer.
- Start wos2bib with the name of the new file as argument and add the output to your current bibtex file
wos2bib savedrec.txt >> diss_ref.bib
At the first call use > instead of >>
- Edit diss_ref.bib if necessary
wos2bib:
C-Source
UNIX
Linux
- wos2bib is also available as Online-Tool, which contains more features.
- Some references in your .tex-files
\cite{ref}
where ref is mostly composed by the first name of the first author and the year of publication (eg:Tell:1291).
- A Link to the reference collection inside the document statement)
\bibliography{diss_ref}
which will create the reference index
Remark: Also here .bib is not used. Multiple files may be separated by comma (without spaces between).
- A three-time compilation (one time before makeindex twice after), see also create
cross references
With \label{name} you can mark any kind of object (or location). After that you can use \pageref{name} to refer to the page of the named item or \ref{name} for the chapter-numbering (or figure/table if it is used inside their environment).
content, table and figure index
Just include \tableofcontents, \listoftables resp. \listoffigures at the place where it should appear.
Create / Compilation
Latex don't use any kind of WYSIWYG behavior. You just edit the pure code. After that you have to compile the whole thing to have the final document. For that you need some additional programs (which are mostly installed on many UNIX/Linux systems). The following command sequence (UNIX/Linux) should give you the result your looking for. Be careful where the file extensions are necessary and where they are not allowed!
| 1. |
latex diss_main.tex |
first compilation |
| 2. |
bibtex diss_main |
create the reference index |
| 3. |
makeindex diss_main |
create the index |
| 4. |
latex diss_main.tex |
second compilation (insert the references) |
| 5. |
latex diss_main.tex |
third compilation (page numbering) |
| 6. |
dvips -odiss_main.ps diss_main.dvi |
convert from dvi to postscript |
| 7. |
gv diss_main.ps |
look at the new postscript |
| 8. |
dvipdf diss_main.dvi diss_main.pdf |
convert it to .pdf |
The file names refer to the examples which is available under documents.
Remark
- For printing with a postscript printer use the file diss_main.ps, for a online version (or for email) use diss_main.pdf instead.
- Creating a .pdf: the command pdflatex has some troubles with postscript pictures, ps2pdf has some troubles with special characters (like German ä), dvipdf seems to work well.
Tips
- Movable objects (like the most pictures) are hardly controllable on Latex in kind of positioning.
- With the command \FloatBarrier (from package \usepackage{placeins}) all moveable objects will be displayed before this command.
- The package \usepackage{float} introduces a new positioning flag H additionaly to the current one (h, t, p ...). This flag will display the object at the exactly same place as it is in the tex-script.
- If instead of a long title a shorter version should appear in the indices (like table of content but also in a page header) you should use the following syntax (showed for section)
\section[short Version]{The beautiful but incredible long title of the following chapter}
- A basic formatting can be provided with \frontmatter (for the preamble), \mainmatter (main part of your document), \backmatter (for the acknowledgment and curriculum vitae).
- Formatting
- Basics
- Fonts are primary divided in serif and sans-serif, where serif are the small lines at the end of a character. Serif fonts looks better, sans-serif fonts are better readable if they are small.
Example: serif in opposite to sans-serif
- Another difference is the width of the characters. Normal text is written in proportional fonts (where the M needs much more space than the I). Fonts with constant width (mono-space) uses the same space for all letters (and symbols general). They are mostly used in programming, some kind of tables and equations. The advantage is th implicit formatting of the font.
Example:
| proportional width |
constant width |
MMMMM IIIII |
Jan. 124 Mar. 880 |
MMMMM IIIII |
Jan. 124 Mar. 880 |
- Text in Italic is a good method to mark a text. Bold should be used rarely, because is very eye-catching (but it is widely used in titles). Underlining shouldn't be used. This formatting comes from the typewriters and other handwritten documents (where other styles are more difficult to create).
- Captions and legends of figures and tables should be different from the normal text, so that it is easy to recognize which is which. Normally they are using smaller font sizes and are align centered. The legends is set in italic, title and numbering is not
- The default font of latex is Computer Modern. To use a differnet font you have first to load the font ans specify the familydefault if necessary. Here the code for the three most common fonts:
- Times
- \usepackage{times}
- Helvetica
- \usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
- Courier
- \usepackage{courier} \raggedright
\renewcommand{\familydefault}{\ttdefault}
In the second step you have to set the new default font using the comand \fontfamily{abr}\selectfont if the new font should be used for the whole text following or {\fontfamily{abr}\selectfont Some Text} just for the text in the breaces. abr is the abbreviation of the font family. The most often used are ptm (Times), phv (Helvetica), pcr (Courier), pbk (Bookman), pag (Avant Garde), ppl (Palatino), bch (Charter), pnc (New Century Schoolbook), pzc (Zapf Chancery), put (Utopia ).
- variable names: italic and serif fonts, example: Times New Roman). Use $Name$, to do this. Inside caption and so, which are already italic you have to reverse it ($\rm Name$).
- Equations: Serif fonts. Use \rm inside the math-environment to get it. At eqnarray you have to repeat \rm at each line.
- If the content and preamble shouldn't be counted for the chapter numbering you can use the command \setcounter{chapter}{0} before the first chapter to count.
With \setcounter{enumi}{5} you can change any kind of number items by using the right items inside the brackets.
- If there some chapter numberings look like 3.0.1 you forgot to start the chapter of the upper level. As example you used subsection before using a section.
- For a series of equations the environment eqnarray is useful. In this case you need some fine tuning for numbering. The following example should explain the most of it.
| Latex code | result |
\begin{eqnarray}
&&\mathbf{HO_X-Cycle} \nonumber \\*
\rm OH + O_3 &\rightarrow& \rm HO_2 + O_2 \nonumber\\*
\rm HO_2 + O &\rightarrow& \rm OH + O_2 \nonumber\\*
\rm O_3 + h\nu &\rightarrow& \rm O + O_2\nonumber\\*
\cline{1-3} \mathbf{2O_3 + h\nu }&\rightarrow& \mathbf{3O_2}
\end{eqnarray}
|
| | | HOx - Cycle | |
| OH + O3 | → | HO2 + O2 | |
| HO2 + O | → | OH + O2 | |
| O3 + hν | → | O + O2 | |
| | |
| 2O3 + hν | → | 3O2 | (2.3) |
|
- The package mhchem is
useful for chemical reactions, since it may handle things like \ce{C + H2O <=> CO + H2} directly.
- Postscript-files are the only (god) way to include pictures. There are two ways: .ps are the classic one, where information about the page (eg: it's a A4-page) is included (in this case they are ready to print); .eps is the other one, where no page information is included but a as called bounding-box, which defines a border around the objects. It isn't difficult to change this bounding-box with a text-editor.
- To see only a part of the postscript figure you can cut it directly inside Latex.
\includegraphics[clip,viewport=35 130 590 490]{epsfile.eps}
- To change the orientation of a Postscript file use.
\includegraphics[angle=-90]{psfile.ps}
- Zooming is also provided, where you can use all kind of lengths which are available in Latex.
\includegraphics[keepaspectratio,width=\columnwidth]{psfile.ps}
The example dissertation includes to all used packages a small explanation.
Commands
Latex allows to simplify things which are used often. It's a decision of style how often you will use this things. Very often they make it harder to read the code of the document (especially after a break of some month or for other person which see it the first time). On the other hand they make it easier to create a consistent layout.
All this commands are defined before the \begin{document} statement. It's also a good idea to export them to an own file an import them with \input{comdef.tex}
Here some tips and examples
- If Latex fails by some hyphenation you can explain them to Latex.
\hyphenation{syllable-syllable}.
- Often used words can be replaced by short ones.
eg: \newcommand{\IOLU}{International organized latex users\xspace}. Inside the text you need only to write \IOLU instead of the whole thing. The \xspace at the end needs the package xspace(\usepackage{xspace}) and handles the problems with space at the end of \IOLU. Don't define hundred of shorts in this style. Your text won't be readable. Another advantage is the uniform formating of all occurrence of them (\newcommand{\brand}{\textit{brand}\xspace}).
- For an identical figure style use a command like this:
\newcommand{\myFig}[5][\columnwidth]{
\begin{figure}[htbp]\begin{center}
\includegraphics[width=#1]{#2}
\caption{#3}
\label{img:#5}
\small{\textit{#4}}
\end{center}\end{figure}
}
It uses 5 arguments, where the first one is optional: Width of the figure (default: column-width). name of the file, title, caption and reference name (where img: is added by default, to prevent duplicated names).
Example \myFig[5cm]{psfile.ps}{Overview}{This picture show everything}{everything} or without a given width \myFig{psfile.ps}{Overview}{This picture show everything}{everything}
If you define also \newcommand{\fig}[1]{Figure \ref{img:#1}} you can refer the picture just by using \fig{everything} (In the text figure 6 will appear as example).
The advantage of this two commands is that you can change the layout of all pictures just by changing the command definition.
- A little bit more complicate is newenvironment but it allows also more complicate things, because you may embed whole text passage.
\newenvironment{myTab}[3][]
{\begin{table}[#1]\begin{center}\caption{#2}\label{tab:#3}\vspace{3mm}}
{\end{center}\end{table}
}
Defines a environment for tables. The arguments are position (optional), title and reference name ( with an additional tab:
\begin{myTab}{the results of my work}{reswork}
Caption of the table, the table itself ...
\end{myTab}
Tips Windows
Based on notes by R. Schefold
- Download and install mikTeX on your system.
- Download and install WinEdt. Memeber of the IACETH may ask Hans Hirter for a serial number.
- In WinEdt, choose Options->Configurations->MikTex direct!
- Open the file main tex file in WinEdt
- Compilation
- full compilation: 2x Latex, 1x Accesories->BiBTex, 2x Latex.
- fast preview: 1x Latex.
Instead of WinEdt the TeXnicCenter from toolscenter.org can be used.
Links
|
|
- Overhead slides with the package beamer (by Andrew Mertz and William Slough).
- Font selection (by Walter Schmidt).
|
documents
| common | ETH-files |
|
|
|
| bibliography (.bst) | example dissertation (German) |
|
|
|
Poster with Latex
Based on notes by Mark Liniger.
- necessary files: a0poster.cls and a0size.sty (copy directly to your Latex files will work well). The class a0poster is based on article.
- document settings
\documentclass[a0,portrait]{a0poster}
- instead of portrait landscape will too (default)
- The following sizes are allowed: a0b a0 a1 a2 a3, where the first one is default.
- With draft the pictures are replaced by empty borders in the right size.
- Reuse latex and dvips
- For a A4-preview
pstops -h1189mm -w841mm "1:0@.25" < poster_a0.ps >! poster_a4.ps