introducci´on a la escritura cient´ıfica en...

109
Introducci´ on a la escritura cient´ ıfica en L A T E X2 ε David G´ omez-Castro Departamento de An´ alisis Matem´ atico y Matem´ atica Aplicada Universidad Complutense de Madrid [email protected] https://blogs.mat.ucm.es/dgcastro Diciembre 2018 David G´ omez-Castro (UCM) Introducci´ on a L A T E X2ε Diciembre 2018 1 / 80

Upload: others

Post on 07-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Introduccion a laescritura cientıfica en

LATEX 2ε

David Gomez-Castro

Departamento de Analisis Matematico y Matematica AplicadaUniversidad Complutense de Madrid

[email protected]://blogs.mat.ucm.es/dgcastro

Diciembre 2018

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 1 / 80

Page 2: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Desarrollo del curso ISesion 1: Bienvenido a LATEX

1 Instalacion

2 ¡Hola Mundo! e ingredientes basicos

Sesion 2: LATEX para Matematicas

3 FormulasDistintos tipos de formulasSımbolosMatricesDiagramas

4 Teoremas

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 2 / 80

Page 3: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Desarrollo del curso IISesion 3: LATEX como editor de texto avanzado5 Insertando objetos

FigurasTablasCodigos

6 Formato avanzadoSecciones e ındicesEl formato de paginaEl formato de la Facultad

Sesion 4: Referencias7 Referencias a elementos del texto

EtiquetasReferencias basicas de LATEXEl paquete cleveref

8 Referencias a bibliografıaDavid Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 3 / 80

Page 4: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Desarrollo del curso IIISesion 5:

9 Presentaciones en Beamer

Sesion 6:

10 Graficos avanzadosDibujo libreRepresentacion de funcionesRepresentacion de datos

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 4 / 80

Page 5: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Material de apoyo

UrlGoogle. Si no: lmgtfy.comTEX Stack ExchangeThe not so short introduction to LaTeX2e (actualmente en 139minutos)

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 5 / 80

Page 6: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Sesion I

Bienvenido a LATEX

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 6 / 80

Page 7: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

¿Que es LATEX?

LATEX es un sistema de preparacion de documentos, utilizado endocumentos cientıficos y tecnicos.

LATEX ¡no es un procesador de textos! Nos permite separar el contenido delcontinente, dejando el formato a un lado.

Por eso, LATEX se escribe en documentos de texto “sin formato” con unacabecera que dice como sera el formato (tipo de letra, espaciados,margenes, tıtulos...).

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 7 / 80

Page 8: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

¿Por que LATEX?¿Quien lo usa?

1 Las principalesrevistas delmundo: Nature,Science, PNAS,PLOS, ...

2 Todas las revistasde Matematicas

3 Los profesores ensus apuntes (enla UCM y entodas partes)

1 0 D E C E M B E R 2 0 1 5 | V O L 5 2 8 | N A T U R E | 2 0 7

ARTICLEdoi:10.1038/nature16059

Undecidability of the spectral gapToby S. Cubitt1,2, David Perez-Garcia3,4 & Michael M. Wolf5

The spectral gap is one of the most important physical properties of a quantum many-body system, determining much of its low- energy physics. Gapped systems exhibit non-critical behaviour (for example, massive excitations and short-range correlations), whereas phase transitions occur when the spectral gap vanishes and the sys-tem exhibits critical behaviour (for example, massless excitations and long-range correlations). Many seminal results in condensed matter theory prove that specific systems are gapped or gapless, for exam-ple, that the Heisenberg chain is gapless for half-integer spin1 (later extended to higher dimensions2), or that the 1D AKLT (Affleck–Kennedy–Lieb–Tasaki) model is gapped3. Similarly, many famous and long-standing open problems in theoretical physics concern the presence or absence of a spectral gap. A paradigmatic example is the antiferromagnetic Heisenberg model in 1D with integer spins. The ‘Haldane conjecture’ that this model is gapped, first formulated in 19834, has yet to be rigorously proven despite strong supporting numerical evidence5. The same question in the case of 2D non-bipartite lattices such as the kagome lattice was posed in 19736. Numerical evidence7 strongly indicates that these systems may be topological spin liquids. This problem has attracted substantial attention8 because materials such as herbertsmithite9 have emerged whose interactions are well-approximated by the Heisenberg coupling. The presence of a spectral gap in these models remains one of the main unsolved ques-tions concerning the long-sought topological spin liquid phase. In the related setting of quantum field theory, one of the most notorious open problems again concerns a spectral gap—the Yang–Mills mass gap problem10. Proving the existence of a gap in Yang–Mills theory could provide a full explanation of the phenomenon of quark con-finement. Although there is strong supporting evidence of such a gap from numerical lattice quantum chromodynamics computations11, the problem remains open.

All of these problems are specific instances of the general spectral gap problem: given a quantum many-body Hamiltonian, is the system it describes gapped or gapless? Our main result is to prove that the spectral gap problem is undecidable in general. This involves more than merely showing that the problem is computationally or mathematically

hard. Although one may be able to solve the spectral gap problem in specific cases, our result implies that it is, in general, logically impossi-ble to determine whether a system is gapped or gapless. This statement has two meanings, and we prove both.

(1) The spectral gap problem is algorithmically undecidable: there cannot exist any algorithm that, given a description of the local inter-actions, determines whether the resultant model is gapped or gapless. This is the same sense in which the halting problem is undecidable12.

(2) The spectral gap problem is axiomatically independent: given any consistent recursive axiomatization of mathematics, there exist particular quantum many-body Hamiltonians for which the presence or absence of the spectral gap is not determined by these axioms. This is the form of undecidability encountered in Gödel’s incompleteness theorem13.

Precise statement of resultsIt is important to be precise in what we mean by the spectral gap prob-lem. To this end, we must first specify the systems we are considering. Because we are proving undecidability, the simpler the system, the stronger the result. We restrict ourselves to nearest-neighbour, trans-lationally invariant spin lattice models on a 2D square lattice of size L × L (which we later take to ∞), with local Hilbert space dimension d. Any such Hamiltonian HL is completely specified by at most three finite-dimensional Hermitian matrices describing the local interactions of the system: two d2 × d2 matrices hrow and hcol that specify the inter-actions along the rows and columns of the lattice, and a d × d matrix h1 that specifies any on-site interaction. All matrix elements will be algebraic numbers, and we normalize the interaction strength such that

=h h hmax , , 1row col 1 .We must also be precise in what we mean by ‘gapped’ and ‘gapless’

(see Fig. 1). Because quantum phase transitions occur in the ther-modynamic limit of arbitrarily large system size, we are interested in the spectral gap ∆(HL) = λ1(HL) − λ0(HL) as the system size L → ∞ (where λ0 and λ1 are the eigenvalues of HL with the smallest and second-smallest magnitude). We take ‘gapped’ to mean that the system has a unique ground state and a constant lower bound on the spectral gap:

