Workshop LaTeX Base

Preview:

DESCRIPTION

LaTeX BaseWorkshop c/o Area Ricerca Banca d'ItaliaSala Emeroteca14 Dicembre 2007

Citation preview

E. Somma LATEXBase 13/12/2007 1 / 61

LATEXBase

Emmanuele Somma1

14 Dicembre 2007

c© 2007 – Emmanuele ’exedre’ Sommariproduzione integrale permessa con qualsiasi mezzo

1Bank of Italy - Research Area Computer Support

E. Somma LATEXBase 13/12/2007 2 / 61

Part I

Introduzione

E. Somma LATEXBase 13/12/2007 3 / 61

Cos’e LATEX

LATEX e pronunciato latech (con la chi greca finale), e un sistema per la preparazione ditesti basato sul programma di composizione tipografica TEX.Fornisce funzioni di desktop publishing programmabili e mezzi per l’automazione dellamaggior parte della composizione tipografica, inclusa la numerazione, i riferimentiincrociati, tabelle e figure, organizzazione delle pagine, bibliografie e molto altro. LATEXvenne creato nel 1985 da Leslie Lamport (adesso e manutenuto da Frank Mittelbach) ede divenuto il principale metodo di utilizzo di TEX, poche persone usano ancoradirettamente TEX base per la redazione di documenti. La versione attuale e denominataLATEX 2ε.

E. Somma LATEXBase 13/12/2007 4 / 61

Personaggi importanti

Donald Knuth, Stanford University

Leslie Lamport, Microsoft Research

Frank Mittelbach, LaTeX3 Project

E. Somma LATEXBase 13/12/2007 5 / 61

Versioni di LATEX

LATEX 2.09differenti installazioni: NFSS, SliTeX, AMS-TeX, . . .

LATEX 2εNFSS standardpackages: amstex, slitex, . . .

LATEX 3 . . .

E. Somma LATEXBase 13/12/2007 6 / 61

TEX User Group

La Banca d’Italia e uno dei 25 membri istituzionali mondiali del TEX User Group. Altrimembri: (American Mathematical Society, Center of Computer Science, CNRS France,IBM Corporation, Max Plank Insitute, Stanford Linear Accelerator Center, University:Duke, Florida State, New York, Stanford, Stockholm, Delaware, Laval, Oslo, Uppsala,Vanderbilt,. . .)La rivista del TUG e TUGboat (disponibile presso la SIA)Il sito e http://www.tug.org

E. Somma LATEXBase 13/12/2007 7 / 61

Riferimenti

Leslie Lamport LaTeX - A Document Preparation System Addison-Wesley ReadingMassachusetts, second edition, 1994

Michel Goossens, Frank Mittelbach and Alexander Samarin. The LATEX CompanionAddison-Wesley, Reading, Massachusetts, 1994

http://www.tug.org

http://www.latex-project.org

3652

E. Somma LATEXBase 13/12/2007 8 / 61

Part II

LATEX

E. Somma LATEXBase 13/12/2007 9 / 61

WYSIWYM-What You See Is What You Mean

E. Somma LATEXBase 13/12/2007 10 / 61

Processo di pubblicazione LATEX

E. Somma LATEXBase 13/12/2007 11 / 61

1, 2, 3 . . . LATEX

LATEX 2.09

\documentstyle[<opts>]{<style>}

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

LATEX 2ε

\documentclass[<opts>]{<class>}\usepackage[<opts>]{<packages>}\begin{document}...\end{document}

E. Somma LATEXBase 13/12/2007 12 / 61

1, 2, 3 . . . un esempio di LATEX

LATEX 2.09

\documentstyle[twoside,epsfig,multicol]{article}

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

LATEX 2ε

\documentclass[twoside]{article}\usepackage{epsfig}\usepackage{multicol}\begin{document}...\end{document}

E. Somma LATEXBase 13/12/2007 13 / 61

Classi e package standard

Classi: article, book, report, letter, slides, minimal

Package: alltt, doc, exscale, fontenc, graphpap, ifthen, inputenc, latexsym, makeidx,newlfont, oldlfont, showidx, syntonly, tracefnt,

