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.
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) \usepackage url \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.
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 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 \author David Buchmann \date \today %%% text for title page. no empty lines allowed, use \\ for newlines \title \Large Example title page, change! \\\vspace 40pt \Huge\bf PROJECT \\\vspace 50pt Working paper at Departement of Informatics\\ University of Fribourg, Switzerland\\ \vspace 30pt \normalsize\begin flushleft \hspace 3cm Referent: Prof. Dr. Ulrich Ultes-Nietsche\\ \vspace 30pt \hspace 3cm Author:\\ \hspace 3cm David Buchmann\\ \hspace 3cm Chemin de musee 4\\ \hspace 3cm 1700 Fribourg\\ \hspace 3cm david.buchmann@unifr.ch \end flushleft \begin document \maketitle \newpage \tableofcontents \chapter Latex Samples \begin Listing [label=Listing 1: An Example] a += 3; \end Listing % put an illustration to the side of the text. Default is on the left side, % \parpic[r] would put it on the right side. \piccaption A decoration figure\label figTest \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 \ac XML ? The word \ac XML is used as an example of acronym here. If we need it explained again, we can write \acf XML . \ac XML is defined by \cite W3C . There is also the web page \url http://www.xml.org .\\ %two backslashes force newline. Somewhere in the document, there must be the complete acronym listing. %\footnote In our sample document, it is in an appendix. \picskip 0 % 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 \ref figTest . 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: \begin figure [ht] \begin center \includegraphics[width=4cm] img/penguin % height will be scaled proportionally. \caption The linux penguin as sample bitmap. \label imgSample \end center \end figure You should always reference the image in your text, even if Figure \ref imgSample 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 \chapter Acronyms \begin acronym \acro XML Extensible Markup Language \end acronym \begin thebibliography 99 \bibitem W3C \url http://www.w3.org/ , Definition of XML \end thebibliography \end document
Komplettes Beispiel herunterladen 21 kB.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % 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 \usepackage babel %%% german hyphenation, german descriptions etc. % \usepackage german %%% use umlaute without escape \usepackage[latin1] inputenc %%% to rotate figures \usepackage rotating %%% to let text float around figures \usepackage picins %%% for image inclusion (eps for dvi output resp. png/pdf for pdf output) \usepackage graphicx %%% nice code listings \usepackage fancyvrb \DefineVerbatimEnvironment Listing Verbatim 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). \usepackage tocbibind %%% acronym list and writing acronyms full length exactly once \usepackage acronym %%% 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) \usepackage url \fi %ifpdf % how deeply sections are numbered. \setcounter secnumdepth 2 % how deep titles appear in the table of contents \setcounter tocdepth 1 %%% you can customize the layout of a page \setlength \textheight 24cm \setlength \textwidth 16cm \setlength \oddsidemargin 3mm \setlength \evensidemargin -8mm \setlength \topmargin -1cm \setlength \headheight 12pt \setlength \headsep 15mm \renewcommand \topfraction 0.85 \renewcommand \textfraction 0.1 \pagestyle headings
Komplettes Beispiel herunterladen 21 kB.
Attachment | Size |
---|---|
latex.zip | 20.26 KB |
sample.pdf | 65.53 KB |