LATEX for Beginners

Sachverstand2 @ Geocities.com

15. Oktober 2005


Inhalt

1. Intro

Winword is dead! Lets create professional looking documents with Latex. Latex is bundled with every Linux distribution I know of, and is known as Latex-Life to run with windoze, too, without eating up any hard disk space.

This tutorial is as short as possible. I present only 20% of all Latex commands, because I do not use more myself. Instead, I'll show how to convert them to PDF.

1.1 Paradigma

Latex keeps track of all the layout for you.

Thus, Latex is perfect for texts with more than 10 pages.

1.2 Workstation

For Latexing with Linux you need

Boot from CD, say ''Install KDE or GNOME Workstation'', add User nemo.

X: 800x600x256 colors for 14''-Monitor, 1024x768x256 for 17''-Monitor.

Reboot, take off cd, done.

2. Your first Latex Document

2.1 Skeleton


\documentclass{article}       % this is file 1st.tex

\begin{document}
bla bla bla...
\end{document}

Each Latex document is one of five classes:

Latex files are text and Latex commands. Latex commands start with a Backslash.

Above are shown the essential commands for each Latex input file.

The part between documentclass and begin(document) is called the preamble: document-wide commands go here.

Between begin(document) and end(document) is the document.

2.2 Making it visible

You can run this through Latex with latex 1st (Latex adds the .tex where appropriate). Latex will slurp the file and create another file called 1st.dvi.

You should switch to X now. Now you can browse 1st.dvi by xdvi 1st.dvi.

dvi can easily be converted by dvips -f 1st.dvi > 1st.ps or dvips 1st.dvi (only one works). Browse it with ghostview 1st.ps.

You may convert this to pdf by ps2pdf 1st.

To create .pdf on one step, i say pdflatex 1st.tex, and get 1st.pdf.

To convert to html, i say latex2html -split 0 1st.tex, and then browse happily 1st.html. latex2html works, but its still a pain.

My Skeleton shows some more commands.

2.3 My Skeleton


% everything behind a % is a comment
\documentclass [11pt, a4paper] {article}  % an article with 11pt text size

\usepackage {german}               % switch on german hyphenation
\usepackage {umlaut}               % switch on german umlauts
\usepackage {palatino}             % switch to palatino font
\usepackage {graphicx}             % include pictures
\usepackage [margin=1.5cm] {geometry}  
  % I guess I was looking for something that allows choosing paper size
  % and margins without pain for two years. Now I found it. 

\author {sachverstand2@geocities.com}
\date   {\today}
\title  {\LaTeX\ for Beginners}    % "\ " is needed for space

\oddsidemargin=-5mm                % margins
\evensidemargin=-5mm
\topmargin=-15mm
\headheight=5mm
\headsep=5mm
\textheight=262mm
\textwidth=180mm

\pagestyle {headings}              % i want some headline on each page
\parindent 0.mm                    % no paragraph indentation
\parskip=1mm                       % space between paragraphs
\fboxsep=5mm                       % i have a crush for frameboxes
\fboxrule=0.5mm

\begin{document}

\maketitle                         % makes title automagically
\tableofcontents                   % creates toc automagically

\section{Intro}                    % there are sections, subsections...

bla bla bla bla bla bla bla bla bla bla bla bla bla bla 
...

\end{document}

2.4 Two ideas what to type for pdf output

First.

  latex test1                         # dabei kommt u.a. test.dvi heraus
  dvips -f test1.dvi > test1.ps       # konvertiert nach postscript
  ps2pdf test1.ps                     # erzeugt test1.pdf
  startx                              # startet X
  <klick>xterm                        # startet ein xterm
  xpdf test1.pdf                      # startet den pdf-viewer.
Second.

  pdflatex test1                      # dabei kommt u.a. test.pdf heraus
  startx                              # startet X
  <klick>xterm                        # startet ein xterm
  xpdf test1.pdf                      # startet den pdf-viewer.

3. Organizing the Input

For each document, you should proceed as follows:

4. Special characters


  # $ % & ~ ^ _ \ { } $ < >

4.1 Math Mode


	$$ 3_{long Index} > \frac{upper=4^{4^{44}}}{downer=\sqrt{2}} $$
gives

\begin{displaymath}3_{long Index} > \frac{upper=4^{4^{44}}}{downer=\sqrt{2}} \end{displaymath}

and

	$$ y_2 = \sqrt{ \frac{1+ \frac{2}{3} }{1- \sqrt{2}}} $$
