TUTORIAL DE LATEX - WordPress.com · TEX Y LATEX ๏ TeX es un programa de computadora para hacer...

Post on 25-Jul-2020

7 views 0 download

Transcript of TUTORIAL DE LATEX - WordPress.com · TEX Y LATEX ๏ TeX es un programa de computadora para hacer...

TUTORIAL DE LATEXM. en C. Erika Vilches

TEX Y LATEX

๏ TeX es un programa de computadora para hacer composición tipográfica de documentos.

✴Creado por D. E. Knuth

✴Toma un archivo preparado adecuadamente y lo convierte en una forma que puede ser impresa en muchos tipos de impresoras (Laser, máqunas de composición tipográfica de alta resolución,etc.)

✴Muchas editoriales utilizan TeX para hacer la composición tipográfica de libros y revistas matemáticas.

๏ Documentos simples que no contienen fórmulas matemáticas o tablas pueden ser producidos muy fácilmente

✴El cuerpo del texto es escrito prácticamente sin alteraciones

‣ Observando ciertas reglas con respecto a las comillas y signos de puntuación.

๏ Hacer composición tipográfica matemática es más complicado

๏ LaTeX

✴Escrito por L. B. Lamport

✴Uno de los dialectos de TeX

✴Particularmente adecuado para la escritura de libros y artículos largos

‣ Tiene facilidades para la numeración automática de capítulos, secciones, teoremas, ecuaciones, etc.

‣ Asimismo, tiene facilidades para hacer referencias.

‣ Es una colección de macros de TeX diseñada para facilitar la tarea del escritor en la creación de documentos.

๏ Crear un archivo llamado hello.tex y escribir lo siguiente en él:

๏ Lo que produce:

๏ Nota: TeX es case-sensitive

HELLO WORLD EN TEX

Hello \TeX\ world! \bye

๏ El compilador de TeX produce un archivo *.dvi (devide independent) llamado hello.dvi

๏ El archivo hello.dvi es posteriormente convertido a postscript hello.ps

✴Podemos verlo en postcript con programas como GSView o convertirlo a PDF.

๏ Crear un archivo llamado hello.tex y escribir lo siguiente en él:

๏ Lo que produce:

๏ Nota: LaTeX es case-sensitive

HELLO WORLD EN LATEX

\documentclass{article} \begin{document} Hello \LaTeX\ world! \end{document}

ESPACIOS Y PÁRRAFOS

๏ TeX y LaTeX ignoran los espacios y nuevas líneas.

๏ Ejemplo en TeX:

๏ Produce:

Hello \TeX\ World! \bye

๏ Es necesario colocar una línea en blanco entre párrafos para producir un nuevo párrafo.

Now is the time for all good men to come to the aid of their country.

Now is the time for all good men to come to the aid of their country.

\bye

๏ Las siguientes opciones están disponibles:

✴ \rm → roman

✴ \br → bold

✴ \it → italica

✴ \sl → slanted

✴ \tt → typewriter

✴ \cal → script

CAMBIANDO LA FUENTE

๏ Ejemplo:

If you change to \it italic \rm you must remember to change back to roman. If you change to \bf boldface and forget to change back to roman, all of your remaining text will be boldface.

\bye

๏ Agrupar mediante llaves limita el alcance del tipo de letra.

\rm Grouping with curly braces limits the scope of {\bf bold typeface}. This is the most {\it efficient} way to change typefaces.\bye

๏ TeX y LaTeX reservan caracteres especiales para distintos usos importantes.

✴ \ → Símbolos especiales e instrucciones → literal $\backslash$

✴ { → Abrir un grupo → literal $\{$

✴ } → Cerrar un grupo → literal $\}$

✴% → Comentarios → literal \%

✴& → Alineaciones de tablas y Tabs → literal \&

✴ ˜ → Espacio no partible → literal \˜{}

CARACTERES ESPECIALES

✴$ → Empezar o terminar texto matemático → literal \$

