Lihuen
RSSRSS AtomAtom

Latex

Beamer

Acentos -eñes - símbolos

Poner todo un documento en español lleva varios pasos:

\usepackage[spanish,es-tabla,es-noquoting]{babel} % Idioma y codificación del texto
\usepackage[utf8x]{inputenc} % Codificación del archivo
 
%% La tipografía tiene que soportar tildes, no todas lo hacen %%
\usepackage{courier}    % Courier para tipografía monoespaciada
\usepackage[T1]{fontenc}
 
%% Si se usa hyperref + utf8x para establecer el título, autor, etc... %%
\PrerenderUnicode{á}
\PrerenderUnicode{é}
\PrerenderUnicode{í}
\PrerenderUnicode{ó}
\PrerenderUnicode{ú}
\PrerenderUnicode}
 
%% Los listings precisan parámetros especiales, sino puede fallar la generación del PDF %%
\lstset{
     extendedchars=true, 
     inputencoding=utf8x,
     literate={á}{{\'a}}1
           {é}{{\'e}}1
           {í}{{\'i}}1
           {ó}{{\'o}}1
           {ú}{{\'u}}1
           {ñ}{{\~n}}1
}

En el caso que necesitemos símbolos especiales como por ejemplo °, usamos el siguiente código:

$^{\circ}$    % o también \textdegree incluyendo el paquete textcomp

Si no sabemos como se escribe un carácter alcanza con dibujarlo en este sitio para saber el código Latex para generarlo: http://detexify.kirelabs.org (http://github.com/kirel)

Tabla completa de símbolos: http://www.ctan.org/tex-archive/info/symbols/comprehensive/

Flotantes en posición fija

\usepackage{float}
...
\begin{figure}[H]

http://tex.stackexchange.com/questions/8625/force-figure-placement-in-text

Enumerate con letras u otros contadores

\usepackage{enumerate}
...
\begin{enumerate}[(a)]

http://tex.stackexchange.com/questions/2291/how-do-i-change-the-enumerate-list-format-to-use-letters-instead-of-the-defaul

Figuras

http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions

\begin{figure}
    \centering
    \begin{framed} % Si queremos un recuadro
        \includegraphics[width=\textwidth]{chick}
    \end{framed}
    \caption{Ejemplos}
    \label{fig:ejemplos}
\end{figure}

Subfiguras con el paquete subcaption

Existen 3 paquetes para hacer subfiguras, el más moderno es subcaption (no confundir con subfig y subfigure que usan environments muy parecidos):

\usepackage{caption}
\usepackage{subcaption}
% ...
\begin{figure}
    \centering
    \begin{framed}
        \begin{subfigure}[b]{0.45\textwidth}
            \begin{lstlisting}[language=bash]
./programa.bin "3 2 5 + *"
            \end{lstlisting}
            \subcaption{}
        \end{subfigure}\rule{.1pt}{35pt} % Línea vertical
        \begin{subfigure}[b]{0.45\textwidth}
            \begin{lstlisting}[language=bash]
./programa.bin "2 5 *" "4 5 +"
            \end{lstlisting}
            \subcaption{}
        \end{subfigure}\\
        \rule{1\textwidth}{.1pt} % Línea horizontal
        \begin{subfigure}[b]{1\textwidth} % Subfigura al 100% de ancho
            \begin{lstlisting}[language=bash]
./programa.bin
            \end{lstlisting}
            Imprime:\\
            \texttt{Uso: ./programa.bin expresión\_en\_npi [expresión\_en\_npi [...]]}
            \subcaption{}
        \end{subfigure}
    \end{framed}
    \caption{Ejemplos}
    \label{fig:ejemplos}
\end{figure}

Eso genera la figura:

Latex Subfiguras.png

Gráficos

http://en.wikibooks.org/wiki/LaTeX/Importing_Graphics

Lo mejor es generar PDFs a partir de SVGs y usar esos gráficos:

inkscape -z -f imagen.svg --export-pdf=imagen.pdf

Gráficos vectoriales y flechas con Tikz

Gráficos creados en Latex puro con el paquete Tikz

Si bien se pueden agregar gráficos vectoriales en Latex usando PDFs, el documento queda un poco pesado y los gráficos no interactúan con el resto del documento: por ejemplo no puede haber una flecha a un elemento de un itemize. Tampoco funciona con uncover/pause/only a menos que generemos varias imágenes distintas.

Tikz resuelve todas estas cosas y permite crear gráficos relativamente complejos en Latex puro.

Código fuente del ejemplo: ejemplo_tikz.tex

Fuente: http://www.texample.net/tikz/examples/data-flow-diagram/


  • Para hacer la construcción de un diagrama con pausas
Construcción de un diagrama con pausas


begin{tikzpicture}[node distance=0.25cm, auto,>=latex', thick]
    % We need to set at bounding box first. Otherwise the diagram
    % will change position for each frame.
    \path[->]   
      node[format] (temp) {Template};\pause
    \path[->]              node[nuestro, below=.55 of temp](conf){Configuración específica variante}
         (temp) edge (conf);\pause
    \path[->]           node[format, below =.55 of conf](liv){Live Build : chroot y generar ISO}; 
    \path[->] (conf) edge (liv);\pause
    \path[->]         	node[nuestro, below =0.55 of liv] (inst) {Configuración Installer: menú arranque};
     \path[->] (liv) edge (inst); \pause
         \path[->]    	node[nuestro, below =0.55 of inst] (iso) {Generar ISO final}; 
         \path[->] (inst) edge (iso);\pause
    \path[->]         	node[format, below =0.55 of iso] (arran) {Configuración arranque: hostname, idioma}; 
    \path[->](iso) edge (arran);\pause  
 
\end{tikzpicture}


Makefiles

Si tenemos un proyecto con la estructura:

+ presentacion
|- Makefile
|- documentos.tex
|-+ styles
|   \ 
|    |- imagen.svg
|    |- Makefile
|
|-+ images
    \
    |- logo.svg
    |- Makefile

Podemos automatizar todo con los siguientes Makefiles:

  • Para images y styles:
DOCUMENTS=$(patsubst %.svg,%.pdf,$(wildcard *.svg))

all: $(DOCUMENTS)

%.pdf: %.svg
	inkscape -z -f $< --export-pdf=$@


clean:
	rm -f $(DOCUMENTS)
	rm -f *.log

.PHONY: clean

  • Para el directorio principal:
DOCUMENTS=$(patsubst %.tex,%.pdf,$(wildcard *.tex))

all: $(DOCUMENTS)

%.pdf: %.tex generate_figures
	pdflatex $<


generate_figures:
	make -C images
	make -C style

pdfonly: all
	rm -f *.nav *.out *.snm *.toc *.vrb *.aux *.bak *.log

clean:
	make -C images clean
	make -C style clean
	rm -f *.nav *.out *.pdf *.snm *.toc *.vrb
reallyclean: clean
	rm -f *.aux *.bak *.log

.PHONY: clean generate_figures

Nota: Para que se generen correctamente los índices y referencias generalmente hay que ejecutar make 2 veces.

Cambiar los encabezados y pies de página

http://texblog.org/2007/11/07/headerfooter-in-latex-with-fancyhdr/


Listas

 \begin{itemize}
\item ...
\end{itemize}

Verificar errores ortográficos

aspell check archivo.tex

ispell también funciona pero no es tan fácil usarlo con UTF-8.

Si las fuentes no se ven bien

Verificar si está instalado el paquete de fuentes cm-super.

Cómo poner links a videos u otros archivos en un PDF

Es posible abrir archivos usando links en los PDFs con el visor de PDFs Evince:

\href{run:videos/interfaz.mp4}{video}

Orden de preferencia de formatos de imágenes para los \includegraphics

\DeclareGraphicsExtensions{.pdf,.png,.jpg}

Links a tener en cuenta

Varios templates ya armados

  1. Templates