E. Somma LATEXBase 13/12/2007 14 / 61

Package aggiuntivi

Package: amslatex, babel, cyrillic, graphics, psnfss, tools

Strumenti: array, calc, dcolumn, delarray, hhline, longtable, tabularx, afterpage, bm,enumerate,fontsmpl, ftnright, indexfirst, layout, multicol, rawfonts, somedefs,showkeys, theorem, varioref, verbatim, xr, xspace

E. Somma LATEXBase 13/12/2007 15 / 61

E. Somma LATEXBase 13/12/2007 16 / 61

E. Somma LATEXBase 13/12/2007 17 / 61

Elementi del linguaggio TEX

Commenti: % fino a fine riga

Comandi: \ComandoSenzaArgomenti, \ComandoCon1Argomento oppure\ComandoRicco{arg1}{arg2}...{arg9} (riconosce maiuscole e minuscole, ovvero\delta != \Delta)

Contatori: \nomevar=1

Dimensioni: \dimen0=1pc ( dimensioni accettate mm,cm,pt,pc,em,ex,...)

Spazio non interrompibile: ~ (L. Torvalds)

Spazio sicuro: \ (fine\comando\ inizio)

Caratteri accentati: ae... \"u (Br\"{u}lhart)

Gruppi: \textit{ciao}

E. Somma LATEXBase 13/12/2007 18 / 61

Elementi del linguaggio TEX

Virgolette: ’, ", ’’

Lineette: - (a capo), -- (numerico), --- (segno di punteggiatura, discorso)

A capo: \-

Simboli speciali: # $ % & ~ _ ^ { }

Spazio troppo speciali: $>$, $<$, $\backslash$

E. Somma LATEXBase 13/12/2007 19 / 61

Elementi propri del linguaggio LATEX

Opzioni dei Comandi: \Comando[opz1,opz2,...]{arg1}

Ambienti: \begin{nome}[opz,...] <contenuto> \end{nome}

Forme alternate: \section{} \section*{}

Errori: ! LaTeX Error: ...

E. Somma LATEXBase 13/12/2007 20 / 61

Un programma LATEX

% Preambolo\documentclass[<opts>]{<class>}\usepackage[<opts>]{<packages>}...% Documento\begin{document}...\end{document}

E. Somma LATEXBase 13/12/2007 21 / 61

Preambolo

Tutto quello che c’e prima di\begin{document}

Comandi:

\documentclass o \documentstyle,

\usepackage,

\listfiles,

\setcounter

E. Somma LATEXBase 13/12/2007 22 / 61

Comando: documentclass

\documentclass Classe LATEX 2ε

Uso:

\documenclass[<opts>]{<class>}

dove <class> e:

article

book

report . . .

Esempio:

\documentclass[twoside ]{ article}

\documentclass[slides ]{ beamer}� �

E. Somma LATEXBase 13/12/2007 23 / 61

Comando: usepackage

\usepackage Attivazione package esterno

Uso:

\usepackage[<opts>]{<name>}

dove <name> e uno dei package supportati dalla distribuzione. Ad es.:

graphicx

url

inputenc . . .

Esempio:

\usepackage[latin1 ]{ inputenc}

\usepackage[italian ]{babel}

\usepackage{listings}� �

E. Somma LATEXBase 13/12/2007 24 / 61

Comando: listfiles

\listfiles Elenca i file usati nel log

Uso:

\listfiles

Esempio:

*File List*

beamer.cls 2007/03/11 cvs version 3.07 A class for typesetting presentations (rcs -revision 1.70)

beamerbasercs.sty 2007/01/28 (rcs -revision 1.4)

beamerbasemodes.sty 2007/01/28 (rcs -revision 1.22)

beamerbasedecode.sty 2007/01/28 (rcs -revision 1.20)

beamerbaseoptions.sty 2007/01/28 (rcs -revision 1.8)

[...]� �

E. Somma LATEXBase 13/12/2007 25 / 61

Comando: setcounter

\setcounter Definisci il valore di un contatore

Uso:

\setcounter{<nome>}{<valore>}

dove <nome> e il nome di un contatore e <valore> e un valore numerico.Esempio:

\setcounter{errorcontextlines }{999}� �

E. Somma LATEXBase 13/12/2007 26 / 61

Part III

Documento LATEX

1 Comandi

2 Ambienti

3 Matematica

4 Riferimenti Bibilografici

5 Titoli

E. Somma LATEXBase 13/12/2007 27 / 61

Comandi

Comandi

1 Comandi

2 Ambienti

3 Matematica

4 Riferimenti Bibilografici

5 Titoli

E. Somma LATEXBase 13/12/2007 28 / 61

Comandi

Comandi in un documento TEX

Formato: \emph{per dare enfasi}

Struttura: \section{Titolo di sezione} (a capo), -- (numerico), --- (segno dipunteggiatura, discorso)

Riferimento: \ref, \pageref, \label{}

Ambienti:

\begin{theorem}

bla bla bla

\end{theorem}

Matematica: $L=\sum_{i=1}^{M}L_i$

E. Somma LATEXBase 13/12/2007 29 / 61

Comandi

Comandi di formattazione

Una buona norma:

USARE SOLO UN TIPO DI ENFASI:

\emph{bla bla bla}

Da non usare: variazioni di stile

\textbf{bla bla bla}

\textit{bla bla bla}

\textsl{bla bla bla}

Ma si usano nella matematica

E. Somma LATEXBase 13/12/2007 30 / 61

Comandi

Comandi di strutturazione

Dipendono dalla classe del documento.\chapter \section \subsection \subsubsection \paragraph \subparagraph \appendix

Inserimento nella tabella dei contenuti

\chapter{Pippo}

\chapter[Titolo Lungo]{Un titolo troppo lungo per essere impaginato nella testata}

\chapter*{Pippo}

Sommario: \tableofcontents (DOPPIO GIRO!)

E. Somma LATEXBase 13/12/2007 31 / 61

Comandi

Comandi di riferimento

Definizione delle etichette \chapter{Pinco Pallino}\label{pinco-pa} Uso delriferimento:

. . . come si puo leggere nel Capitolo \ref{pinco-pa} a pagina\pageref{pinco-pa}

RICORDARE SEMPRE: quando ci sono i riferimenti bisogna lanciare DUE volte ilcomando di compilazione del documento

E. Somma LATEXBase 13/12/2007 32 / 61

Comandi

Altri comandi

Note a pie pagina: \footnote{}

Note a margine: \marginpar{}

Testo dattiloscritto: \verb-\comando-

Numerazione delle pagine: \pagenumbering{arabic} (oppureroman, Roma, alph, Alph)

Avanzamento pagina: \clearpage oppure \pagebreak, contrario \samepage

Spazio verticale: \vspace{1cm} \vspace*{},\smallskip, \medskip, \bigskip, \fill

Spazio orizzontale: \hspace{1cm} \hspace*{}

E. Somma LATEXBase 13/12/2007 33 / 61

Ambienti

Ambienti

1 Comandi

2 Ambienti

3 Matematica

4 Riferimenti Bibilografici

5 Titoli

E. Somma LATEXBase 13/12/2007 34 / 61

Ambienti

Ambiente: quotation

1\begin{quotation}

2\noindent {\small ‘‘How do we construct demand measures

3in the presence of more than two countries? Indeed

4\emph{how does one even formulate the home market effect

5hypothesis }? The ratios and shares of the theoretical

6formulations neglect third country effects.’’}

7\end{quotation}� �

E. Somma LATEXBase 13/12/2007 35 / 61

Ambienti

Ambiente: picture

1\begin{picture }(50 ,50)

2\thicklines

3\qbezier (0 ,0)(0 ,50)(50 ,50)

4\qbezier [20](0 ,0)(50 ,0)(50 ,50)

5\thinlines

6\put (0 ,0){\ line (1 ,1){50}}

7\end{picture}� �

E. Somma LATEXBase 13/12/2007 36 / 61

Ambienti

Ambiente: verbatim

1\begin{verbatim}

2>> rho = (1+ sqrt (5))/2

3rho =

41.6180

5>> a = abs (3+4i)

6a =

75

8>> z = sqrt(besselk (4/3,rho -i))

9z =

100.3730 + 0.3214i