✴ ˆ → Superscripts matemáticos → literal \ˆ{}

✴_ → Subscripts matemáticos → literal \_{}

✴# → Definir símbolos de reemplazo → \#

%This is a comment Almost 100\% of the \$300 is {\bf gone}! If $x_1^2-2x_1=3$, then find the value of $x_1$ and use this result in exercise \#1.

\bye

๏ Las expresiones matemáticas inline se encierran en $ ... $

๏ Para “desplegar” expresiones matemáticas utilizamos $$ ..... $$

MATEMÁTICAS EN TEX

If $f$ is continuous on $[a,b]$, differentiable on $(a,b)$, then there exists a $c$ in $(a,b)$ such that $$ f'(c)={{f(b)-f(a)}\over {b-a}}. $$

\bye

๏ No olvidar que TeX ignora los espacios y líneas nuevas, de modo que es lo mismo escribir :

๏ Que escribir :

If $f$ is continuous on $[a,b]$, differentiable on $(a,b)$, then there exists a $c$ in $(a,b)$ such that $$ f'(c)={{f(b)-f(a)}\over {b-a}}. $$

\bye

If $f$ is continuous on $[a,b]$, differentiable on $(a,b)$, then there exists a $c$ in $(a,b)$ such that $$ f’(c)={{f(b)-f(a)}\over {b-a}}.$$

๏ Para envolver una palabra o frase entre comillas iniciar la frase con dos comillas sencillas de apertura consecutivas y terminarla con dos comillas sencillas de cierre

COMILLAS Y GUIONES

``Merrily we roll along'' cried the Mad Hatter.

\bye

๏ Existen varios tipos de guiones en LaTeX, cada uno con un propósito distinto.

My mother-in-law did exercises 11--22 in her workbook ---a thoroughly difficult assignment--- while it was $-20$ degrees outside.\bye

ESTRUCTURA DE UN DOCUMENTO LATEX

๏ Titulo

๏ Autor

๏ Fecha

๏ Abstract

๏ Tabla de Contenido

๏ Encabezados de secciones y subsecciones

๏ Referencias

๏ Notas al Pie

ELEMENTOS DE UN BUEN ARTÍCULO

DECLARANDO LA CLASE DE UN DOCUMENTO

๏ Recordando la estructura básica de un documento en LaTeX:

\documentclass{article} → preámbulo\begin{document} → Escribir el cuerpo del documento aquí\end{document}

๏ \documentclass{article} instruye a LaTeX para que utilice la clase artículo cuando estructure el documento.

๏ Algunas otras clases de LaTeX son:

✴report → Util para escribir un reporte, tesis, etc.

✴book → Util para escribir libros

✴ letter → Utilizado para crear cartas, memorandums, etc.

✴slides → Utilizado para crear diapositivas

CREANDO EL TÍTULO DE UN ARTÍCULO

\documentclass{article} %Always place the following commands in the preamble \title{My First \LaTeX\ Article} \author{Erika Vilches} \date{August 24, 2009} \begin{document} %But create the title in the body of the document \maketitle Place the body of your article here. \end{document}

๏ Para crear una página de título separada, utilizar la opción titlepage en la declaración de la clase. Ej:

\documentclass[titlepage]{article} %Always place the following commands in the preamble \title{My First \LaTeX\ Article} \author{Erika Vilches} \date{August 24, 2009} \begin{document} %But create the title in the body of the document \maketitle Place the body of your article here. \end{document}

Página 1Página 2

CREANDO UN ABSTRACT

\documentclass{article} \title{My First \LaTeX\ Article} \author{Erika Vilches} \date{August 24, 2009} \begin{document} \maketitle %The abstract goes here \begin{abstract} An abstract is one of the most important parts of your article. Readers use the abstract to determine if they want to read further, so you have to hook them in with a good abstract. \end{abstract} Place the body of your article here. \end{document}

๏ El resultado es:

๏ Agregando algo de cuerpo:

\documentclass{article} \title{My First \LaTeX\ Article} \author{Erika Vilches} \date{August 24, 2009} \begin{document} \maketitle \begin{abstract} An abstract is one of the most important parts of your article. Readers use the abstract to determine if they want to read further, so you have to hook them in with a good abstract. \end{abstract} This time we want to place something significant in the body of our document. After you are done, use copy and paste to follow this paragraph with about 50 copies of itself. Remember to separate paragraphs in the source with at least one blank line. \end{document}

๏ Resultado:

๏ Utilice \section para obtener encabezados de sección automáticamente numerados.

SECCIONES Y SUBSECCIONES

\section{Type Whatever You Want Here} This time we want to place something significant in the body of our document. After you are done, use copy and paste to follow this paragraph with about 50 copies of itself. Remember to separate paragraphs in the source with at least one blank line.

๏ Las subseccions se crean utilizando el comando \subsection

\subsection{Type Whatever You Want Here} This time we want to place something significant in the body of our document.

๏ Para crear secciones y subsecciones sin numeración utilizar \section* y \subsection*

\section*{Hello}

๏ Para añadir la tabla de contenido se utiliza el comando \tableofcontents justamente después del abstract.

๏ Es necesario correr LaTeX sobre el documento dos veces antes de poder ver el resultado.

๏ Nota: Las formas con asterisco de seccion y subsección no serán mostradas en la tabla de contenido.

TABLA DE CONTENIDO

\documentclass{article} \title{My First \LaTeX\ Article} \author{Erika Vilches} \date{August 24, 2009} \begin{document} \maketitle \begin{abstract} An abstract is one of the most important parts of your article. Readers use the abstract to determine if they want to read further, so you have to hook them in with a good abstract. \end{abstract}

\tableofcontents

\section{Type Whatever You Want Here}This time we want to place something significant ...

๏ El contador secnumdepth controla qué encabezados serán numerados

✴Para numerar solamente encabezados de primer nivel (encabezados \section), utilice en el preámbulo el comando:

✴Para que los cambios tengan efecto, deberá ejecutarse dos veces el comando LaTeX

\setcounter{secnumdepth}{1}

๏ El mismo modo, el comando:

๏ Numeraría los primeros dos niveles de encabezados (\section y \subsection)

๏ Colocar :

en el preámbulo permitirá solamente encabezados de nivel 1 (\section) en la tabla de contenido

\setcounter{secnumdepth}{2}

\setcounter{tocdepth}{1}

๏ Es creada con el ambiente.

๏ Las entradas individuales en la bibliografía comienzan cada una con el comando (la etiqueta es opcional, la llave no):

BIBLIOGRAFÍA

\begin{thebibliography}{sample.label} entries \end{thebibliography}

\bibitem[label]{key} entry.text

๏ Ejemplo:

✴Al final de su documento, antes del comando \end{document}, agregue lo siguiente:

✴Note que no se proporciono ninguna etiqueta, de modo que los elementos de la bibliografía se numerarán automáticamente, comenzando con el número 1.

\begin{thebibliography}{03} \bibitem{erika} Erika, \emph{Data Mining} \end{thebibliography}

๏ Referenciando la bibliografía:

✴Una cita en el cuerpo del documento es hecha con el siguiente comando:

✴Por ejemplo, colocando en el cuerpo de nuestro documento:

\cite{key}

\cite{erika}

๏ Si no se desea numeración automática, se puede utilizar la etiqueta opcional del comando \bibitem para crear etiquetas propias.

๏ Ejemplo:

\begin{thebibliography}{Erika, 2003} \bibitem[Erika, 2003]{erika} Erika, \emph{Data Mining} \end{thebibliography}

๏ LaTeX provee notas al pie auto-numeradas.

๏ Ejemplo:

๏ Esto pone una nota al pie inmediatamente después de la palabra que referencia

๏ Si la nota referencia un enunciado o frase, ponerla después del punto.

NOTAS AL PIE

In the first place,\footnote{What happens to second place?} I don’t want to hear about it!

