Textverarbeitung mit Latex

Latex ist das Textsatzsystem für umfangreichere Arbeiten. Im Gegensatz zu Microsoft Word trennt das System zwischen Texterstellung und Layout. Der Text wird in einem beliebigen Texteditor geschrieben, ohne sich zu diesem Zeitpunkt von Layout ablenken zu lassen.
Das Layout nimmt anschliessend der Latex converter vor. Abbildungen werden automatisch platziert, nicht immer direkt im Text aber dafür hat man nicht mehr die ganzen Layoutpannen wie mit Word. Mit pdflatex kann man auch sehr schüne PDF's inklusive anklickbaren Links erstellen.

Makefile für Latex und einzubindende Bilder

Bilder werden mit dem Befehle \includegraphic in ein Dokument eingefügt (siehe untenstehendes Beispiel).
Für Postscript-Dokumente müssen sie dazu im Format EPS vorliegen, für PDF als PNG oder PDF.
Ich habe ein Makefile geschrieben, das die Bilder und auch XFig Diagramme automatisch ins richtige Format umwandelt, bevor das Dokument erzeugt wird. Somit sind beide Versionen immer auf dem gleichen Stand und man kann PDF und PS Dokumente erzeugen, die genau gleich aussehen.
Hier herunterladen 21 kB, inkl. Beispieldokument.

Zur Verwendung muss Imagemagick (erkennbar am Programm convert) installiert sein, für fig Dokumente fig2dev und epstopdf.

Um Bilder korrekt einbinden zu künnen mit diesem Verfahren müssen folgende Zeilen in den Kopfbereich des Dokuments:

%%% PDF / dvi dependant defines
% Must be after all other usepackage statements, many of commands get redefined.
% Check whether we are running pdflatex or latex and set graphics extension
% accordingly. In the document, reference graphic files without extensions!

\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse % we are not running pdflatex
\DeclareGraphicsExtensions.eps
\else
\pdfoutput=1 % we are running pdflatex
\pdfcompresslevel=9     % compression level for text and image;
\pdftrue
\DeclareGraphicsExtensions.pdf,.png
\fi


\ifpdf

%%% refs also as links
\usepackage[pdftex,plainpages=false,colorlinks=false,pdfborder=0,
            pdftitle=Paper Title,
            pdfauthor=David Buchmann,
            pdfsubject=Subject for PDF description.]
     hyperref
%plainpages=false: enable links although page numbering is reset after title
%other options... backref, pagebackref (links back from index to chapter/page) urlcolor=blue,citecolor=red

\else %no pdf

%%% url can be written as url. (this works fine in dvi)
\usepackageurl

\fi %ifpdf

Um die Bilder einzuschliessen, werden die Dateinamen ohne Endung angegeben. Je nach dem, ob man das Postscript oder PDF erzeugt, versucht latex die eine oder andere Version zu finden. Damit diese Version existiert, muss das Bild im Makefile eingetragen werden (unter PDFIMAGES und EPSIMAGES), jeweils mit der passenden Endung (eps bei allen EPSIMAGES und pdf für Vektorbilder, png für Bitmapgrafiken). Ein make erzeugt das PDF, make ps das Postscript Dokument.

Beispiele

Latex ist nicht wirklich schwierig. Aber manche Dinge braucht man nicht oft und vergisst, wie sie funktionieren.
Ich habe hier ein Beispieldokument zusammengestellt, das einige Funktionen zeigt.
Es besteht aus einem Definitions-Teil und dem eigentlichen Text-Dokument. Das Ergebnis sieht als PDF so aus Beispieldokument.


Komplettes Beispiel herunterladen 21 kB.

sample.tex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
%                          Sample latex document                                %
%                          *********************                                %
%                                                                               %
% Examples of usage of the packages fancyverb, acronym, url, figure, picins     %
% and bibliography                                                              %
%                                                                               %
% Author: David Buchmann, http://www.budda.ch/                                  %
% Fribourg, 9.7.2004                                                            %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\inputdefines


\authorDavid Buchmann
\date\today

%%% text for title page. no empty lines allowed, use \\ for newlines
\title
\Large Example title page, change!\\\vspace40pt
\Huge\bf PROJECT\\\vspace50pt
Working paper at Departement of Informatics\\
University of Fribourg, Switzerland\\
\vspace30pt
\normalsize\beginflushleft
\hspace3cmReferent: Prof. Dr. Ulrich Ultes-Nietsche\\
\vspace30pt
\hspace3cmAuthor:\\
\hspace3cmDavid Buchmann\\
\hspace3cmChemin de musee 4\\
\hspace3cm1700 Fribourg\\
\hspace3cmdavid.buchmann@unifr.ch
\endflushleft



\begindocument

\maketitle

\newpage

\tableofcontents

\chapterLatex Samples

\beginListing[label=Listing 1: An Example]
a += 3;
\endListing



% put an illustration to the side of the text. Default is on the left side,
% \parpic[r] would put it on the right side.