The spectral gap—the energy difference between the ground state and first excited state of a system—is central to quantum many-body physics. Many challenging open problems, such as the Haldane conjecture, the question of the existence of gapped topological spin liquid phases, and the Yang–Mills gap conjecture, concern spectral gaps. These and other problems are particular cases of the general spectral gap problem: given the Hamiltonian of a quantum many-body system, is it gapped or gapless? Here we prove that this is an undecidable problem. Specifically, we construct families of quantum spin systems on a two-dimensional lattice with translationally invariant, nearest-neighbour interactions, for which the spectral gap problem is undecidable. This result extends to undecidability of other low-energy properties, such as the existence of algebraically decaying ground-state correlations. The proof combines Hamiltonian complexity techniques with aperiodic tilings, to construct a Hamiltonian whose ground state encodes the evolution of a quantum phase-estimation algorithm followed by a universal Turing machine. The spectral gap depends on the outcome of the corresponding ‘halting problem’. Our result implies that there exists no algorithm to determine whether an arbitrary model is gapped or gapless, and that there exist models for which the presence or absence of a spectral gap is independent of the axioms of mathematics.

1Department of Computer Science, University College London, Gower Street, London WC1E 6BT, UK. 2DAMTP, University of Cambridge, Centre for Mathematical Sciences, Wilberforce Road, Cambridge CB3 0WA, UK. 3Departamento de Análisis Matemático and IMI, Facultad de CC Matemáticas, Universidad Complutense de Madrid, Plaza de Ciencias 3, 28040 Madrid, Spain. 4ICMAT, C/Nicolás Cabrera, Campus de Cantoblanco, 28049 Madrid, Spain. 5Department of Mathematics, Technische Universität München, 85748 Garching, Germany.

© 2015 Macmillan Publishers Limited. All rights reserved

ARTICLERESEARCH

2 0 8 | N A T U R E | V O L 5 2 8 | 1 0 D E C E M B E R 2 0 1 5

∆(HL) ≥ γ > 0 for all sufficiently large L. We take ‘gapless’ to mean the system has continuous spectrum above the ground state in the thermodynamic limit.

Here gapped is not the negation of gapless; there are systems that fall into neither category. We adopt such strong definitions to delib-erately exclude ambiguous cases, such as systems with degenerate ground states. A Hamiltonian that is gapped or gapless according to the above definitions is recognized as such throughout the literature. We show that the spectral gap problem is undecidable even given that the Hamiltonian either has a unique ground state and a spectral gap of magnitude one, or has continuous spectrum above the ground state.

We prove this by showing that the halting problem for Turing machines can be encoded in the spectral gap problem, implying that the latter is at least as hard as the former. A Turing machine is a simple, abstract model of computation in which a head reads and writes sym-bols from some finite alphabet on an infinite tape and moves left or right, following a finite set of rules. The halting problem asks: given an initial input written on the tape, does the Turing machine halt? Turing proved that this problem is undecidable12; we relate it to the spectral gap problem in the following way.

Theorem 1We can explicitly construct a dimension d, d2 × d2 matrices A, B, C and D, and a rational number β > 0, which can be chosen to be as small as desired, such that

(i) A is Hermitian, with matrix elements in Z Z Zβ+ + β2

;(ii) B and C have integer matrix elements; and(iii) D is Hermitian, with matrix elements in 0, 1, β.For each positive integer n, define the local interactions of a transla-

tionally invariant, nearest-neighbour Hamiltonian H(n) on a 2D square lattice as

† †

α Π

β

( )= ( )=

= + ( + + + )ϕ ϕπ ( ) −π ( ) π −πϕ ϕ−| ( )| −| ( )|

h n nh Dh A B B C Ce e e ei n i n i i

1

row

col2 2n n

where ϕ( )= / | |−n n 2 n 1 is the rational number whose binary fraction expansion contains the binary digits of n after the decimal point, |ϕ(n)| denotes the number of digits in this expansion, α(n) ≤ β is an algebraic number that is computable from n, Π is a projector and the daggers denote Hermitian conjugation. Then

(i) the local interaction strength is ≤1 (that is, ( ) ( ) ≤h n h h n, , 11 row col ( ) ( ) ≤h n h h n, , 11 row col );

(ii) if the universal Turing machine halts on input n, the Hamiltonian H(n) is gapped with γ ≥ 1; and

(iii) if the universal Turing machine does not halt on input n, the Hamiltonian H(n) is gapless (that is, has continuous spectrum).

Theorem 1 implies that the spectral gap problem is algorithmically undecidable because the halting problem is. By a standard argument14 algorithmic undecidability also implies axiomatic independence. Both forms of undecidability extend to other low-temperature properties of quantum systems, such as critical correlations in the ground state. In fact, our method allows us to prove undecidability of any physical property that distinguishes a Hamiltonian from a gapped system with unique, product ground state.

Hamiltonian constructionWe first relate undecidability of the spectral gap to undecidability of another important physical quantity, the ground state energy density, which, for a 2D lattice, is given by λ= ( )/ρ

→∞E H Llim [ ]

LL0

2 . We then transform the halting problem into a question about ground state energy densities.

Reducing the ground state energy density problem to the spectral gap problem requires two ingredients.

(1) It requires a translationally invariant Hamiltonian Hu(ϕ) on a 2D square lattice with local interactions hu(ϕ), whose ground state energy density is either strictly positive or tends to zero from below in the thermodynamic limit, depending on the value of an external parame-ter ϕ; however, determining which case holds should be undecidable. Constructing such a Hamiltonian constitutes the main technical work of our result. (These properties of Hu(ϕ) are unaffected if we multiply hu(ϕ) by an arbitrary fixed rational number β, no matter how small.)

(2) It requires a gapless Hamiltonian Hd with translationally invariant local interactions hd and a ground state energy of zero. (Recall that by ‘gapless’ we mean continuous spectrum above the ground state, not merely a vanishing spectral gap.) There are many well-known examples of such Hamiltonians, for example, that associated with the critical XY model1.

Given Hamiltonians with these properties, we construct a new trans-lationally invariant Hamiltonian, with local interactions h(ϕ), that is gapped or gapless depending on the value of ϕ. The local Hilbert space of h(ϕ) is the tensor product of those of hu and hd together with one additional energy level: = | ⟩⊕ ⊗H H H0 u d . We take the interaction h(i, j) between nearest-neighbour sites i and j to be

ϕ ϕ( ) = | ⟩⟨ | ⊗ ( −| ⟩⟨ |) + ( )⊗

+ ⊗( )

( ) ( ) ( ) ( ) ( )

( ) ( )

! !

!

h h

h

0 0 0 01

i j i j i j i j

i j i j

,u

,d

,

u,

d,

The spectrum of the new Hamiltonian H is

ϕ= ( )+ ( )∪ ∪H H H Sspec 0 spec spec 2u d

with S ≥ 1 (see Supplementary Information for details). Recalling that we chose Hd to be gapless, we see immediately from equation (2) that if the ground state energy density of Hu tends to zero from below (so that λ0(Hu) < 0), then H(ϕ) is gapless; if Hu has a strictly positive ground state energy density (so that λ0(Hu) diverges to +∞), then it has a spectral gap ≥1, as required (see Fig. 2).

This construction is rather general: by choosing different hd, we obtain undecidability of any physical property that distinguishes a Hamiltonian from a gapped system with a unique product ground state.

Encoding computation in ground statesTo construct the Hamiltonian Hu(ϕ), we encode the halting problem into the local interactions hu(ϕ) of the Hamiltonian. The halting prob-lem concerns the dynamics of a classical system—a Turing machine. To relate it to the ground state energy density—a static property of a quantum system—we construct a Hamiltonian whose ground state encodes the entire history of the computation carried out by the Turing