LISTAS ENUMERADAS

\begin{enumerate} \item Put on the paper. \item Put on the tape. \item Put on the ribbon. \end{enumerate}

\begin{enumerate} \item If $f(x)=xˆ2-2x-3$, then $f(2)$ equals \begin{enumerate} \item $-3$ \item $2$ \item $-9$ \item $12$ \item None of these \end{enumerate} \item What is the formula for the area of a circle? \end{enumerate}

๏ Se pueden anidar hasta 4 niveles

LISTAS DE VIÑETAS

\begin{itemize} \item Put on the paper. \item Put on the tape. \item Put on the ribbon. \end{itemize}

\begin{itemize} \item The graph of $x=\cosˆ3 t$, $y=\sinˆ3 t$ is symmetric with respect to \begin{itemize} \item the $x$-axis, \item the $y$-axis, and \item the origin. \end{itemize} \item Parametric equations are fun! \end{itemize}

๏ Se pueden anidar hasta 4 niveles

LISTAS DESCRIPTIVAS

\begin{description} \item[elephant] A large mammal with a long snout and ivory tusks, usually found in Africa. \item[skunk] A foul smelling animal, all black with a white stripe down its back and tail, usually encountered by Don Hickethier on his morning ride to work. \item[golf swing] Something Todd is working on! \end{description}

๏ Tienen forma de glosario.

\begin{itemize} \item The graph of $x=\cosˆ3 t$, $y=\sinˆ3 t$ is symmetric with respect to \begin{itemize} \item the $x$-axis, \item the $y$-axis, and \item the origin. \end{itemize} \item Parametric equations are fun! \end{itemize}

๏ Se pueden anidar hasta 4 niveles

TABLAS

\begin{tabular}{ll} \textbf{Name} & \textbf{Address} \\ David Arnold & 1223 My Blue Heaven \\ Mike Butler & 666 Devil’s Highway \\ Todd Olsen & 1234 Sand Trap \\ \end{tabular}

๏ El & es utilizado para separar entradas en una fila

๏ El \\ indica el final de una fila

๏ Si se deseara justificar a la derecha la columna “Address”

\begin{tabular}{lr} \textbf{Name} & \textbf{Address} \\ David Arnold & 1223 My Blue Heaven \\ Mike Butler & 666 Devil’s Highway \\ Todd Olsen & 1234 Sand Trap \\ \end{tabular}

๏ Es posible centrar cada columna y poner una línea horizontal debajo de la primera fila:

\begin{tabular}{cc} \textbf{Name} & \textbf{Address} \\ \hline David Arnold & 1223 My Blue Heaven \\ Mike Butler & 666 Devil’s Highway \\ Todd Olsen & 1234 Sand Trap \\ \end{tabular}

๏ Es posible separar columnas con líneas verticales y filas con líneas horizontales.

\begin{tabular}{|c|c|} \hline \textbf{Name} & \textbf{Address} \\ \hline David Arnold & 1223 My Blue Heaven \\ \hline Mike Butler & 666 Devil’s Highway \\ \hline Todd Olsen & 1234 Sand Trap \\ \hline \end{tabular}

๏ Para centrar la tabla completa en la hoja, insertarla en un ambiente de centrado:

\begin{center} \begin{tabular}{|c|c|} \hline \textbf{Name} & \textbf{Address} \\ \hline David Arnold & 1223 My Blue Heaven \\ \hline Mike Butler & 666 Devil’s Highway \\ \hline Todd Olsen & 1234 Sand Trap \\ \hline \end{tabular} \end{center}

\begin{enumerate} \item If $xˆ3-2xˆ2-3x-11$ is divided by $x+1$, the remainder is\\ \begin{tabular}{lllll} a) $x-3$ & b) $x+1$ & c) $x-11$ & d) $x-2$ & e) None of these\\ \end{tabular} \item What is the formula for the area of a circle?\\ \begin{tabular}{lllll} a) $\pi rˆ2$ & b) $2\pi r$ & c) $\pi dˆ2$ & d) $2\pi d$ & e) None of these\\ \end{tabular} \end{enumerate}