\piccaptionA decoration figure\labelfigTest
\parpic\includegraphics[height=5cm]img/test % note that filename has no extension
\noindent % paragraphs are usually indentet. With an illustration, this would look bad
Do you know about \acXML? The word \acXML is used as an example of acronym here.
If we need it explained again, we can write \acfXML.
\acXML is defined by \citeW3C. There is also the web page
\urlhttp://www.xml.org.\\ %two backslashes force newline.
Somewhere in the document, there must be the complete acronym listing.
%\footnoteIn our sample document, it is in an appendix.
\picskip0 % The number specifies how many lines after the command should still be indented

The last paragraph was decorated with a figure on its side. It can also
be referenced: figure \reffigTest. To stop the text and continue
below the figure, you can use picskip. (Note that picskip must be standing at
the end of a paragraph, never on a line by itselves.)

We can also include images like this:

\beginfigure[ht]
\begincenter
\includegraphics[width=4cm]img/penguin % height will be scaled proportionally.
\captionThe linux penguin as sample bitmap.
\labelimgSample
\endcenter
\endfigure

You should always reference the image in your text, even if Figure
 \refimgSample is just a sample image of the linux penguin.

If you need to specify the width of your graphic relatively to the page or column width,
 you can use the length \columnwidth. If you don't want it to fill the whole width, it can
be scaled using a rather surprising syntax:
\includegraphics[width=.9\columnwidth]img/penguin.
That is, a fraction to scale the length with is just written in front of it, without any operator like *.

If you need to have more space between two paragraphs, you can put a tilde with
empty lines before and after to generate an empty paragraph.

~

The next paragraph begins further down.

To stop chapters and start the appendix, you can write appendix on a line. Then
you continue using chapter for the headings. They will be numbered A, B instead
of 1, 2, 3.

\appendix

\chapterAcronyms
\beginacronym
\acroXML  Extensible Markup Language
\endacronym

\beginthebibliography99
\bibitemW3C \urlhttp://www.w3.org/, Definition of XML
\endthebibliography


\enddocument

Komplettes Beispiel herunterladen 21 kB.

 

defines.tex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
%                 Useful definitions for latex documents                        %
%                 **************************************                        %
%                                                                               %
% Useful for producing latex documents both for postscript and pdf output.      %
% See the sample.tex document for how to use some of the packages               %
%                                                                               %
% See below for possible configurations. You should at least edit the           %
% parameters for hyperref to set the PDF description for your document.         %
%                                                                               %
% Author: David Buchmann, http://www.budda.ch/                                  %
% Fribourg, 9.7.2004                                                            %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[english, a4paper,twoside,12pt]report
% you would use german 'instead' of 'english' here for german documents
% you can omit twoside if you don't want to print on front and back side of each
% sheet of paper.
% you can use other document classes than report


%%% for different languages
\usepackagebabel

%%% german hyphenation, german descriptions etc.
% \usepackagegerman

%%% use umlaute without escape
\usepackage[latin1]inputenc


%%% to rotate figures
\usepackagerotating

%%% to let text float around figures
\usepackagepicins

%%% for image inclusion (eps for dvi output resp. png/pdf for pdf output)
\usepackagegraphicx

%%% nice code listings
\usepackagefancyvrb
\DefineVerbatimEnvironmentListingVerbatim
   frame=single,labelposition=topline,xleftmargin=1cm,xrightmargin=1cm,framesep=3mm


%%% to make table of contents and bibliography appear in the table of contents (and pdf bookmarks for pdf).
\usepackagetocbibind


%%% acronym list and writing acronyms full length exactly once
\usepackageacronym



%%% PDF / dvi dependant defines
% Must be after all other usepackage statements, many of commands get redefined.
% Check whether we are running pdflatex or latex and set graphics extension
% accordingly. In the document, reference graphic files without extensions!

\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse % we are not running pdflatex
\DeclareGraphicsExtensions.eps
\else
\pdfoutput=1 % we are running pdflatex
\pdfcompresslevel=9     % compression level for text and image;
\pdftrue
\DeclareGraphicsExtensions.pdf,.png
\fi


\ifpdf

%%% refs also as links
\usepackage[pdftex,plainpages=false,colorlinks=false,pdfborder=0,
            pdftitle=Paper Title,
            pdfauthor=David Buchmann,
            pdfsubject=Subject for PDF description.]
     hyperref
%plainpages=false: enable links although page numbering is reset after title
%other options... backref, pagebackref (links back from index to chapter/page) urlcolor=blue,citecolor=red

\else %no pdf

%%% url can be written as url. (this works fine in dvi)
\usepackageurl

\fi %ifpdf



% how deeply sections are numbered.
\setcountersecnumdepth2
% how deep titles appear in the table of contents
\setcountertocdepth1

%%% you can customize the layout of a page

\setlength\textheight24cm
\setlength\textwidth16cm
\setlength\oddsidemargin3mm
\setlength\evensidemargin-8mm
\setlength\topmargin-1cm
\setlength\headheight12pt
\setlength\headsep15mm

\renewcommand\topfraction0.85
\renewcommand\textfraction0.1


\pagestyleheadings

Komplettes Beispiel herunterladen 21 kB.

AttachmentSize
latex.zip20.26 KB
sample.pdf65.53 KB