• Aucun résultat trouvé

Mathematics,complexlayout CoursL TEXEDITEdeParis

N/A
N/A
Protected

Academic year: 2022

Partager "Mathematics,complexlayout CoursL TEXEDITEdeParis"

Copied!
46
0
0

Texte intégral

(1)

Cours L

A

TEX EDITE de Paris

Mathematics, complex layout

(2)

20/01/2011

Outline

Mathematics

Mathematical Environments Characters

Formulas Theorems Tables

Images and Floats Application

(3)

Outline

Mathematics

Mathematical Environments Characters

Formulas Theorems

Tables

Images and Floats Application

(4)

20/01/2011

Inline mathematics

Inlinemathematical formulas are written by surrounding them with $ $ or, equivalently, with \( \).

For all $x\in \mathbb{N}$,

$x+1=1+x$.

\bigskip

One can also show that

\(

\sum_{n=1}^{+\infty}

\frac 1{n^2}=\frac{\pi^2}{6}

\) is true.

For allx ∈N,x+1=1+x. One can also show that

∑︀+∞

n=1 1

n2 = 𝜋62 is true.

To have the same rendering as in displayed mode (cf. further), add

\displaymath inside the environment.

(5)

Displayed mathematics

Displayedmathematical formulas are written by surrounding them with

\[ \] or possibly \begin{equation*} \end{equation*}.

Do not use $$ $$ which is the Plain TEX syntax and raises spacing problems with LATEX.

The Euler constant $\gamma$

is such that:

\[

\lim_{n\rightarrow+\infty}

\left(\sum_{k=1}^{n}

\frac 1 {k}\right) -\ln(n)=\gamma

\]

The Euler constant 𝛾 is such that:

n→+∞lim (︃ n

∑︁

k=1

1 k

)︃

−ln(n) =𝛾

(6)

20/01/2011

Numbered equations

\begin{equation}

\label{equ:mass-energy}

E=m\cdot\mathsf{c}^2

\end{equation}

One can use Equation%

~\eqref{equ:mass-energy}

to prove the following theorem.

E =m·c2 (1) One can use Equation (1) to prove the following theorem.

\eqref is an addition of the amsmath package. One can also use

\ref (but parentheses need to be added by hand).

(7)

Environments of the amsmath package

amsmathproposes mathematical environments allowing regrouping several equations or splitting an equation across several lines.

multline equation across several lines, without alignment split equation across several lines, with alignment gather equation group without alignment

align equation group with alignment aligned alignment inside a complex equation

Do not use eqnarray/eqnarray* which gives badly for- matted output.

(8)

20/01/2011

multline environment

\begin{multline*}

x=1+2+3\\

+\dots+\\

+(n-1)+n

\end{multline*}

x =1+2+3 +· · ·+

+ (n−1) +n

multline*: unnumbered

(9)

split environment

\begin{equation}

\begin{split}

\phi=&(x\land y\land z)\lor{}\\

&(\lnot x\land y\land \lnot z)

\end{split}

\end{equation}

𝜑=(x∧y∧z)∨

(¬x∧y∧ ¬z) (2)

The {} after \lor makes the spacing right: LATEX is told that∨is properly used as a binary operator.

(10)

20/01/2011

aligned environment

\begin{equation*}

\left.\begin{aligned}

\mathbf{B’}&=-\partial\times \mathbf E,\\

\mathbf{E’}&=\partial\times \mathbf B - 4\pi \mathbf J

\end{aligned}

\right\}

\qquad \text{Maxwell’s equations}

\end{equation*}

B =−𝜕×E, E =𝜕×B−4𝜋J

}︃

Maxwell’s equations

(11)

Outline

Mathematics

Mathematical Environments Characters

Formulas Theorems

Tables

Images and Floats Application

(12)

20/01/2011

Latin characters

By default, variable names, etc., are displayed in italics.

One has access to the followingmathematical fonts, for the letters of the Latin alphabet.

\mathrm{ABCDZ} Serif ABCDZ

\mathsf{ABCDZ} Sans serif ABCDZ

\mathtt{ABCDZ} Typewriter ABCDZ

\mathit{ABCDZ} Italics ABCDZ

\mathbf{ABCDZ} Bold ABCDZ

\mathcal{ABCDZ} Cursive 𝒜ℬ𝒞𝒟𝒵

\mathfrak{ABCDZ} Fraktur ABCDZ

\mathbb{ABCDZ} Blackboard bold ABCDZ Some of these fonts require a \usepackage{amsfonts}.