Figure 1 | Gapped and gapless systems. a, A gapped system has a unique ground state λ0(H) and a constant lower-bound γ on the spectral gap ∆(H) = λ1 − λ0 in the thermodynamic limit. b, A gapless system has continuous spectrum λi(H) above the ground state in the thermodynamic limit.

Oi(H)

(H) ≥ JΔO1

O0O0

a b

© 2015 Macmillan Publishers Limited. All rights reserved

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 8 / 80

Page 9: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Descargar e instalar LATEX

Esta experiencia depende del sistema utilices: visita Latex projectWindows: MikTeXMac: MacTeXLinux: a traves del gestor software nativo de terminal

Debian/Ubuntu: sudo apt-get install texlive-fullRedHat/Fedora: yum install texlive-scheme-fullSuse: zypper install texlive-latexArch: pacman -S texlive-mostOtros: ¿en serio? ¿ninguno de los anteriores?. Te buscas la vida.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 9 / 80

Page 10: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Descargar el editorTeXstudio

Durante esta lecciones utilizaremos el editor TeXstudio. Es libre ygratuito1.

Hay mas opciones:1 TeXShop2 TexMaker3 Gummy4 Atom (requiere alguna configuracion)5 Emacs, Vim, etc... + compilacion por terminal

1Los usuarios de Linux lo pueden descargar por terminalDavid Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 10 / 80

Page 11: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeXstudio

Figura: Interfaz de TeXstudio

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 11 / 80

Page 12: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El archivo mınimo

Los archivos de LATEX son archivos de texto (plano) con extension .tex.

Aquı es donde decidimos que tipo de archivo latex queremos escribir, haydiferentes tipos de documentos

Codigo\documentclass<style>

% Configuracion del archivo

\begindocument

% El texto

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 12 / 80

Page 13: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El archivo ¡Hola Mundo!

Aquı es donde decidimos que tipo de archivo latex queremos escribir, haydiferentes tipos de documentos

Codigo [hola-mundo.tex]\documentclassarticle

\begindocument

Hola Mundo

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 13 / 80

Page 14: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Compilando con TeXstudio

Figura: Compilar con TeXstudio

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 14 / 80

Page 15: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Compilando en terminal

Navegar hasta la carpeta y escribir en terminal

latex hola-mundo.tex

En archivos mas complicados hay que ejecutar el codigo varias veces

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 15 / 80

Page 16: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Cabecera y tipo de documento

En la cabecera introduciremos todo lo relativo a configuracion

Codigo\documentclass<style>

% Configuracion del archivo

\begindocument

% El texto

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 16 / 80

Page 17: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Tipo de documento

Aquı es donde decidimos que tipo de archivo latex queremos escribir, haydiferentes tipos de documentos

<style>:1 article Para artıculos

cortos. Acepta partes,secciones y subsecciones

2 book

Codigo\documentclass<style>

% Configuracion del archivo

\begindocument

% El texto

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 17 / 80

Page 18: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Tipo de documento

Aquı es donde decidimos que tipo de archivo latex queremos escribir, haydiferentes tipos de documentos

<style>:

1 article

2 book Para archivos masextensos. Acepta partes,capıtulos, secciones,subsecciones

Codigo\documentclass<style>

% Configuracion del archivo

\begindocument

% El texto

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 17 / 80

Page 19: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El cuerpo

A partir de aquı escribiremos el texto

Todo lo que queramosescribir.

Codigo\documentclass<style>

% Configuracion del archivo

\begindocument

% El texto

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 18 / 80

Page 20: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Comandos y variables

Una herramienta fundamental en la escritura con LATEX

<command> Nombre delcomando<opt> Argumentooptativo.<arg> Argumentoobligatorio

Codigo (llamada a comando)\<command>[<opt>]<arg1><arg2>

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 19 / 80

Page 21: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Entornos

Los entornos funcionan como comandos, pero nos permiten introducircantidades mas largas de texto.

Algunos ejemplos sondocument: Es dondeintroducimos eldocumentoequation: Paraintroducir ecuacionesnumeradasemph: Para conseguirtextos en cursiva.

Codigo\begin<env>[<opt>]

\end<env>

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 20 / 80

Page 22: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Los paquetesPor defecto LATEX no incluye demasiados comandos ni entornos. Podemosanadir nuevas funcionalidades (comandos y entornos) incluyendopaquetes.

Uno de los paquetes mas usuales es el paquete matematico de la AmericanMathematical Society (AMS): amsmath.

Codigo\documentclassarticle

\usepackageamsmath

\begindocument

\beginequation\sum_i=1ˆ3 a_i = 1.\endequation

\enddocument

3∑

i=1

ai = 1. (1)

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 21 / 80

Page 23: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Creando comandos

Codigo\documentclassstandalone

\newcommand\deciralgo[1]Esto es lo que digo: ‘‘#1’’.Y no me arrepiento.

\begindocument\deciralgoHola

\enddocument

Esto es lo que digo: “Hola”. Y no me arrepiento.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 22 / 80

Page 24: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El fichero y compatibilidadesEl paquete inputenc

Para mayor compatibilidad, especialmente entre sistemas operativos esrecomendable guardar los archivos de .tex en formato UTF8. Esto nospermitira poner acentos de manera sencilla.

Para indicarle al compilar quehemos hecho eso escribimos.

Codigo\documentclass<style>

\usepackage[utf8]inputenc

\begindocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 23 / 80

Page 25: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El fichero y compatibilidadesEl paquete inputenc

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 24 / 80

Page 26: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El paquete babel

Para que LATEX ponga todos los textos automaticos en castellanodeberemos anadir el paquete babel

Para indicarle al compilar quehemos hecho eso escribimos.

Codigo\documentclass<style>

\usepackage[spanish]babel

\begindocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 25 / 80

Page 27: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Ficheros modulares: inputEscribir un libro completo en un unico archivo no es comodo. Por esoLATEX permite escribir modularmente.Podemos escribir en diferentes archivos .tex, y luego juntarlos en unprincipal.

Codigo [modular.tex]\documentclassstandalone\begindocument

\inputmodulo1.tex\inputmodulo2.tex

\enddocument

Codigo [modulo1.tex]Un texto.

Codigo [modulo2.tex]Otro texto.

Un texto. Otro texto.

Figura: Resultado de compilarmodular.tex

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 26 / 80

Page 28: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Aspecto de un primer documento

Codigo (ejemplo1.tex)\documentclassarticle

\usepackage[utf8]inputenc\usepackage[spanish]babel

\titleMi trabajo a \LaTeX\authorYo \\ Y mi amigo\date\today

\begindocument

\maketitle

Este es el principio de mi trabajo.

\enddocument

Mi trabajo a LATEX

YoY mi amigo

23 de marzo de 2013

Este es el principio de mi trabajo.

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 27 / 80

Page 29: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Colaboracion en LATEXLATEX se lleva bien con la colaboracion en Dropbox. Naturalmente, espreferible que solo una persona edite cada .tex. Por eso, en grupo, esbuena idea trabajar en modulos.

Otra opcion es usar algun sistema online. Por ejemplo, Overleaf2.

2El sistema ShareLatex es ahora parte de OverleafDavid Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 28 / 80

Page 30: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Sesion II

LATEX para Matematicas

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 29 / 80

