Tag Archives: documentclass

Left equation numbering

By default, equation numbers are place on the right side of an equation for any numbered math environment, such as equation, eqnarray, and align. Surprisingly, the equation number position can is changed through the optional documentclass argument leqno:

Left numbering

\documentclass[leqno]{article}

Right numbering (by default and therefore usually skipped):

\documentclass[reqno]{article}

Here is a minimal working example:

\documentclass[a4paper,12pt, leqno]{article}
\usepackage{amsmath}
\begin{document}
\subsubsection*{Equation:}
\begin{equation}
	f(x)=ax^2+bx+c
\end{equation}
\subsubsection*{Align:}
\begin{align}
	f_1(x)&=a_1x^2+b_1x+c_1\\
	f_2(x)&=a_2x^2+b_2x+c_2
\end{align}
\end{document}

Align is part of the amsmath package which was used here because there are several reasons to avoid eqnarray.


Beamer: An introduction to LaTeX presentations

Beamer is a LaTeX document class that provides extensive functionality to create presentations. Here, I will only show the basics and after reading this guide you will be able to create a simple presentation in LaTeX. I am aware there are a lot of tutorials available out there and this is not different from any other tutorial. I hope however, I can encourage some of you who have hesitated so far, for whatever reason, to create your next presentation with LaTeX. And I’m sure it will be a lot of fun, with similar effort. I should add that the output will obviously be a PDF file (with all its advantages!). Luckily, PDF-viewers (including Adobe Acrobat) provide a fullscreen-mode for presentation purposes.

So lets get started!

\documentclass{beamer}

Now that line is straight forward, not much to say about it. Once that’s done, we have to choose a theme. This website gives a visual overview of the most common themes. I like Singapore:

\usetheme{Singapore}

Next, still in the preamble, we prepare the title page, using a similar set of commands as for other document-classes:

\title{Your Presentation Title}
\author{The author}
\date{February 4, 2011}

A frame may have one or several slides. Since PDFs are static, dynamic “effects” such as adding more content to a frame are achieved by two consecutive slides in the output file.

We use the previously defined title page to create our first (single-slided) frame:

\begin{frame}
\titlepage
\end{frame}

Similar to articles, sections, subsections, etc. are available and can be used to define an outline, printed with \tableofcontents. For many themes, the outline will be displayed in the header/footer and provides direct access to a certain section of the presentation. Frame-titles are created using \frametitle{Title}.

Most of the time, a frame will show a list of items created through the well known itemize-environment:

\begin{frame}
\frametitle{Title of the Frame}
\begin{itemize}
\item First item
\item Second item
\item ...
\end{itemize}
\end{frame}

Now what if you don’t want to show all the items at once, but one after another. The \pause-command will take care of it. Just add it anywhere you want to “pause” and will produce 3 slides. In presentation mode, the next bit of information is only shown after you press a key (usually space or arrow keys). So the above code example now looks as follows:

\begin{frame}
\frametitle{Title of the Frame}
\begin{itemize}
\item First item \pause
\item Second item \pause
\item ...
\end{itemize}
\end{frame}

Figures are used similarly as within other document-classes:

\usepackage{graphicx}
...
\begin{figure}
\includegraphics[scale=0.5]{img.jpg}
\caption{Sample caption.}
\end{figure}

Finally, I will show you something a little more advanced. Two columns, with items on the left and figures on the right side. The idea is to show an item along with an image. We want one item after the other to appear, while the image replaces the previous. Let me give you the code first and then explain some of the details:

\begin{frame}{A More Advanced Example}
\begin{columns}
\begin{column}{5cm}
\begin{itemize}
\item<1-> Figure 1
\item<2-> Figure 2
\item<3-> Figure 3
\end{itemize}
\vspace{2cm}
\end{column}
\begin{column}{5cm}
\includegraphics<1>[scale=0.1]{img1.jpg}
\includegraphics<2>[scale=0.1]{img2.jpg}
\includegraphics<3>[scale=0.1]{img3.jpg}
\end{column}
\end{columns}
\end{frame}

What’s new here is called overlay specification within an environment (itemize) and lets you display different text/content on different slides or a range of slides.

<1-> indicates that this item will be displayed from slide 1 onwards in this frame. We could also have used <1-3>. Whereas the actual figures will only be displayed on their specific slide, e.g. <1>.

If there is no environment, the set of things to display has to be enclosed by the overprint-environment:  \begin{overprint}...\end{overprint}.

Another thing is the “overlay specification” for commands, e.g. to change the text-color for slides 2 and 3:

\color<2-3>[rgb]{1,0,0} This text is red on slides 2 and 3, otherwise black.

Here, the overlay specification always has to follow the command before any additional arguments. I have to admit, slightly useless, but at least it illustrates the result nicely (example was taken from the user guide page 81).