๏ Utilice el ambiente de quote para hacer pequeñas citas.

QUOTES Y QUOTATIONS

\begin{quote} Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. \end{quote}

๏ Utilice el ambiente quotation para hacer citas de mayor tamaño.

\begin{quotation} Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. \end{quotation}

๏ Para que LaTeX respete los espacios y saltos de línea, se utiliza el ambiente verbatim.

๏ Particularmente útil para pegar código de computadora en el documento.

EL AMBIENTE VERBATIM

\begin{verbatim}

while (i <= m) & (j <= n) [p,k] = max(abs(A(i:m,j))); k = k+i-1; if (p <= tol) A(i:m,j) = zeros(m-i+1,1); j = j + 1; else jb = [jb j]; A([i k],j:n) = A([k i],j:n); A(i,j:n) = A(i,j:n)/A(i,j); for k = [1:i-1 i+1:m] A(k,j:n) = A(k,j:n) - A(k,j)*A(i,j:n); end i = i + 1; j = j + 1; end end

\end{verbatim}

๏ Resultaría en:

ECUACIONES EN LÍNEA CONTRA INDEPENDIENTES

\documentclass{article} \begin{document} Summation notation, as in $\sum_{k=1}ˆn 2ˆk$, looks slightly different when it occurs within a line of text (in-line). Contrast this appearance with the display $$ \sum_{k=1}ˆn 2ˆk. $$ \end{document}

๏ Las matemáticas en línea también se pueden delimitar con \( ... \) y las matemáticas independientes con \[ ... \]

\documentclass{article} \begin{document} Integration, as in \(f(x)=\int_1ˆx f(t)\,dt\), looks slightly different when it occurs within a line of text. Contrast this appearance with the display \[ f(x)=\int_1ˆx f(t)\,dt. \] \end{document}

๏ Asimismo, es posible delimitar las matemáticas en línea con \begin{math}. . . \end{math} y las matemáticas independientes con \begin{displaymath}. . . \end{displaymath}

✴La forma menos común de hacerlo

๏ Si aparece más de un caracter en un subscript o superscript, utilizar símbolos de agrupación para contenerlos

✴Ejemplo: $x_{i,j}$

๏ \ → Inserta un pequeño espacio entre f(t) y dt

๏ Para crear comandos nuevos utilizamos el comando:

๏ Ej: Si una expresión se repite muchas veces, se puede crear un comando para no escribirla reiteradamente.

\newcommand

\documentclass{article} \newcommand{\be}{\begin{enumerate}} \newcommand{\ee}{\end{enumerate}} \begin{document} I have to complete the following chores today. \be \item Mow the lawn. \item Rake the leaves. \item Wash the car. \ee \end{document}

๏ Cambiando los estilos de fuente

✴Hay tres familias de fuentes

‣ \textrm → Roman

‣ \textsf → Sans Serif

‣ \texttt → Typewriter

\documentclass{article} \begin{document} Here is a sample of the \textsf{Sans Serif} family, and here is a sample of the \texttt{Typewriter} family. \end{document}

✴Existen dos series de letras.

‣ \textmd → Serie media

‣ \textbf → Serie boldface

\documentclass{article} \begin{document} This is \textbf{bold}, while \textbf{this is \textmd{medium} series}. \end{document}

✴Existen cuatro formas de letra:

‣ \textup → Upright

‣ \textit → Italicas

‣ \textsl → Slant

‣ \textsc → Small caps

\documentclass{article} \begin{document} At 3\,\textsc{pm}, you can easily tell the difference between \textit{the italic font shape} and \textsl{the slant font shape}. \textit{If the text is already italic, emphasis is provided by \textup{the upright shape} in the italicized sentence}. You can also combine various text commands, as \textsl{in \textbf{this} phrase}. In most circumstances, if you want to emphasize \emph{a word or phase}, use the \verb+\emph+ command. \end{document}