24
Computermathematik L A T E X 2+3: Komplexe Dokumente & Grafiken M. Eichlseder/F. Lehner 17. Oktober 2018

M. Eichlseder/F. Lehner 17. Oktober 2018€¦ · Wissenschaftliche\ Dokumente Beispiele I Publikationen I Code- Dokumentation I Skriptum I Labor-Protokoll I Technischer Bericht I

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

ComputermathematikLATEX 2+3: Komplexe Dokumente & Grafiken

M. Eichlseder/F. Lehner

17. Oktober 2018

Ziele

I Wissenschaftliche DokumenteI Dokumentstruktur planen

I ReferenzenI Bilder einsetzenI Referenzen verwendenI Zitieren

I AlgorithmenI Code und Pseudocode einsetzen konnen

I GrafikenI Diagramme sinnvoll einsetzenI Umsetzung in TikZ (o.a.)

1 / 23

”Wissenschaftliche“ Dokumente

Beispiele

I Publikationen

I Code-Dokumentation

I Skriptum

I Labor-Protokoll

I TechnischerBericht

I Bachelor-Arbeit

LATEX-DokumentklassenKOMA AMS-LATEX

article scrartcl amsart

report scrreprt

book scrbook amsbook

letter2 scrlttr2

Weitere: beamer, moderncv,flashcards, . . .

2 / 23

Beispiel: ScrArtcl

Lorem Ipsum

Mary Sue John Doe

October 21, 2014

Contents

1 A first section 11.1 With subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Another section 32.1 With yet another subsection . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1 A first section

1.1 With subsection

Hello, here is some text without a meaning. This text should show what a printedtext will look like at this place. sin2(α) + cos2(β) = 1. If you read this text, you willget no information E = mc2. Really? Is there no information? Is there a differencebetween this text and some nonsense like “Huardest gefburn”? Kjift – not at all! Ablind text like this gives you information about the selected font, how the letters arewritten and an impression of the look. n

√a · n√b = n

√ab. This text should contain all

letters of the alphabet and it should be written in of the original language.n√an√b

= n

√ab .

There is no need for special content, but the length of words should match the language.a n√b = n√anb.

x =1

n

i=n∑

i=1

xi =x1 + x2 + . . . + xn

n

Hello, here is some text without a meaning. dΩ = sinϑdϑdϕ. This text should showwhat a printed text will look like at this place. If you read this text, you will get noinformation. Really? Is there no information? Is there a difference between this text andsome nonsense like “Huardest gefburn”? Kjift – not at all! A blind text like this givesyou information about the selected font, how the letters are written and an impressionof the look. sin2(α) + cos2(β) = 1. This text should contain all letters of the alphabetand it should be written in of the original language E = mc2. There is no need for

1

3 / 23

Beispiel: Book

Lorem Ipsum

Mary Sue John Doe

XXI Octobris MMXIV

+ Leerseite

+ Inhalts-verzeichnis

+ Leerseite

Caput 2

Ein Chapter

2.1 Mit Section

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortisfacilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent im-perdiet mi nec ante. Donec ullamcorper, felis non sodales commodo, lectusvelit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus nuncnunc, molestie ut, ultricies vel, semper in, velit. Ut porttitor. Praesent insapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis frin-gilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat.Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin.Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam,luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quisurna dictum turpis accumsan semper.

x =1

n

i=n∑

i=1

xi =x1 + x2 + . . . + xn

n

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortisfacilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent im-perdiet mi nec ante. Donec ullamcorper, felis non sodales commodo, lectusvelit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus nuncnunc, molestie ut, ultricies vel, semper in, velit. Ut porttitor. Praesent insapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis frin-gilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat.Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin.Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam,luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quisurna dictum turpis accumsan semper.

∫ ∞

0e−αx

2dx =

1

2

√∫ ∞

−∞e−αx2dx

∫ ∞

−∞e−αy

2dy =

1

2

√π

α

3

4 / 23

Typische Dokument-Bausteine

I Titelseite \maketitle oder \begintitlepage

I Abstract? Keywords? \beginabstract

I Inhaltsverzeichnis? \tableofcontents

Inhalt

I Bibliographie BibTEX

I Index von Bildern, Tabellen, Algorithmen, Stichwortern?Paket makeidx, \listoffigures, \listoftables

5 / 23

Aufbau

1. EinleitungWas? Warum? Wer hat schon ahnliches gemacht?

2. Methoden, GrundlagenWas braucht man dazu? Wie macht man das?

3. ErgebnisseWas ist passiert?

4. DiskussionWas bedeutet das?

6 / 23

Dateien aufteilen – nur Hauptdokument kompilieren

main.tex

\documentclassreport

\usepackage ...

\newcommand ...

\begindocument