One can also use \text{texte} (amsmath) to put regular text inside a formula.

(13)

Greek alphabet

The letters of the Greek alphabet are available by their name.

\[\alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa

\lambda\mu\nu\xi\pi\rho\sigma\tau\upsilon\phi\chi\psi\omega\]

\[\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega\]

𝛼𝛽𝛾𝛿𝜖𝜁𝜂𝜃𝜄𝜅𝜆𝜇𝜈𝜉𝜋𝜌𝜎𝜏 𝜐𝜑𝜒𝜓𝜔 ΓΔΘΛΞΠΣϒΦΨΩ

There is also \varepsilon 𝜀, \varpi 𝜛, \varsigma 𝜍, \varphi 𝜙.

(14)

20/01/2011

Other characters

Symbols \aleph ℵ, \infty

“Accents” \vec{x} x, \bar{x} x¯, \widehat{abc} abĉ︂

Binary operators \leq ≤, \cup ∪, \notin/ Big operators \sum ∑︀, \bigcup ⋃︀

Arrows \leftarrow ←, \iff ⇐⇒

Dots \ldots . . .ou \cdots · · · (\dots from amsmath does the right thing depending on surrounding operators) Refer to:

The Comprehensive LATEX Symbol List, accessible through

“texdoc symbols-a4”

Find a LATEX symbol by drawing it:

http://detexify.kirelabs.org/classify.html

(15)

Outline

Mathematics

Mathematical Environments Characters

Formulas Theorems

Tables

Images and Floats Application

(16)

20/01/2011

Function names

Function and operator names are traditionally not in italics:

\sin sin

\Pr Pr

\max max . . .

To define a custom operator (amsmath extension):

% Document header

\DeclareMathOperator*{\argmin}{argmin}

\DeclareMathOperator{\argmax}{argmax}

% Body

\[\argmin_x f(x)=0\]

\[\argmax_x f(x)=1\]

argmin

x

f(x) =0 argmaxxf(x) =1

(17)

Sub- and superscripts

\[

\prod_{

\substack{x\in X\\f(x)=0}

}

g(x^{2^n})

\]

∏︁

x∈X f(x)=0

g(x2n)

\substack is an amsmath feature.

One can control placing (below or besides) with the \limits or

\nolimits instructions directly after the operator.

(18)

20/01/2011

Fractions, roots, large delimiters

\[

\left\{

\frac{1}{\sqrt{

\left(\frac{x}{y}\right)^2}

}

\;\middle|\;

y\neq 0\right\}

\]

1

√︂

(︁x y

)︁2

y ̸=0

One can use \left., \right. when only one side has a delimiter.

(19)

Binomial coefficents

French convention:

\[

\mathsf{C}_n^p=

\frac{n!}{p!(n-p)!}

\]

English convention:

\[

\binom{n}{p}=

\frac{n!}{p!(n-p)!}

\]

French convention:

Cpn= n!

p!(n−p)!

English convention:

(︃n p

)︃

= n!

p!(n−p)!

\binom is a macro of theamsmathpackage.

(20)

20/01/2011

Mathematical spacing and phantoms

Usually, LATEX makes a good job at managing spacing. Sometimes, one still has to adjust by hand.

x\,x x x thin space

x\:x x x medium space

x\;x x x large space

x\ x x x regular space

x\!x xx negative space

x\quad x x x 1em space

x\qquad x x x 2em space

x\phantom{abcd}x x x same width as the argument

Some of these commands can also be used in text mode. \vphantom, which has the height of its argument and a zero width, also exists.

(21)

Outline

Mathematics

Mathematical Environments Characters

Formulas Theorems Tables

Images and Floats Application

(22)

20/01/2011

Theorems, definitions, etc.

One can define a theorem-like environment as follows:

\newtheorem{definition}{Definition}

It is then used:

\begin{definition}

A formula is

\emph{satisfiable}

if there exists a valuation that makes it true.

\end{definition}

Definition

A formula is satisfiable if there exists a valuation that makes it true.

amsthm proposes several different styles of theorems.

(23)

Proofs

amsthmadds a proof environment:

\begin{proof}

This result is trivial.

\end{proof}

Proof.

This result is trivial.

(24)

20/01/2011

Outline

Mathematics Tables

Basics

Advanced features Images and Floats Application

(25)

Outline

Mathematics Tables

Basics

Advanced features Images and Floats Application

(26)

20/01/2011

The tabular environment

One defines a table in LATEX with thetabularenvironment:

\begin{tabular}{specification}