Page 31: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Escribiendo formulas

Hay diferentes entornos para escribir formulas:

1 En lınea

2 Presentada3 equation4 align

CodigoPuedo escribir $eˆi\pi + 1= 0$

Puedo escribir eiπ + 1 = 0

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 30 / 80

Page 32: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Escribiendo formulas

Hay diferentes entornos para escribir formulas:

1 En lınea2 Presentada

3 equation4 align

CodigoPuedo escribir$$ eˆi\pi + 1 = 0$$

Puedo escribir

eiπ + 1 = 0

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 30 / 80

Page 33: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Escribiendo formulas

Hay diferentes entornos para escribir formulas:

1 En lınea2 Presentada3 equation

4 align

CodigoPuedo escribir\beginequation

eˆi\pi + 1 = 0\endequation

Puedo escribir

eiπ + 1 = 0 (1)

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 30 / 80

Page 34: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Escribiendo formulas

Hay diferentes entornos para escribir formulas:

1 En lınea2 Presentada3 equation4 align

CodigoPuedo escribir\beginalign

eˆi\pi + 1 &= 0 \\eˆi\pi &= -1

\endalign

Puedo escribir

eiπ + 1 = 0 (1)eiπ = −1 (2)

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 30 / 80

Page 35: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Sımbolos utiles

+ + ε \varepsilon ab \fracab

− - δ \delta√

a \sqrta× \times ∂ \partial ab aˆb÷ \div Ω \Omega· \cdot π \pi⊕ \oplus⊗ \otimes

La web Detexify permite buscar sımbolos a partir de un dibujo a manoalzada.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 31 / 80

Page 36: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

La ecuacion mas bella del mundo

La ecuacion de Euler, popular por contener algunas de las mas importantesconstantes matematicas puede escribirse

Codigoeˆi\pi + 1 = 0

eiπ + 1 = 0

CodigoPuedo escribir la ecuacionde Euler $eˆi \pi + 1 = 0$en lınea o presentada$$ eˆi\pi + 1 = 0$$para que quede mejor

Puedo escribir la ecuacion deEuler eiπ + 1 = 0 en lınea opresentada

eiπ + 1 = 0

para que quede mejor

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 32 / 80

Page 37: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Subındices y superındices

Los subındices de sumarios e integrales cambian de formato presentado aen lınea

CodigoEn lınea digo$\sum_i=1ˆn \int_aˆb$mientras que presentado$$ \sum_i=1ˆn \int_aˆb $$

En lınea digo∑n

i=1∫ b

a mien-tras que presentado

n∑i=1

∫ b

a

Ademas la funcion \substack es muy util

Codigo$$\max_\substacky \in \Omega \\ |y| > 1$$

maxy∈Ω|y |>1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 33 / 80

Page 38: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Subındices y superındices

Los subındices de sumarios e integrales cambian de formato presentado aen lınea

CodigoEn lınea digo$\sum_i=1ˆn \int_aˆb$mientras que presentado$$ \sum_i=1ˆn \int_aˆb $$

En lınea digo∑n

i=1∫ b

a mien-tras que presentado

n∑i=1

∫ b

a

Ademas la funcion \substack es muy util

Codigo$$\max_\substacky \in \Omega \\ |y| > 1$$

maxy∈Ω|y |>1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 33 / 80

Page 39: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Matrices

Las matrices se introducen siempre en entornos matematicos. Maple ymatlab permiten exportar matrices a LATEX. Hay distintos tipos de matricespredeterminadas en el paquete amsmath.

1 matrix Sin bordes2 pmatrix Entre ()3 vmatrix Entre | |4 bmatrix Entre [ ]

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 34 / 80

Page 40: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

MatricesEjemplo

Codigo$$\beginpmatrix1 & 2 & 3 \\4 & 5 & \\6 & & 7\endpmatrix$$

1 2 34 56 7

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 35 / 80

Page 41: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

MatricesEjemplo

Codigo$$\beginbmatrix1 & 2 & 3 \\4 & 5 & \\6 & & 7\endbmatrix$$

1 2 34 56 7

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 36 / 80

Page 42: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El paquete xy-pic

Este paquete se emplea para hacer todo tipo de graficos, por ejemplo eldiagrama

A f //

gf

Bg

CTiene infinidad de opciones.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 37 / 80

Page 43: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

xymatrix

Es la manera mas sencilla de introducir diagramas. Los elementos que seconectaran por flechas se introducen en las posiciones de una matriz, detipo xymatrix

Codigo\xymatrixA & B \\& C

A B

C

Se puede introducir una xymatrix dentro o fuera de formulas, perodeberemos tener cuidado con el contenido.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 38 / 80

Page 44: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las flechas

Dentro de una xymatrix podemos introducir flechas con el comando \arAdmite varios modificadores

1 Destino Colocando laflecha en la casilla de laque parte se coloca uncadena de cuantascasillas a derecha oizquierda y arriba oabajo esta el destino.\ar [<hop>]

2 Etiqueta3 Tipo4 Curvatura5 Entrada y salida

u arribad abajor derechal izquierda

a si misma

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 39 / 80

Page 45: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las flechas

Dentro de una xymatrix podemos introducir flechas con el comando \arAdmite varios modificadores

1 Destino2 Etiqueta Se puede

escribir sobre las letras

3 Tipo4 Curvatura5 Entrada y salida

\ar [r]ˆf a f // b\ar [r]_f a

f// b

\ar [r]|f a f // b

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 39 / 80

Page 46: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las flechas

Dentro de una xymatrix podemos introducir flechas con el comando \arAdmite varios modificadores

1 Destino2 Etiqueta3 Tipo Hay distintos tipos

de base, cuerpos ycabezas de flecha\ar @<type>[<hop>]

4 Curvatura5 Entrada y salida

@=> a +3 b@.> a // b@:> a +3 b@˜> a // b@--> a // b@|-> a // b

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 39 / 80

Page 47: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las flechas

Dentro de una xymatrix podemos introducir flechas con el comando \arAdmite varios modificadores

1 Destino2 Etiqueta3 Tipo4 Curvatura Podemos

curvar las flechas haciaarriba y hacia abajo,para evitar que secorten, o solo para quedemas estiloso \ar@/<curve>/ [<hop>]

5 Entrada y salida

