LaTeX for newbies
Diese Seite auf Deutsch
Druckansicht
comments
It is advisable to insert many comments into the source code, otherwise things might get confusing. Comments are visible only in the source code and will be ignored by the compiler.Comments are inserted using the percent sign:
%
% figure x from book y, page z
%
\begin{figure}[htbp]
\centering
\fbox{
\includegraphics{filename}
}
\caption{title}
\label{labelname}
\end{figure}
This is true for all charactes which have a special meaning for the compiler.
formatting
emphasizing text
Text is emphasized using the
\emph{text}
The resulting font style depends on the context: if the text to be emphasized is surrounded by normal text, it will be italic. If the surrounding text is already italic, the emphasized text will be shown in the normal font.
Text is underlined using
\underline{text}
\textbf{text}
bold:
\textit{text}
serif:
\textsf{text}
sans-serif:
\texttt{text}
typewriter:
font size
Font size is defined in relation to normal text using the following commands:\tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \Huge
If you just want to write alter the size of a few words, you might want to use an alernative notation:
{\Large large text}
normal text
verbatim
Text written insied the verbatim-environment will be shown just as it is written in the source code. Indention, linebreaks and spacing will be visible in the output file:
\begin{verbatim}
this
text
will
look just like
that
in the output
file.
\end{verbatim}
paragraphs
Paragraphs are defined by inserting blank lines in the source file. Usually LaTeX will insert a linebreak and indent the beginning of the new paragraph in the output file. If you don't want to indent the first line of a new paragraph you have to insert the command\parindent 0pt
In order to define the height of a blank line you can use the command
\parskip 12pt
justification
Text is shown justified if no other justification command is given. In order to align the text to the left or to the right or to center it there are the following environments:
\begin{flushleft}
left-aligned
\end{flushleft}
\begin{flushright}
right-aligned
\end{flushright}
\begin{center}
centered
\end{center}
sections
Sections are separated with the commands
\section{Titel}
\subsection{Titel}
\subsubsection{Titel}
If these commands are used, you can build the contents automatically: In order to insert the contents, simply insert
\tableofcontents
wraps
linebreaks
You can force a linebreak using\\
\newline
pagebreaks
Pagebreaks are inserted using the\newpage
lists
The are three different environments for lists: "itemize", "enumerate" and "description". The "itemize"-environment is used for simple lists, where the list items are just bulleted:
\begin{itemize}
\item item 1
\item item 2
\end{itemize}
\begin{itemize}
\item[-] Punkt 1 mit Strich
\item[*] Punkt 2 mit Stern
\end{itemize}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}
\begin{description}
\item[first] item 1
\item[second] item 2
\end{description}
\begin{description}
\item[first list] a few items
\begin{itemize}
\item subitem 1
\item subitem 2
\end{itemize}
\item[second list] more items
\begin{itemize}
\item subitem 1
\item subitem 2
\end{itemize}
\end{description}
citing
quotation marks
The leading quotation mark is " ` ", the trailing quotation mark is " ' ".In order to write double quotes, you use
``text im double quotes''
`text in single quotes'
long quotations
For longer quotes or in order to emphasize important paragraphs, you use the "quote"-environment:
normal etxt
\begin{quote}
citation
\end{quote}
displacement
Horizontal space is inserted using
\hspace{x cm}
\vspace{x cm}
cross references
You define a label using
\label{labelname}.
\ref{labelname},
\pageref{labelname}
bibliography
The biblioghraphy is generated using the thebibliography-environment:
\begin{thebibliography}{------}
...
\end{thebibliography}
This is an example of how an entry in the bibliography might look like:
\bibitem[Bowie87]{bowie}
J. U. Bowie, R. L\"uthy and D. Eisenberg.
{\em A Method to Identify Protein Sequences That Fold
into a Known Three-Dimensional Structure}.
Science, 1991 (253), pp 164-170
\cite{bowie}
inserting figures
In order to insert figures, the graphicx-package has to included in the preamble (before the \begin{document}-command) of your LaTeX-document:
\usepackage{graphicx}
If you want to insert a figure, you will usually have to convert your graphics file to an EPS-file with a suitable program.
The simplest way of including a graphic looks like this:
\includegraphics{filename.eps}
If the image is not located in the same folder as the tex-file, you will have to specify the path relative to the tex-file.
If you want the image to appear in a different size, you can specifiy the size as a aprameter of the \includegraphics-command::
\includegraphics[width=4cm]{filename.eps}
The \textwidth-command is useful if you don't want to specify an absolute size but rather want the actual size to depend on the text width:
\includegraphics[width=0.5\textwidth]{filename.eps}
The "figure"-environment
You use the figure-environment to let your image appear in a "floating" environment:
\begin{figure}
\includegraphics{filename.eps}
\caption{title of your figure}
\label{labelname}
\end{figure}
The figure
\ref{labelname} on page \pageref{labelname} ..
placing figures
If figures reside inside a \figure-environment, this will cause LaTeX to choose the actual location of the figure inside the document. There are different parameters for the placement strategy:
- h (here): Try to place the figure just where the command is located.
- t (top): Try to place the figure at the top of the page.
- b (bottom): Try to place the figure at the bottom of the page.
- p (float page): Try to place the figure on a page which contains only floating elements.
If no parameter is present, the default order istbp.
The command for a figure-environment might for example look like this:
\begin{figure}[htbp]
...
\end{figure}
table of figures
A table of figures is inserted using the command\listoffigures
If you want to use different captions, you may add a parameter to the \caption-command:
\caption[caption for listoffigures]{caption inside the document}
figures with a border
There are two possibilities to place a border around figures: either only the figure itself is bordered or there is a border around the figure and its caption. You place a border around the figure using the \fbox-command.Border around the figure:
\begin{figure}[htbp]
\centering
\fbox{
\includegraphics{filename}
}
\caption{caption}
\label{Labelname}
\end{figure}
Placing a border around the figure and its title is a little more tricky: You need to place the figure and the title in a \minipage-environment which is bordered again with the \fbox-command:
\begin{figure}[htbp]
\centering
\fbox{
\begin{minipage}{13 cm}
\includegraphics{filename}
\caption{caption}
\label{labelname}
\end{minipage}
}
\end{figure}
side by side figures
You might want to place to figures side by side but use only one cpation. This is achieved by placing both figures in its own \minipage-environment which reside in the same \figure-environment.if only one \caption-command us used, both figures will have a common title:
\begin{figure}[htbp]
\centering
\begin{minipage}[b]{5 cm}
\includegraphics{filename 1}
\end{minipage}
\begin{minipage}[b]{5 cm}
\includegraphics{filename 2}
\end{minipage}
\caption{common caption}
\label{Labelname}
\end{figure}
The first parameter of the \minipage-environment determines how both graphics are aligned to each other. b (bottom) aligns the bottom borders of the figures, t (top) aligns the top borders and c aligns the centers.
If you want distinct titles for the two figures you will only have to supply a \caption-command for both \minipage-environments:
\begin{figure}[htbp]
\centering
\begin{minipage}[b]{5 cm}
\includegraphics{filename 1}
\caption{caption 1}
\label{labelname 1}
\end{minipage}
\begin{minipage}[b]{5 cm}
\includegraphics{filename 2}
\caption{caption 2}
\label{labelname 2}
\end{minipage}
\end{figure}
If you want to have subfigures with distinct caption, you use the \subfigure-command:
\begin{figure}[htbp]
\centering
\subfigure[subcaption 1]{
\label{labelname 1}
\includegraphics{filename 1}
}
\subfigure[subcaption 2]{
\label{labelname 2}
\includegraphics{filename 2}
}
\caption{common caption}
\label{common label}
\end{figure}