l1,c1&l1,c2 ... \\

l2,c1&l2,c2 ... \\

...

\end{tabular}

The specification is a sequence ofncharacters, one for each table column. Each character describes the alignment of the column (m and b require thearraypackage):

l text on a single line, left-aligned r text on a single line, right-aligned c text on a single line, centered

p{1cm} paragraph of 1cm width, vertically top-aligned m{1cm} paragraph of 1cm width, vertically middle-aligned

b{1cm} paragraph of 1cm width, vertically bottom-aligned

(27)

The tabular environment, cont.

Rows are indicated one after the other, separated with \\ (or

\tabularnewline); columns are separated with ampersands &.

\begin{tabular}{lcc}

&True&False\\

A&yes&no\\

B&no&no

\end{tabular}

True False

A yes no

B no no

Tables are also often used (with p, m, or b) to layout two “blocks”

one besides the other; in this case the size is often a fraction of the line width: .3\linewidth (see also \minipage and \parbox)

(28)

20/01/2011

The array environment

In mathematical mode, one usesarrayinstead oftabular. Features are the same.

\[

I_3=\left(

\begin{array}{ccc}

1&0&0\\

0&1&0\\

0&0&1\\

\end{array}\right)\]

I3=

1 0 0 0 1 0 0 0 1

amsmathalso defines special commands for matrices.

(29)

Outline

Mathematics Tables

Basics

Advanced features Images and Floats Application

(30)

20/01/2011

Uniform columns

With thearraypackage, one can indicate arbitrary LATEX code to put at the beginning of a column (prefix the specification character with

>{code}), at the end (suffix the specification character with <{code}) or in between two columns (add @{} in the specification).

\begin{tabular}

{>{\bfseries}c

>{\color{blue}}c}

a&b\\

b&a\\

\end{tabular}

a b b a

(31)

Merged columns

One can use \multicolumn{num}{specification}{content} to merge columns of a given row. numis the number of columns,specification the specification character.

\begin{tabular}{cc}

a&b\\

\multicolumn{2}{c}{bouh}\\

b&a\\

\end{tabular}

a b

bouh

b a

(32)

20/01/2011

Merged lines (multirow)

With themultirowpackage one can merge two rows inside a given column. The syntax is \multirow{num}{width}{content}. The width is either given absolutely, or one can write * to mean “decide with respect to content length”.

\begin{tabular}{lr}

Bouh&x\\

Bah&y\\

\multirow{2}{*}{Bli}

&z\\

&t\\

\end{tabular}

Bouh x

Bah y

Bli z

t

(33)

Separation rules

One can add horizontal rules with \hrule and vertical rules by adding a | at the proper place in the specification.

\begin{tabular}{|c|c|}

\hline a&b\\

\hline b&a\\

\hline

\end{tabular}

a b

b a

Typographers recommend to never use vertical rules in such a table, and horizontal rules produced with \hline are poor. Prefer those of thebooktabspackage.

(34)

20/01/2011

Nicer tables with booktabs

\begin{tabular}{cc}

\toprule T&Y\\

\midrule a&b\\

b&c\\

b&a\\

\bottomrule

\end{tabular}

T Y

a b

b c

b a

One can also use \cmidrule for partial lines, see the documentation ofbooktabs.

(35)

Outline

Mathematics Tables

Images and Floats Images

Floats Application

(36)

20/01/2011

Outline

Mathematics Tables

Images and Floats Images

Floats Application

(37)

The graphicx package

To load images, one use the graphicx package and the command

\includegraphics.

\includegraphics[options]{file_name_without_extension}

Supported options:

width=.5\linewidth to define the width with respect to the line width height=1cm to define a constant height

angle=90 to rotate the image

Do not use epsfig or graphics, these packages are obso- lete.

(38)

20/01/2011

Supported graphics formats

Compilation with latex+dvips onlyEPS(Encapsulated PostScript)

Compilation with pdflatex

PDF forvectorimages (logical description of the image)

PNG forbitmap(pixel per pixel description of the image) schemas, logos, etc.

JPG for photos and othercontinuous color bitmaps

(39)

Conversion between graphics formats

From a bitmap format to PNG or EPS (GIF, BMP, TIF, RLE, etc.) Use any bitmap image editing software (Paint, PhotoShop, Gimp, etc.) On Unix, convert (ImageMagick) is a command-line tool.

Do not convert a logo into JPG! JPG is a for- mat with compression that is adapted only for continuous color bitmaps.