@/_/ a 66 b@/ˆ/ a (( b@/_1mm/ a 22 b

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 39 / 80

Page 48: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las flechas

Dentro de una xymatrix podemos introducir flechas con el comando \arAdmite varios modificadores

1 Destino2 Etiqueta3 Tipo4 Curvatura5 Entrada y salida Si

queremos que la flechasalga desde una parte enconcreto de la celdapodemos especificarlo\ar@(<in>,<out>)[<hop>]

@(u,d)[r] a LLb@(ur,dr)[] a dd b

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 39 / 80

Page 49: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las flechasEjercicioEscriba el siguiente diagrama:

A

f !!B // _

C idyy

D

Codigo (ejercicio3.tex)$$\xymatrix

A \ar@/_2ex/[ddr] \ar[dr]|f \ar@/ˆ2ex/[drr] \\& B \ar@-->[r] \ar@ˆ(->[d] & C\ar@(dr,ur)[]_id \\& D

$$

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 40 / 80

Page 50: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las flechasEjercicioEscriba el siguiente diagrama:

A

f !!B // _

C idyy

D

Codigo (ejercicio3.tex)$$\xymatrix

A \ar@/_2ex/[ddr] \ar[dr]|f \ar@/ˆ2ex/[drr] \\& B \ar@-->[r] \ar@ˆ(->[d] & C\ar@(dr,ur)[]_id \\& D

$$

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 40 / 80

Page 51: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El paquete xy-pic y el paquete babel

El paquete babel entra en conflicto con @ ası que si queremos hacerbuenos diagramas debemos desactivarlo. Empleando inputenc con utf8no tendremos problemas con los acentos. Debemos cambiar los nombresde capıtulos y secciones. Para ello \renewcommand<command><new_name>

\abstractname Abstract\appendixname Appendix\bibname Bibliography (report,book)\chaptername Chapter (report,book)\contentsname Contents\figurename Figure (for captions)\indexname Index\listfigurename List of Figures\listtablename List of Tables\tablename Table (for caption)

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 41 / 80

Page 52: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeoremasEl paquete amsthm

A la hora definir un teorema debemos tener en cuenta tres cosas1 El estilo: Los teoremas

se escriben en cursiva,mientras que lasdefiniciones se escribencon fuente normal.

2 El nombre3 La numeracion

Codigo\documentclass(...)\theoremstyle <style>\newtheorem <env><name>(...)\begin document

Hay tres estilos predefinidos:plain Theorem 1.Theorem text.

definition Definition 1. Definition text.remark Remark 1.Remark text.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 42 / 80

Page 53: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeoremasEl paquete amsthm

A la hora definir un teorema debemos tener en cuenta tres cosas1 El estilo2 El nombre: Debemos

poner un nombre deentorno <env>, ya seateorema (por ejemplo<env>=teorema) unnombre para mostrar enel documento (porejemplo<name>=Teorema)

3 La numeracion

Codigo\documentclass(...)\theoremstyle <style>\newtheorem <env><name>(...)\begin document

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 42 / 80

Page 54: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeoremasEl paquete amsthm

A la hora definir un teorema debemos tener en cuenta tres cosas

1 El estilo2 El nombre3 La numeracion: Podemos

numerar los teoremas dediferentes maneras

Codigo\documentclass(...)\theoremstyle <style>\newtheorem <env><name>(...)\begin document

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 42 / 80

Page 55: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeoremasEl paquete amsthm

A la hora definir un teorema debemos tener en cuenta tres cosas1 El estilo2 El nombre3 La numeracion

a) Con su propio contador:El contador se crea pordefecto si no decimosnada mas, y se nombraautomaticamente como<env>

b) Siguiendo lanumeracion de otroteorema ya definido

c) Supeditada a otrocontador, por ejemplola seccion.

Codigo\documentclass(...)\theoremstyle <style>\newtheorem <env><name>(...)\begin document

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 42 / 80

Page 56: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeoremasEl paquete amsthm

A la hora definir un teorema debemos tener en cuenta tres cosas1 El estilo2 El nombre3 La numeracion

a) Con su propio contador:b) Siguiendo la

numeracion de otroteorema ya definido

c) Supeditada a otrocontador, por ejemplola seccion.

Codigo\documentclass(...)\theoremstyle <style>\newtheorem <env> [<counter>]<name>(...)\begin document

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 42 / 80

Page 57: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeoremasEl paquete amsthm

A la hora definir un teorema debemos tener en cuenta tres cosas1 El estilo2 El nombre3 La numeracion

a) Con su propio contador:b) Siguiendo la

numeracion de otroteorema ya definido

c) Supeditada a otrocontador, por ejemplola seccion. En este casoel contador de tipo a)lleva como predecesorel otro contador, y seresetea al cambiar elcontador al quesupedita

Codigo\documentclass(...)\theoremstyle <style>\newtheorem <env><name>[<counter>](...)\begin document

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 42 / 80

Page 58: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TeoremasEjemplo

Este es el aspecto de un teorema normal definido con el paquete amsthm.

Codigo (ejemplo2.tex)\documentclassarticle\usepackageamsthm

\theoremstyleplain\newtheoremteoremaTeorema

\begindocument

\beginteorema[Euclides]No existe un primo mayor que el resto.\endteorema

\enddocument

Teorema 1 (Euclides) . Noexiste un primo mayor que elresto.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 43 / 80

Page 59: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Operadores matematicos

Con el paquete amsmath se pueden definir operadores matematicos, comodiv o rot:

\DeclareMathOperator \rot rot

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 44 / 80

Page 60: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Ejercicio

Escribir el siguiente documento LATEX

El teorema de la divergencia

Un estudiante

10 de abril de 2013

1. El teorema

El teorema de la divergencia de Gauss se enuncia de la siguiente manera

Teorema 1.1. Dado ....

Demostracion. La prueba...

2. Ejercicios

Ejercicio 1. Este ejercicio

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 45 / 80

Page 61: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Solucion

Codigo(ejercicio1.tex)\documentclassarticle

\usepackage[spanish]babel\usepackage[utf8]inputenc\usepackageamsthm

\theoremstyleplain\newtheoremthmTeorema[section]\theoremstyledefinition\newtheoremexEjercicio

\titleEl teorema de la divergencia\authorUn estudiante

\begindocument\maketitle

Codigo (ejemplo3.tex)\sectionEl teorema

El teorema de la divergencia de Gaussse enuncia de la siguiente manera

\beginthmDado ....

\endthm\beginproof

La prueba...\endproof

\sectionEjercicios

\beginexEste ejercicio

\endex

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 46 / 80

Page 62: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Sesion III

LATEX como editor de textoavanzado

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 47 / 80

Page 63: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Flotantes y su localizacion

Los objetos con los que vamos a trabajar: figuras, tablas, etc... se conocen comoflotantes.

Por defecto LATEX los coloca donde menos moleste: en el lugar del texto dondehemos colocado el codigo, al principio de la pagina o al final de la pagina.

Podemos especificar donde colocarlos mediante parametros optativos:\begin figure[placement specifier].

Las opciones son las siguientes

Specifier Permissionh Place the float here (approximately at the same point it occurs in the source text)t Position at the top of the page.b Position at the bottom of the page.p Put on a special page for floats only.! Override internal parameters LaTeX uses for determining “good” float positions.H Places the float at precisely the location in the LaTeX code. Requires the float package.

Tambien se admiten cadena htb significa: intentalo en su sitio, si no ponlo arribay, si no, abajo.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 48 / 80

Page 64: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Flotantes y su localizacion

Los objetos con los que vamos a trabajar: figuras, tablas, etc... se conocen comoflotantes.

Por defecto LATEX los coloca donde menos moleste: en el lugar del texto dondehemos colocado el codigo, al principio de la pagina o al final de la pagina.

Podemos especificar donde colocarlos mediante parametros optativos:\begin figure[placement specifier].

Las opciones son las siguientes

Specifier Permissionh Place the float here (approximately at the same point it occurs in the source text)t Position at the top of the page.b Position at the bottom of the page.p Put on a special page for floats only.! Override internal parameters LaTeX uses for determining “good” float positions.H Places the float at precisely the location in the LaTeX code. Requires the float package.

Tambien se admiten cadena htb significa: intentalo en su sitio, si no ponlo arribay, si no, abajo.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 48 / 80

Page 65: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Figuras