The following a complete code sample with a few frames containing the various examples described above:

\documentclass{beamer}
\usepackage{graphicx}
\usetheme{Singapore}
\title{Presentation Title}
\author{The Author}
\date{May 4, 2011}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}
\section{List of Items}
\begin{frame}
\frametitle{List of Items}
\begin{itemize}
\item First item \pause
\item Second item \pause
\item ...
\end{itemize}
\end{frame}
\section{Figure Example}
\begin{frame}
\frametitle{Figure Example}
\begin{figure}
\includegraphics[scale=0.1]{img1.jpg}
\caption{Sample caption.}
\end{figure}
\end{frame}
\section{Overlay Specification}
\begin{frame}
\frametitle{Overlay Specification}
\begin{columns}
\begin{column}{5cm}
\begin{itemize}
\item<1-> Figure 1
\item<2-> Figure 2
\item<3-> Figure 3
\end{itemize}
\vspace{3cm}
\end{column}
\begin{column}{5cm}
\includegraphics<1>[scale=0.1]{img1.jpg}
\includegraphics<2>[scale=0.1]{img2.jpg}
\includegraphics<3>[scale=0.1]{img3.jpg}
\end{column}
\end{columns}
\end{frame}
\end{document}

The packages hyperref, xcolor, color are automatically loaded when using the beamer class.

A comprehensive user guide can be downloaded from CTAN.


Using draft to determine overfull hboxes

Latex provides a draft-mode as an optional argument to the document class, having two main effects on the whole document.

Draft is an optional argument of the document class and is therefore used as follows

\documentclass[draft]{...}

The two main effects mentioned before are:

  1. Marking overfull hboxes (no line-break within the margin) by a vertical line, helping to locate overfull hbox warnings. This affects text, but also figures and tables.
  2. Embedded images are not displayed in the generated PDF. Instead only an outline including the file path is shown.

A similar effect as the latter can also be achieved by drafting the graphicx package (\usepackage[draft]{graphicx}).


Creating two columns in article, report or book

Three different styles have to be distinguished when creating multiple columns in a Latex document. Either we want the whole document to have two columns, single pages or only part of a page. In order to do so, three different Latex commands are used…

Whole document (using article to write a paper):

The only thing you need to do is changing the first command of your Latex-file.

\documentclass[11pt,twocolumn]{article}

It will automatically create two columns in the entire document.

Note: if you are writing a paper, IEEE provides useful templates which can be used and adapted to your needs. You can download them from their “Author Digital Tool Box“.

Single pages:

The command \twocolumn starts a new page having two columns. Accordingly, \onecolumn starts a new page with a single column assuming you are in a two column environment as described above. Both commans do not take any arguments.

The is a way to define the distance between the two columns, use

\setlength{\columnsep}{distance}

If you need a line to separate the columns, the following command will do the job:

\setlength{\columnseprule}{thickness}

Part of a page:

I have posted another article on that, just have a look there. \minipage can also be used for text, not only for figures and tables.


\documentclass{book, report, article or letter}

A LaTeX document starts with the command \documentclass [option] {type}. The most common document-classes in LaTex are:

  1. book
  2. report
  3. article
  4. letter

All of them are similar, except letter. The main differences can be summerised as follows:

  • An “article” does not provide “chapter”, whereas “book” and “report” do. Thus, the first structuring element of an “article” is \section{name}.
  • In a “book”, a header is automatically added to each page indicating the page number as well as the chapter name on even pages and the section name on odd pages
  • A “book” is always 2-sided whereas in a “report” or “article” you have to specify it by using the “twoside” option. In addition, in a “book” and “report” the “titlepage” and “abstract” will take a whole page each, which is not the case for “article”. In an “article”, you can use the options “titlepage” and “abstract”.
  • The “letter” provides a US-type letter format.

Available document structure commands:

Book: \part{}, \chapter{}, \section{}, \subsection{}, \subsubsection{}, \paragraph{}, \subparagraph{}.

Report: \part{}, \chapter{}, \section{}, \subsection{}, \subsubsection{}, \paragraph{}, \subparagraph{}.

Article: \part{}, \section{}, \subsection{}, \subsubsection{}, \paragraph{}, \subparagraph{}.

Letter: A letter does not know the same structuring commands as other formats, but more specific commands like \signature{}, \address{}, \opening{} and \closing{}.

Except \part{}, all structuring commands build a hierarchy. They have a standard formating and numeration.

Other less common document-classes:

  1. “proc” for a protocol (two columns by default and smaller borders on the left and right)
  2. “slides” for a presentations
  3. “minimal, a prototype for your own document type

You can always change the standard document types, by adapting the *.cls-file to your needs.


Follow

Get every new post delivered to your Inbox.

Join 316 other followers