From a vector format to EPS or PDF (SVG, WPG, WMF, etc.) Use a vector drawing program such as Inkscape.

From EPS to PDF Use epstopdf, provided with LATEX distributions.

From PDF to EPS Use pdftops, with the “-eps” option, provided with GhostScript.

(40)

20/01/2011

Producing high-quality schemas

With anyvector drawingsoftware (Inkscape, OpenOffice Draw, etc.) Some of these (especially, Inkscape, xfig, IPE) propose either to export directly in LATEX format, or to integrate LATEX formulas into the schema.

With a programmed description of the schema, in anexternal languagewell-integrated with LATEX (MetaPost, Asymptote) By describing the schema as a program inside LATEX itself (xypic, pstricks,tikz)

Whenever possible, save schemas in avector format!

(41)

Outline

Mathematics Tables

Images and Floats Images

Floats Application

(42)

20/01/2011

Floats

Two environments: \begin{figure} and \begin{table} allow to definefloatingfigures and tables, i.e., that do not follow the normal flow of the document.

\begin{figure}[thp]

\includegraphics{toto}

\end{figure}

The environment has an optional parameter which is aposition

specification, purely indicative. tfor top of the page,bfor bottom of the page,hfor current position,pfor dedicated page.

Possible to define new floating environments with thefloatpackage.

Some classes or packages with multicolumn text layout (multicol) propose figure* and table* that indicate the float is to span the columns.

(43)

Captions and references

\begin{table}

\begin{center}

\begin{tabular}{cr}

Carrots&10~\texteuro\\

Cheese&15~\texteuro\\

Rabbit&100~\texteuro\\

\end{tabular}

\end{center}

\caption{Expense amounts}

\label{tab:depenses}

\end{table}

As indicated in Table~\ref{tab:depenses}, rabbit is costly.

(44)

20/01/2011

Outline

Mathematics Tables

Images and Floats Application

(45)

Application

Reproduce the example available on the course Web page (with the document class scrartcl).

(46)

20/01/2011

Licence de droits d’usage

Contexte public} avec modifications

Par le téléchargement ou la consultation de ce document, l’utilisateur accepte la licence d’utilisation qui y est attachée, telle que détaillée dans les dispositions suivantes, et s’engage à la respecter intégralement.

La licence confère à l’utilisateur un droit d’usage sur le document consulté ou téléchargé, totalement ou en partie, dans les conditions définies ci-après et à l’exclusion expresse de toute utilisation commerciale.

Le droit d’usage défini par la licence autorise un usage à destination de tout public qui comprend : – le droit de reproduire tout ou partie du document sur support informatique ou papier,

– le droit de diffuser tout ou partie du document au public sur support papier ou informatique, y compris par la mise à la disposition du public sur un réseau numérique,

– le droit de modifier la forme ou la présentation du document,

– le droit d’intégrer tout ou partie du document dans un document composite et de le diffuser dans ce nouveau document, à condition que : – L’auteur soit informé.

Les mentions relatives à la source du document et/ou à son auteur doivent être conservées dans leur intégralité.

Le droit d’usage défini par la licence est personnel et non exclusif.

Tout autre usage que ceux prévus par la licence est soumis à autorisation préalable et expresse de l’auteur :sitepedago@telecom-paristech.fr

Références

Documents relatifs

Le droit d’usage défini par la licence autorise un usage à destination de tout public qui comprend : – le droit de reproduire tout ou partie du document sur support informatique

Le droit d’usage défini par la licence autorise un usage à destination de tout public qui comprend : – le droit de reproduire tout ou partie du document sur support informatique

Le droit d’usage défini par la licence autorise un usage à destination de tout public qui comprend : – le droit de reproduire tout ou partie du document sur support informatique

Le droit d’usage défini par la licence autorise un usage à destination de tout public qui comprend : – le droit de reproduire tout ou partie du document sur support informatique

ODT Il est possible d’obtenir une sortie OpenDocument lisible avec Openoffice (p. ex., pour ensuite convertir en un document Word), mais fonctionne assez

Not WYSIWYG (what you see is what you get) like classical word processing software (Microsoft Word, OpenOffice Writer, etc.) A L A TEX document: a text file (or several), usually

Les tableaux sont aussi souvent utilisés (avec p, m ou b) pour mettre en page deux « blocs » l’un à côté de l’autre ; dans ce cas on exprime souvent la taille en une fraction de

Le droit d’usage défini par la licence autorise un usage à destination de tout public qui comprend : – le droit de reproduire tout ou partie du document sur support informatique