11>> huge = exp(log(realmax ))

12huge =

131.7977e+308

14>> toobig = pi*huge

15toobig =

16Inf

17\end{verbatim}� �

E. Somma LATEXBase 13/12/2007 37 / 61

Ambienti

Ambiente: Liste itemize, enumerate

1\begin{itemize}

2\item Leslie Lamport [...]

3\item Michel Goossens , Frank Mittelbach and Alexander Samarin. [...]

4\item \url{http :// www.tug.org}

5\item \url{http :// www.latex -project.org}

6\item $3652$

7\end{itemize}� �Leslie Lamport [...]

Michel Goossens, Frank Mittelbach and Alexander Samarin. [...]

http://www.tug.org

http://www.latex-project.org

3652

E. Somma LATEXBase 13/12/2007 38 / 61

Ambienti

Ambiente: Descrizione description

1\begin{description}

2\item[Leslie Lamport] \textit{LaTeX - A Document Preparation System} ...

3\item[Michel Goossens , Frank Mittelbach and Alexander Samarin] \textit{The LATEX Companion} ...

4\end{description}� �Leslie Lamport LaTeX - A Document Preparation System ...

Michel Goossens, Frank Mittelbach and Alexander Samarin The LATEX Companion ...

E. Somma LATEXBase 13/12/2007 39 / 61

Ambienti

Ambiente: Giustificazione paragrafi center, flushright, flushleft

1\begin{center}

2And the battles just begun\\

3Theres many lost , but tell me who has won\\

4The trench is dug within our hearts \\

5And mothers , children , brothers , sisters torn apart \\

6\ \\

7Sunday , bloody sunday \\

8Sunday , bloody sunday \\

9\end{center}� �And the battles just begun

Theres many lost, but tell me who has wonThe trench is dug within our hearts

And mothers, children, brothers, sisters torn apart

Sunday, bloody sundaySunday, bloody sunday

E. Somma LATEXBase 13/12/2007 40 / 61

Ambienti

Ambiente: Oggetti Volanti - figure

1\begin{center}

2\begin{figure }[h]

3\caption[Nella LOF]{Una bella figura}

4\vspace {5cm}

5\label{figone}

6\end{figure}

7\end{center}� �Figure: Una bella figura

E. Somma LATEXBase 13/12/2007 41 / 61

Ambienti

Ambiente: Oggetti Volanti - table

1\begin{center}

2\begin{table}[h]

3\caption[Nella LOT]{Una bella tabella}

4\vspace {5cm}

5\label{tabone}

6\end{table}

7\end{center}� �

Table: Una bella tabella

E. Somma LATEXBase 13/12/2007 42 / 61

Ambienti

Tabelle

1\begin{tabular }{ lccccccc}

2\multicolumn {7}{c}{\ text{Table 2 --- ’Pairwise $Z$-tests ’ and

3accessibility -adjusted ’pairwise $Z$-tests ’}} \\ \\

4\hline\hline

5\text{ISIC} \quad\ \text{Industry classification} & OECD & OECD [...]\\

6\hline

7& $M$ & $\%$ with $\ lambda $ & $\%$ with $\ lambda ^{\ mathrm{size }}$ & [...]

8\hline

9311 \qquad Food products & 20 & 54.2 & 59.5$^{\ mathbf {\ast \ast }}$ & 20 &

1043.2 & 43.2 \\� �

E. Somma LATEXBase 13/12/2007 43 / 61

Ambienti

Ambiente: equation

1\begin{equation}

2\mathrm{RMP}=\ Phi \mathrm{diag }(\Phi \lambda )^{ -1}

3\theta \leq \mathbf {1},\ label{equ}

4\end{equation}

5with the complementary slackness conditions

6\begin{equation *}

7(\ mathrm{RMP}_{i}-1)\ lambda _{i}=0

8\qquad i=1,2,\ ldots M.

9\end{equation *}� �RMP = Φdiag(Φλ)−1θ ≤ 1, (1)

with the complementary slackness conditions

(RMPi − 1)λi = 0 i = 1, 2, . . .M.

E. Somma LATEXBase 13/12/2007 44 / 61

Matematica

Matematica

1 Comandi

2 Ambienti

3 Matematica

4 Riferimenti Bibilografici

5 Titoli

E. Somma LATEXBase 13/12/2007 45 / 61

Matematica

Matematica Semplice

1\begin{equation}

2\sum_{j}

3\dfrac{\phi _{ij}\ theta_{j}}

4{\sum_{k}\phi _{kj}\ lambda _{k}}

5\leq 1,

6\qquad

7i=1,2,\ldots ,M. \label{firms 2}

8\end{equation}� �∑j

φijθj∑k φkjλk

≤ 1, i = 1, 2, . . . ,M. (2)

E. Somma LATEXBase 13/12/2007 46 / 61

Matematica

Matematica Semplice

1\mathrm{ri}(\ Delta )=

2\biggl\{

3x\in\mathbf {\ mathbb{R}}^M ,\;\;

4\sum_{i}x_{i}=1 ,\;\;

5x_{i}>0,\;

6\forall i\biggr \}.� �ri(∆) =

{x ∈ RM ,

∑i

xi = 1, xi > 0, ∀i

}. (3)

E. Somma LATEXBase 13/12/2007 47 / 61

Matematica

Matematica: Sistemi di equazioni

1\begin{eqnarray}

2\mathrm{RMP}_{i} &=&1

3\qquad \text{if }

4\qquad \lambda _{i}^{\ ast }>0, \notag

5\\

6\mathrm{RMP}_{i} &\leq &1

7\qquad \text{if }

8\qquad \lambda _{i}^{\ ast }=0.

9\label{firms3}

10\end{eqnarray}� �RMPi = 1 if λ∗i > 0,

RMPi ≤ 1 if λ∗i = 0. (4)

E. Somma LATEXBase 13/12/2007 48 / 61

Matematica

Matematica: Matrici e Vettori

1\Phi\equiv\left(

2\begin{array}{cccc}

3\phi _{11} &\phi _{12} &\cdots &\phi _{1M}\\

4\phi _{21} &\phi _{22} &\cdots &\phi _{2M}\\ \vdots &

5\vdots &\ ddots &\ vdots \\ \phi _{M1} &\phi _{M2} &\ cdots &\phi_{MM}

6\end{array}

7\right) ,\;\;

8\lambda \equiv \left ...� �

E. Somma LATEXBase 13/12/2007 49 / 61

Riferimenti Bibilografici

Riferimenti Bibilografici

1 Comandi

2 Ambienti

3 Matematica

4 Riferimenti Bibilografici

5 Titoli

E. Somma LATEXBase 13/12/2007 50 / 61

Riferimenti Bibilografici

Riferimenti bibliografici

Citazioni Riferimenti

a mano a mano (liste)(see Helpman, 1998) |\item Helpman, E. (1998) Explaining the struc-

ture of foreign trade, \emph{WeltwirtschaftlichesArchiv} 134, 573-589.

a mano harwarditem...

(see Helpman, 1998) \harvarditem{}{}{} Helpman, E. (1998)

Explaining the structure of foreign trade,

\emph{Weltwirtschaftliches Archiv} 134,

573-589.

BiBTeX cite cite{helpman:ft} \thebibliografy+\bibitem

BibTeX

E. Somma LATEXBase 13/12/2007 51 / 61

Riferimenti Bibilografici

thebibliograhy+bibitem

12\begin{thebibliography }{la -piu -lunga}

3\bibitem{lab:pippo} AuthorName , F., ’’Title ,’’ \textit{ Journal }

4\textbf{ volume} (number), (City , State , Country: Publisher ,

5day mon. year): page -page -

6...

7\end{thebibliography}� �bla bla (vedi \cite[p. 2]{lab:pippo}) bla bla

E. Somma LATEXBase 13/12/2007 52 / 61

Riferimenti Bibilografici

BibTeX

File bibliografico ’generico’ (si trovanoanche su internet) dei riferimenti(bibfile)

File di stile (si trova su internet)

Eliminare la sezione

\begin{thebibliography}

...

\end{thebibliography}

Aggiungere

\bibliographystyle{%

nomedellostile.bst}

\bibliography{bibfile}

E. Somma LATEXBase 13/12/2007 53 / 61

Riferimenti Bibilografici

Record BibTeX

@InProceedings{ fantechi:97,author = {A. Fantechi and Paolo Nesi and E. Somma},title = {Object-Oriented Analysis of COBOL},booktitle = csmr1,month = mar, year = {1997},publisher = ieeecsp,abstract = {The object-oriented paradigm is presently considered the onewhich best guarantees the investments for renewal. It allows to producesoftware with high degrees of reusability and maintainability, satisfyingin a certain measure also quality characteristics. These features are notobviously automatically guaranteed by the simple adoption of anobject-oriented programming language, a process of re- analysis is needed.In this view, several methods for reengineering old applications accordingto the object-oriented paradigm were defined and proposed. In this paper, amethod and tool (C2O2, COBOL to Object-Oriented) for analyzing COBOLapplications in order to extract its object-oriented analysis is presented.The tool identifies classes and their relationships by means of a process ofunderstanding and refinement in which COBOL data structures are analyzed,converted in classes, aggregated, and simplified semiautomatically. Thealgorithm is also capable of detecting data structures which can cause problemspassing to the next millennium, as demonstrated with an example.},class = {Reverse_Engineering, Reverse_Design,

Encapsulation_and_Finding_Objects_in_Legacy_Code},sender = {antonio@ifi.unizh.ch} }

E. Somma LATEXBase 13/12/2007 54 / 61

Riferimenti Bibilografici

BibTexMng

E. Somma LATEXBase 13/12/2007 55 / 61

Riferimenti Bibilografici

WibTeX

E. Somma LATEXBase 13/12/2007 56 / 61

Riferimenti Bibilografici

Aigaion

E. Somma LATEXBase 13/12/2007 57 / 61

Titoli

Titoli

1 Comandi

2 Ambienti

3 Matematica

4 Riferimenti Bibilografici

5 Titoli

E. Somma LATEXBase 13/12/2007 58 / 61

Titoli

Titoli e classificazione

1\title{Testing the ‘home market effect ’ in a multi -country [...] }

23\author{Kristian Behrens

4\thanks {\emph{Corresponding author }: CORE , Universit \’{e} catholique

5de Louvain , 34 voie du Roman Pays , 1348 Louvain -la-Neuve , Belgium.

6Phone: (+32)10474305. Fax: (+32)10474301. E-mail address:

7\texttt{behrens@core.ucl.ac.be}}

8Andrea R. Lamorgese

9\thanks{Research Department , Bank of Italy , Roma.}

10\and Gianmarco I.P. Ottaviano

11\thanks{Universit\‘{a} di Bologna (Italy), FEEM and CEPR.}

12Takatoshi Tabuchi

13\thanks{Faculty of Economics , University of Tokyo , Japan .}}

14\date{}

15\maketitle� �

E. Somma LATEXBase 13/12/2007 59 / 61

Titoli

Abstract e classificazione

1\begin{abstract}

2We propose a theory -based approach to testing the presence of the [...]

3\end{abstract}

45\textbf{Keywords: }home market effect; new trade theory; multi -country models;

6market potential; economic geography

7\textbf{JEL Classification :} D58; F12; F17; R12

89\newpage\begin{center }{}\ end{center}

1011\newpage\tableofcontents%\vspace {1.2 cm}\ newpage� �

E. Somma LATEXBase 13/12/2007 60 / 61

Titoli

Ringraziamenti

1\newpage

2\medbreak\noindent --------------------------------

3We wish to thank A.~Anas , M.~Br\"{u}lhart , D.~Davis , G.~Grossman ,K.~Head ,

4E.~Helpman , T.~Mayer , C.~Michelot , S.~Redding , F.~Trionfetti , J.~Suedekum ,

5and D.~Weinstein , as well as seminar participants at CORE Universit\’{e}

6catholique de Louvain , the University of Osaka , FEMES 2004, ERWIT 2004,

7HWWA Hamburg , and the RSAI 2004 North -American Meeting for helpful comments

8and discussions.

9\newpage

10\begin{doublespacing}

11\section{Introduction}� �

E. Somma LATEXBase 13/12/2007 61 / 61

Recommended