Para incluir imagenes empleamos el paquete graphicx. Si empleamos elcompilador pdflatex. Podemos emplear imagenes .pdf, .png.

Tiene los siguientes parametros:1 <path> Es la direccion del

archivo a incluir. Lo mejor esescribirla relativa al directorioesto es <path>=archivo.pdf

2 <scale>3 <caption>

Codigo\beginfigure[h!]\includegraphics [scale= <scale>] <path>\caption <caption>

\end figure

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 49 / 80

Page 66: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Figuras

Para incluir imagenes empleamos el paquete graphicx. Si empleamos elcompilador pdflatex. Podemos emplear imagenes .pdf, .png.

Tiene los siguientes parametros:1 <path>2 <scale> Valor entre 0 y 1 al

que escalar la figura.

3 <caption>

Codigo\beginfigure[h!]\includegraphics [scale= <scale>] <path>\caption <caption>

\end figure

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 49 / 80

Page 67: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Figuras

Para incluir imagenes empleamos el paquete graphicx. Si empleamos elcompilador pdflatex. Podemos emplear imagenes .pdf, .png.

Tiene los siguientes parametros:1 <path>2 <scale>3 <caption> El contenido de

<caption> sera el pie de foto,es decir, aparecera Figura x:caption

Codigo\beginfigure[h!]\includegraphics [scale= <scale>] <path>\caption <caption>

\end figure

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 49 / 80

Page 68: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

FiguraEjemplo

Codigo\documentclassarticle

\usepackagegraphicx

\begindocument

\beginfigure

\centering\includegraphics[scale=0.5]

gauss.pdf\captionGauss

\endfigure

\enddocument

Figure 1: Gauss

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 50 / 80

Page 69: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Tablas

Las el entorno table es equivalente a figura, pero al generar el captionobtendremos Cuadro (como recomiendo la RAE).

En contenido de la tabla se introduce de manera similar a una matriz1 <align>:

a) l: izquierdab) c: centradoc) r: derecha

2 &3 |4 \hline

Codigo\begintabular<align>| ...

cuadro1 & cuadro2 & ... \\\hline\\...

\endtabular

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 51 / 80

Page 70: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Tablas

Las el entorno table es equivalente a figura, pero al generar el captionobtendremos Cuadro (como recomiendo la RAE).

En contenido de la tabla se introduce de manera similar a una matriz

1 <align>:2 & Separacion entre

cuadros en la misma fila

3 |4 \hline

Codigo\begintabular<align>| ...

cuadro1 & cuadro2 & ... \\\hline\\...

\endtabular

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 51 / 80

Page 71: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Tablas

Las el entorno table es equivalente a figura, pero al generar el captionobtendremos Cuadro (como recomiendo la RAE).

En contenido de la tabla se introduce de manera similar a una matriz1 <align>:2 &3 | Si se desea lınea

vertical entre doscolumnas

4 \hline

Codigo\begintabular<align>| ...

cuadro1 & cuadro2 & ... \\\hline\\...

\endtabular

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 51 / 80

Page 72: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Tablas

Las el entorno table es equivalente a figura, pero al generar el captionobtendremos Cuadro (como recomiendo la RAE).

En contenido de la tabla se introduce de manera similar a una matriz

1 <align>:2 &3 |4 \hline Si se desea una

lınea horizontal.

Codigo\begintabular<align>| ...

cuadro1 & cuadro2 & ... \\\hline\\...

\endtabular

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 51 / 80

Page 73: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

TablasEjemplo

Codigo\begintable

\begintabularc|l r|1 & 2 & 3 \\\hline4 & 5 & \\6 & & 7\endtabular

\captionMi tabla\endtable

1 2 34 56 7

Cuadro: Mi tabla

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 52 / 80

Page 74: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Anadir codigo

El paquete listing nos permite introducir codigo de diferentes lenguajes

Codigo\documentclassstandalone

\usepackagelistings

\begindocument

\beginlstlisting#include<stdio.h>main()printf("Hello World");\endlstlisting

\enddocument

#inc lude<s t d i o . h>main ( )p r i n t f (” He l lo World ” ) ;

Figura: Resultado de compilar

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 53 / 80

Page 75: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Anadir codigo

Tambien se puede cargar de un fichero externo

Codigo [ejemplo-c-2.tex]\documentclassstandalone

\usepackagelistings

\begindocument\lstinputlisting[language=C++]codigo2.cpp\enddocument

Codigo [codigo2.cpp]#include<stdio.h>main()printf("Hello World");

#include<s t d i o . h>main ( )p r i n t f ( ”He l lo World” ) ;

Figura: Resultado de compilarejemplo-c-2.tex

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 54 / 80

Page 76: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Anadir codigo: ColoresCodigo\documentclassstandalone

\usepackagelistings,xcolor\begindocument

\lstsetlanguage=C++,keywordstyle=\colorblue,stringstyle=\colorred,commentstyle=\colorgreen,morecomment=[l][\colormagenta]\#

\beginlstlisting#include<stdio.h>main()printf("Hello World");\endlstlisting

\enddocument

#inc lude<s t d i o . h>main ( )p r i n t f ( ”He l lo World” ) ;

Figura: Resultado de compilar

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 55 / 80

Page 77: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Anadir codigo MATLABMathWorks ofrece un paquete (a descargar aquı) para incluir codigo conformato de matlab

Codigo[Ejemplo de mcode]\documentclassstandalone

\usepackagelisting\usepackagexcolor\usepackagemcode

\begindocument\lstinputlistingcodigo1.m

\enddocument

Codigo[codigo1.m]% Mi codigo matlaba = 1;

% Mi codigo matlaba = 1;

Figura: Resultado de compilarejemplo-mcode.tex

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 56 / 80

Page 78: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Secciones e ındicesNaturalmente LATEX permite estructurar el documento en secciones.

Para empezar una nueva seccion con tıtulo basta con indicarlo y dar untıtulo utilizando los siguientes comandos:

-1 \part titulo0 \chapter titulo1 \section titulo2 \subsection titulo3 \subsubsection titulo4 \paragraph titulo5 \subparagraph titulo

Se puede generar el ındice introduciendo \tableofcontents . Estecomando admite parametros optativos.

Tambien se pueden hacer otras tablas de contenidos: \listoffigures ,\listoftables .

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 57 / 80

Page 79: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Secciones e ındicesNaturalmente LATEX permite estructurar el documento en secciones.

Para empezar una nueva seccion con tıtulo basta con indicarlo y dar untıtulo utilizando los siguientes comandos:

-1 \part titulo0 \chapter titulo1 \section titulo2 \subsection titulo3 \subsubsection titulo4 \paragraph titulo5 \subparagraph titulo

Se puede generar el ındice introduciendo \tableofcontents . Estecomando admite parametros optativos.

Tambien se pueden hacer otras tablas de contenidos: \listoffigures ,\listoftables .

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 57 / 80

Page 80: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Secciones e ındicesNaturalmente LATEX permite estructurar el documento en secciones.

Para empezar una nueva seccion con tıtulo basta con indicarlo y dar untıtulo utilizando los siguientes comandos:

-1 \part titulo0 \chapter titulo1 \section titulo2 \subsection titulo3 \subsubsection titulo4 \paragraph titulo5 \subparagraph titulo

Se puede generar el ındice introduciendo \tableofcontents . Estecomando admite parametros optativos.