\titleTheorie von ...

\authorMary Sue

\maketitle

\tableofcontents

\inputeinfuehrung

\inputtheorie

\inputergebnisse

\enddocument

einfuehrung.tex

\chapterEinf u hrung

Wir beschreiben ...

theorie.tex

\chapterTheorie

Die theoretischen

Grundlagen ...

ergebnisse.tex

\chapterErgebnisse

Unsere Experimente ...

7 / 23

Eigene Titelseite – nutzliche ZutatenManuelle Abstande

\vspace 5cm % vertikal

\hspace 2mm % horizontal

Automatische Abstande (proportional auffullen)

oben

\vfill

links \hfill rechts

\vfill

unten

Linien

\rule5cm1mm % 5cm lang und 1mm dick

Autor, Titel, Datum auslesen

\usepackagetitling

\theauthor , \thetitle , \thedate8 / 23

Kapitel, Abschnitte, etc. referenzieren

Grundmuster: \labelx:y . . . \refx:y.

Kapitel und Abschnitte

\chapterTheorie \labelchap:theorie

\sectionErgebnisse \labelsec:ergebnisse

\beginenumerate

\item \labelsumme Summiere alle Werte $x_i$

\endenumerate

... in Kapitel~\refchap:theorie,

Abschnitt~\refsec:ergebnisse,

Punkt~\refsumme ...

. . . in Kapitel 2, Abschnitt 1, Punkt 1 . . . ...

9 / 23

Formeln

\beginequation

a^2 + b^2 = c^2 \labeleq:pythagoras

\endequation

In Gleichung~\eqrefeq:dreieck ...

a2 + b2 = c2 (1)

In Gleichung (1)...

\beginequation

a^2 + b^2 = c^2 \tag$\ dagger $ \labeleq:pythagoras

\endequation

In Gleichung~\eqrefeq:pythagoras ...

a2 + b2 = c2 (†)

In Gleichung (†)...10 / 23

Bilder

Figure 1: A diagram describing the complex interrela-tions between number theory and social engineering.

As Figure 1 on page 1 illustrates, Lorem ipsum do-lor sit amet, consectetuer adipiscing elit. Ut puruselit, vestibulum ut, placerat ac, adipiscing vitae, felis.Curabitur dictum gravida mauris. Nam arcu libero,nonummy eget, consectetuer id, vulputate a, magna.Donec vehicula augue eu neque. Pellentesque habitantmorbi tristique senectus et netus et malesuada famesac turpis egestas. Mauris ut leo. Cras viverra metusrhoncus sem. Nulla et lectus vestibulum urna fringillaultrices. Phasellus eu tellus sit amet tortor gravidaplacerat. Integer sapien est, iaculis in, pretium quis,viverra ac, nunc. Praesent eget sem vel leo ultricesbibendum. Aenean faucibus. Morbi dolor nulla, male-suada eu, pulvinar at, mollis ac, nulla. Curabitur auc-tor semper nulla. Donec varius orci eget risus. Duisnibh mi, congue eu, accumsan eleifend, sagittis quis,diam. Duis eget orci sit amet orci dignissim rutrum.

1

http://xkcd.com/538/ 11 / 23

Bilder

(a)Left half (b)Right half

Figure 2: A diagram with subfigures.

As Figure 2 on page 2 illustrates with the help of2a and 2b, Lorem ipsum dolor sit amet, consectetueradipiscing elit. Ut purus elit, vestibulum ut, placeratac, adipiscing vitae, felis. Curabitur dictum gravidamauris. Nam arcu libero, nonummy eget, consectetuerid, vulputate a, magna. Donec vehicula augue euneque. Pellentesque habitant morbi tristique senectuset netus et malesuada fames ac turpis egestas. Mau-ris ut leo. Cras viverra metus rhoncus sem. Nullaet lectus vestibulum urna fringilla ultrices. Phasel-lus eu tellus sit amet tortor gravida placerat. Integersapien est, iaculis in, pretium quis, viverra ac, nunc.Praesent eget sem vel leo ultrices bibendum. Aeneanfaucibus. Morbi dolor nulla, malesuada eu, pulvinarat, mollis ac, nulla. Curabitur auctor semper nulla.Donec varius orci eget risus. Duis nibh mi, congueeu, accumsan eleifend, sagittis quis, diam. Duis egetorci sit amet orci dignissim rutrum.

2

http://xkcd.com/538/ 12 / 23

Bilder

Datei einbinden – file.png/.jpg/.pdf

\usepackagegraphicx

\includegraphics [...] file

Parameter

I width, scale – Bild skalieren

I trim, clip – Bildteile ausschneiden

Positionierung?

13 / 23

Float-Umgebungen & Referenzen I

I Bilder