gives

\begin{displaymath}y_2 = \sqrt{ \frac{1+ \frac{2}{3} }{1- \sqrt{2}}} \end{displaymath}

5. Centering, Frameboxes and Parboxes

5.1 Centering a Parbox

A parbox creates a chunk of text with a specified width.


\begin{center}
  \parbox{40mm}{
    A parbox creates a chunk of text with a specified width.
  }
\end{center}

gives

A parbox creates a chunk of text with a specified width.

5.2 Framebox

A framebox makes a frame around the next letter. A parbox counts as a letter.

\framebox{
  \parbox{80mm}{
    A framebox makes a frame around the next letter.
  }
}

gives

\framebox{
\parbox{80mm}{
A framebox makes a frame around the next letter.
}
}

\begin{figure}\vbox{\include{margins}
}\end{figure}

6. Tables

A Table is a float. It goes to the next page, if the current page is too short. This is specified by the option in sqare brackets. The order of the letters gives the priority. LATEX default is htbp.

If you like that, say


\begin{table}[htbp]
  % your tabular goes here
  \caption{My caption}
  \label{tab:mytable}       % tab: is good habit
\end{table}

If you dislike that, just add a tabular:


\begin{tabular}{|c|p{0.5\textwidth}}
  % this table will have bars left to both columns.
  % the first column is centered c. 
  % the second column is in paragraph mode, width = 0.5textwidth
  
    \hline
      first cell     
    & 
	    second cell. as a paragraph cell, i may make paragraphs and
      $ e^{formulae} $

    \\ \hline 

      third cell
    &
      that ampersand and double-backslash stuff has sense, but is a
      little tricky. 

    \\ \hline 

\end{tabular}

gives:

first cell second cell. as it is a paragraph cell, i may make paragraphs and $ e^{formulae} $

third cell that ampersand and double-backslash stuff has sense, but is a little tricky.

7. Lists and Enumerations

I dislike prosa like ''Latex knows section, subsection, subsubsection, paragraph.'' This is an item list (if no priority is implied) or an enumeration.

Lists and enumerations eat up much space, but make a document much more legible.


\begin{itemize}                       % a list
  \item first item
  \item second item
	
    wow! this paragraph indented correctly.
  \item another item
  \begin{enumerate}                   % nests enumeration in list
    \item first
    \item second
    \item third
		
    wow! this paragraph indented correctly, too.
  \end{enumerate}
  \item last item. remember to END enumerations and lists.
\end{itemize}


8. Pictures

8.1 Convert

Use a good picture editor (like irfanview) to convert your .jpeg and .gif to png. Or .eps.

8.2 Put into document


\usepackage{graphicx}   % needed

\begin{document}
bla bla bla...

\begin{figure}[htbp]     % htbp ist LaTeX Standard-Einstellung
  \includegraphics[width=0.5\textwidth]{serielle.ps}
  \includegraphics[width=2cm, height=1in]{serielle.ps}
  \includegraphics[width=2in, height=1cm]{serielle.ps}
  \caption{Serielle Anschl"usse an einem PC}
\end{figure}

bla bla bla...

Specifying width and height is optional, but textwidth or 0.4textwidth comes in very handy.

Abbildung: Serielle Anschlüsse an einem PC
\includegraphics[width=0.5\textwidth]{serielle.ps} \includegraphics[width=2cm, height=1in]{serielle.ps} \includegraphics[width=2in, height=1cm]{serielle.ps}

9. Happy LaTeXing!

These words you should look up in the Latex manual by Sheldon Green (free available online):

  • clearpage
  • flushbottom
  • ldots
  • vfill
  • theorem
  • input
  • footnotesize
  • onecolumn
  • hfill
  • verbatim
  • hrule
  • large
  • twocolumn
  • array
  • verb
  • paragraph
  • Large
  • pagestyle

  • description
  • verse
  • medskip
  • huge
  • rm
  • enumerate
  • bigskip
  • HUGE
  • sf
  • itemize
  • centering
  • frenchspacing
  • tt
  • quote
  • cite
  • em
  • thanks
  • quotation

Über dieses Dokument ...

LATEX for Beginners

This document was generated using the LaTeX2HTML translator Version 99.1 release (March 30, 1999)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -no_navigation -show_section_numbers -split 0 -no_parbox_images latex.tex

The translation was initiated by on 2005-10-15



2005-10-15