Tambien se pueden hacer otras tablas de contenidos: \listoffigures ,\listoftables .

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 57 / 80

Page 81: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Secciones e ındicesNaturalmente LATEX permite estructurar el documento en secciones.

Para empezar una nueva seccion con tıtulo basta con indicarlo y dar untıtulo utilizando los siguientes comandos:

-1 \part titulo0 \chapter titulo1 \section titulo2 \subsection titulo3 \subsubsection titulo4 \paragraph titulo5 \subparagraph titulo

Se puede generar el ındice introduciendo \tableofcontents . Estecomando admite parametros optativos.

Tambien se pueden hacer otras tablas de contenidos: \listoffigures ,\listoftables .

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 57 / 80

Page 82: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El paquete fancyhdr

Una forma sencilla de darle un buen estilo a nuestro archivo es emplear elpaquete fancyhdr. Tiene varias opciones, lo mas sencillo es emplear unpaquete predefinido

Codigo\usepackagefancyhdr\pagestyle<style>

<style>:Encabezado Pie de pagina

empty Vacıo Vacıoplain Vacıo Numero de pagina centrado

headings Nombre del capıtulo y numero de pagina Vacıomyheadings Numero de pagina y otros Vacıo

fancy Capıtulo y seccion Numero de pagina

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 58 / 80

Page 83: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El formato de la FacultadLa Facultad va a incorporar un formato de TFG en el que toda el formatonecesario va preparada en la clase UCMmatTFG.

Codigo. Uso de UCMmatTFG\documentclassclases/UCMmatTFG

[...]\begindocument

[...]%% ************************* Capitulos *************************%% Se recomienda escribir cada capitulo en un archivo distinto%% para evitar grandes tamano de archivos

\pagestylecuerpo-tfg %Cambiar formato de pagina

% Introducimos el primer capitulo\inputcap1/intro

% Capitulo 2\inputcap2/cap2

% Capitulo 3%\inputcap3/cap3

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 59 / 80

Page 84: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Sesion IV

Referencias

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 60 / 80

Page 85: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Referencias

Para establecer una etiqueta a la que poder llamar se emplea\label<label>

Es habitual emplear etiquetas de la forma<label>=thm:euclides, fig:gauss, eq:divergencia

No se pueden emplear acentos.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 61 / 80

Page 86: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

ReferenciasEjemplo

Codigo\begin<thm> \label<label>

\end<thm>

Codigo\beginfigure

\includegraphics<path>\caption<caption>\label<label>

\endfigure

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 62 / 80

Page 87: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Referencias: El comando \ref

Podemos llamar al numero de una etiqueta mediante \ref <label>.

Solucion\documentclassarticle

\usepackage[spanish]babel\usepackage[utf8]inputenc\usepackagegraphicx

\newtheoremthmTeorema

\begindocument

\beginthm \labelthm:euclidesNo hay primo mayor que el resto\endthm\beginfigure[h!]

\centering\includegraphics[scale=0.5]euclides.pdf\captionEuclides\labelfig:euclides

\endfigureEuclides, al que podemos ver en laFigura˜\reffig:euclides, propusoy demostro el Teorema˜\refthm:euclides.

\enddocument

Ejercicio: Escribir el codigocorrespondiente a la siguiente salida:

Teorema 1 No hay primo mayor que el resto

Figura 1: Euclides

Euclides, al que podemos ver en la Figura 1, propuso y demostro el Teorema 1.

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 63 / 80

Page 88: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Referencias: El comando \ref

Podemos llamar al numero de una etiqueta mediante \ref <label>.

Solucion\documentclassarticle

\usepackage[spanish]babel\usepackage[utf8]inputenc\usepackagegraphicx

\newtheoremthmTeorema

\begindocument

\beginthm \labelthm:euclidesNo hay primo mayor que el resto\endthm\beginfigure[h!]

\centering\includegraphics[scale=0.5]euclides.pdf\captionEuclides\labelfig:euclides

\endfigureEuclides, al que podemos ver en laFigura˜\reffig:euclides, propusoy demostro el Teorema˜\refthm:euclides.

\enddocument

Ejercicio: Escribir el codigocorrespondiente a la siguiente salida:

Teorema 1 No hay primo mayor que el resto

Figura 1: Euclides

Euclides, al que podemos ver en la Figura 1, propuso y demostro el Teorema 1.

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 63 / 80

Page 89: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Referencias avanzadas: el paquete \cleverefIntroduciendo este paquete tenemos acceso al comando \Cref .

Esta funcion actua como \ref , pero incluye automaticamente el tipo deobjeto referenciado: Teorema, Figura...

Codigo\documentclassarticle\usepackage[spanish]babel\usepackage[utf8]inputenc\usepackagegraphicx\usepackage[spanish]cleveref\newtheoremthmTeorema\begindocument

\beginthm \labelthm:euclidesNo hay primo mayor que el resto\endthm\beginfigure[h!]

\centering\includegraphics[scale=0.5]euclides.pdf\captionEuclides\labelfig:euclides

\endfigureEuclides, al que podemos ver en la\Creffig:euclides, propusoy demostro el \Crefthm:euclides.

\enddocument

Teorema 1 No hay primo mayor que el resto

Figura 1: Euclides

Euclides, al que podemos ver en la Figura 1, propuso y demostro el Teorema 1.

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 64 / 80

Page 90: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Referencias avanzadas: el paquete \cleverefIntroduciendo este paquete tenemos acceso al comando \Cref .

Esta funcion actua como \ref , pero incluye automaticamente el tipo deobjeto referenciado: Teorema, Figura...Codigo\documentclassarticle\usepackage[spanish]babel\usepackage[utf8]inputenc\usepackagegraphicx\usepackage[spanish]cleveref\newtheoremthmTeorema\begindocument

\beginthm \labelthm:euclidesNo hay primo mayor que el resto\endthm\beginfigure[h!]

\centering\includegraphics[scale=0.5]euclides.pdf\captionEuclides\labelfig:euclides

\endfigureEuclides, al que podemos ver en la\Creffig:euclides, propusoy demostro el \Crefthm:euclides.

\enddocument

Teorema 1 No hay primo mayor que el resto

Figura 1: Euclides

Euclides, al que podemos ver en la Figura 1, propuso y demostro el Teorema 1.

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 64 / 80

Page 91: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Bibliografıa nativa

Codigo\documentclassarticle\begindocument

Cito el art\’iculo \citelatexcompanion

\beginthebibliography9\bibitemlatexcompanion

Michel Goossens, Frank Mittelbach,and Alexander Samarin.\textitThe \LaTeX\ Companion.Addison-Wesley, Reading, Massachusetts, 1993.

\bibitemeinsteinAlbert Einstein.\textitZur Elektrodynamik bewegter K\"orper.(German)[On the electrodynamics of moving bodies].Annalen der Physik, 322(10):891921, 1905.

\bibitemwikipediaWikipedia\\\texttthttp://www.wikipedia.com

\endthebibliography\enddocument

Cito el artıculo [1]

References

[1] Michel Goossens, Frank Mittelbach, and Alexander Samarin. The LATEXCompanion. Addison-Wesley, Reading, Massachusetts, 1993.

[2] Albert Einstein. Zur Elektrodynamik bewegter Korper. (German) [On theelectrodynamics of moving bodies]. Annalen der Physik, 322(10):891921,1905.