As \figurename~\reffig:crypto

on page~\pagereffig:crypto illustrates ,

\beginfigure

\centering

\includegraphicsxkcd

\captionA diagram describing ...

\labelfig:crypto

\endfigure

Floats floaten!

Das ist erwunscht!

Beschriftung & Referenz sind Pflicht!

14 / 23

Float-Umgebungen & Referenzen II

I Tabellen

\begintable

\caption ...\ label ...

\begintabular lr

...

\endtabular

\endtable

I Algorithmen, Code

\beginalgorithm

... kommt gleich

\endalgorithm

15 / 23

Literatur zitieren

Donald E. Knuth showed [2] that the implementationof fundamental algorithms. . .

Examples are provided by Graham et al. [1, p. 13–15].

References

[1] Ronald L. Graham, Donald E. Knuth, and OrenPatashnik. Concrete mathematics – a foundationfor computer science. Addison-Wesley, 1989.

[2] Donald E. Knuth. The Art of Computer Pro-gramming, Volume I: Fundamental Algorithms.Addison-Wesley, 1968.

1

16 / 23

Literatur zitieren – BibTEX

dokument.tex

Donald E.~Knuth showed~\citeartof ...

...by Graham et~al.~\cite[p.~13--15] concr.

\bibliographystyleplain

\bibliographyliteratur

literatur.bib

@bookartof ,

author = Donald E. Knuth,

title = The Art of Computer

Programming , Volume I:

Fundamental Algorithms,

publisher = Addison -Wesley,

year = 1968 ,

17 / 23

Literatur zitieren – BibTEX

I Mehrfach kompilieren notwendigpdflatex dokument.tex

bibtex dokument

pdflatex dokument.tex

pdflatex dokument.tex

I BibTEX-Eintrage am einfachsten aus Datenbanken(Universitats-Bibliotheken, Google Scholar, DBLP, . . . )

I Verschiedene Zitier-Stile in Gebrauch(Nummern, Autor und Jahr, . . . )

I Nachfolger: BibLATEXI Flexibler, internationaler, einfacherI (Noch) nicht uberall gut integriert (Verlage, IDEs, . . . )

18 / 23

Hyperlinks und URLs

Klickbare ref und cite im PDF

\usepackagehyperref

URLs

\urlwww.tugraz.at

\hrefwww.tugraz.atTU Graz

19 / 23

Source Code

Die Funktion nimmt einen unsigned int als Param-eter. Der Returnwert ist ebenfalls ein unsigned int.

unsigned f a c t o r i a l (unsigned n ) ;

Die vollstandige Implementierung ist in code.c.

#include<s t d i o . h>unsigned f a c t o r i a l (unsigned n)

int r e s u l t = 1 , i ;for ( i = 1 ; i <= n ; i++)

r e s u l t ∗= i ;return r e s u l t ;

int main ( int argc , char ∗∗ argv )

p r i n t f ( ”%d ! = %d\n” ,9 , f a c t o r i a l ( 9 ) ) ;return 0 ;

Man kann auch verbatim verwenden:

#include<stdio.h>

unsigned factorial(unsigned n)

int result = 1, i;

for (i = 1; i <= n; i++)

result *= i;

return result;

1

20 / 23

Source Code

I Wenn der Code im Vordergrund steht (z.B. Dokumentation)Nicht, um Algorithmus zu erklaren

I Umgebung verbatim

\beginverbatim ... \endverbatim

oder inline \verb |...|

I Paket listings

\usepackagelistings

\lstsetkeywordstyle =\bfseries ,language=C

\beginlstlisting ... \endlstlisting

oder inline \lstinline !...!

oder aus Datei

\lstinputlistingmain.c

21 / 23

Pseudocode

Algorithmus 1 Berechnung der Fakultat n!

Eingabe: eine Zahl n ∈ NAusgabe: N = n!, die Fakultat von n1: initialisiere N := 12: for i = 1, . . . , n do3: setze N := N · i4: gib Ergebnis N aus

Algorithmus 1 beschreibt die iterative Berechnung derFakultat einer Zahl. Das geht auch mit mehr Worten:

1. Multipliziere alle Zahlen von 1 bis n zusammen.

2. Das Ergebnis ist die gesuchte Zahl N = n!.

1

22 / 23

Pseudocode

I Wenn der Algorithmus im Vordergrund steht, zum Erklaren

I Umgebung enumerate

I Paket algorithmic und Konsorten

\usepackagealgorithm , algorithmic

...

\beginalgorithm

\caption ... \label ...

\beginalgorithmic

\STATE initialisiere $N := 1$

\FOR $i = 1, \ldots , n$

\STATE setze $N := N \cdot i$

\ENDFOR

\endalgorithmic

\endalgorithm

23 / 23