[3] Wikipediahttp://www.wikipedia.com

1

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 65 / 80

Page 92: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Bibtex: formato automaticoCodigo[ejemplo-bibtex.tex]\documentclassarticle\begindocument

Cito el art\’iculo \citeeinstein.

\bibliographystyleplain\bibliographyejemplo-bibliografia.bib\enddocument

Codigo[ejemplo-bibliografia.bib]@articleeinstein,

author = "Albert Einstein",title = "Zur Elektrodynamik bewegter K\"orper.

(German)[On the electrodynamics of moving bodies]",

journal = "Annalen der Physik",volume = "322",number = "10",pages = "891--921",year = "1905",DOI = "http://dx.doi.org/10.1002/andp.19053221004"

Cito el artıculo [1].

References

[1] Albert Einstein. Zur Elektrodynamik bewegter Korper. (German) [On theelectrodynamics of moving bodies]. Annalen der Physik, 322(10):891–921,1905.

1

Observacion. Bibtex, al compilar,genera un archivo .bbl que contieneuna bibliografıa nativa.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 66 / 80

Page 93: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Sesion V

Presentaciones con LATEX

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 67 / 80

Page 94: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El paquete beamer

El paquete beamer nos permite hacer presentaciones en LATEX como esta.

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 68 / 80

Page 95: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

La cabeceraUna cabecera elemental

Codigo\documentclassbeamer

\usepackage[utf8]inputenc

\mode<presentation>\usethemeWarsaw\usecolorthemeseahorse

\titleMi presentacion\authorYo\date\today

Para ver diferentes estilos y colores visitarhttps://hartwork.org/beamer-theme-matrix/

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 69 / 80

Page 96: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

La cabeceraUna cabecera completa

Codigo\documentclassbeamer

\usepackage[utf8]inputenc\usepackage[spanish]babel\usepackageamsthm\usepackagegraphicx\newtheoremthmTeorema

\mode<presentation>\usethemeWarsaw\usecolorthemeseahorse

\titleMi presentacion\authorYo\date\today

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 70 / 80

Page 97: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las diapositivas

Las diapositivas se introducen en un entorno frame. Algunas cosas que sepueden anadir (editando la cabecera acordemente)

Codigo\begindocument

\beginframe% Texto de la diapositiva

\endframe

\enddocument

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 71 / 80

Page 98: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las diapositivas

Las diapositivas se introducen en un entorno frame. Algunas cosas que sepueden anadir (editando la cabecera acordemente)

1 Cuadros

2 Imagenes3 Teoremas

Codigo\beginframe

\beginblockBloqueTexto en un bloque

\endblock\endframe

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 71 / 80

Page 99: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las diapositivas

Las diapositivas se introducen en un entorno frame. Algunas cosas que sepueden anadir (editando la cabecera acordemente)

1 Cuadros2 Imagenes

3 Teoremas

Codigo\beginframe

\beginfigure\centering\includegraphics[scale=0.5]

gauss.pdf\captionGauss

\endfigure\endframe

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 71 / 80

Page 100: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Las diapositivas

Las diapositivas se introducen en un entorno frame. Algunas cosas que sepueden anadir (editando la cabecera acordemente)

1 Cuadros2 Imagenes3 Teoremas

Codigo\beginframe

\beginthmUn teorema...

\endthm\beginproof

Y su prueba ...\endproof

\endframe

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 71 / 80

Page 101: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Sesion VI

Graficos avanzados

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 72 / 80

Page 102: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

El paquete Tikz

El paquete tikz nos permite general dibujos

Codigo\documentclassstandalone % say

\usepackagetikz

\begindocumentTrabajaremos con

\begintikzpicture\draw (-1.5,0) -- (1.5,0);\draw (0,-1.5) -- (0,1.5);\endtikzpicture.

\enddocument

Trabajaremos con .

Figura: Resultado de compilar

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 73 / 80

Page 103: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Dibujo libre

Existen diferentes tipos de lıneas y figuras, las opciones son ilimitadas

Codigo\begintikzpicture\draw[->] (-1.5,0) -- (1.5,0);\draw[dashed] (0,-1.5) -- (0,1.5);\draw[green] (0,0) circle (1cm);\endtikzpicture

Bellos ejemplos se pueden encontrar enhttp://www.texample.net/tikz/examples/

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 74 / 80

Page 104: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Representacion de grafosCodigo\documentclass[tikz,border=10pt]standalone\usetikzlibrarypositioning\tikzsetmain node/.style=circle,fill=blue!20,draw,minimum size=1cm,inner sep=0pt,\begindocument\begintikzpicture\node[main node] (1) $1$;\node[main node] (2) [below left = 2.3cm and 1.5cm of 1] $2$;\node[main node] (3) [below right = 2.3cm and 1.5cm of 1] $3$;

\path[draw,thick](1) edge node (2)(2) edge node (3)(3) edge node (1);

\endtikzpicture\enddocument

1

2 3

Figura: Resultado de compilar

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 75 / 80

Page 105: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Diagramas de flujo

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 76 / 80

Page 106: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Desvarıos excesivos

detA

Poincare Diagram: Classification of Phase Portraits in the (detA,TrA)-plane

TrA

∆=0 ∆=0: detA= 14 (TrA)2

saddle

sink source

spiral sink spiral source

center

line of stable fixed points line of unstable fixed points

degenerate sink degenerate source

uniformmotion

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 77 / 80

Page 107: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Representacion de curvasCodigo\documentclassstandalone\usepackagetikz\begindocument

\begintikzpicture\draw[->] (-3,0) -- (4.2,0) node[right] $x$;\draw[->] (0,-3) -- (0,4.2) node[above] $y$;\draw[scale=0.5,domain=-3:3,smooth,variable=\x,blue] plot (\x,\x*\x);\draw[scale=0.5,domain=-3:3,smooth,variable=\y,red] plot (\y*\y,\y);\endtikzpicture

\enddocument

x

y

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 78 / 80

Page 108: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Representacion de funciones: pgfplots

Codigo\documentclassstandalone\usepackagepgfplots

\begindocument\begintikzpicture\beginaxis[xmax=9,ymax=9,samples=50]\addplot[blue] (x,x*x);\addplot[red] (x*x,x);

\endaxis\endtikzpicture\enddocument

−4 −2 0 2 4 6 8−4

−2

0

2

4

6

8

Figura: Resultado de compilar

Una buena lista de ejemplos del manual:http://pgfplots.sourceforge.net/gallery.html

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 79 / 80

Page 109: Introducci´on a la escritura cient´ıfica en LTEX2εblogs.mat.ucm.es/dgcastro/wp-content/uploads/sites/41/2018/12/18 … · Google. Si no: lmgtfy.com TEX Stack Exchange ... Cambridge

Representacion de datosCodigo\documentclassstandalone\usepackagepgfplots

\begindocument\begintikzpicture\beginaxis\addplot

table [x=a, y=c, col sep=comma]data.csv;

\endaxis\endtikzpicture\enddocument

Codigo [data.csv]a,b,c,d1,4,5,12,3,1,53,5,6,14,1,4,95,3,4,7

1 2 3 4 5

2

4

6

Figura: Resultado de compilar

David Gomez-Castro (UCM) Introduccion a LATEX 2ε Diciembre 2018 80 / 80