latex

Table of Contents

1. LaTeX

1.1. trucos

1.1.1. Texto en 2 columnas con minipage

https://latex-tutorial.com/minipage-latex/
https://latex-programming.fandom.com/wiki/Minipage_(LaTeX_environment)

  \bigskip % Suele funcionar cuando no funciona \\
  \pagenumbering{gobble} % No hay num de pag
  \begin{minipage}[b]{0.45\linewidth}
  .
  .
  .
  \end{minipage} % IMPORTANTE: no puede haber ningún espacio aquí
  \begin{minipage}[b]{0.45\linewidth}
  .
  .
  .
  \end{minipage}
  $\xrightarrow[\text{world}]{\text{hello}}$ % flechas con hello arriba y world abajo
  $\xRightarrow[\text{world}]{\text{hello}}$ % lo mismo con flecha doble
  \uncover para quitar la transparencia del índice en beamer

1.1.2. Handwritten to LaTeX

1.2. Diagramas con dia

Diagramas con Dia:
http://lightonphiri.org/blog/latex-consistent-diagrams-using-dia
Luego también se puede usar https://www.unicodeit.net/ y exportar a
“eps using Pango fonts” (eps parece ser que es más peer-review friendly)

1.3. Instalación Linux

Archivos .tex
En Linux, hace falta instalar texlive y pdflatex. Para compilar un
.tex:
<code> $ texi2pdf 1.tex –clean </code>

1.4. Estructura de un archivo de Latex

  <preamble>
  \documentclass{article}
  \begin{document}
  \begin{<enviroment>}
  \end{<enviroment>}
  \end{document}

Preámbulo actual:

  \documentclass{article}
  \usepackage[utf8]{inputenc}
  \usepackage[spanish, es-nodecimaldot]{babel}
  \usepackage{amsmath}
  \usepackage{braket}
  \usepackage[bitstream-charter]{mathdesign}
  \usepackage{graphicx}
  \graphicspath{{img/}}
  \usepackage[top=1.0in, bottom=1.0in, left=0.85in, right=0.85in]{geometry}
  \usepackage[citecolor=blue,linkcolor=black,colorlinks=true]{hyperref}
  \setlength\parindent{0pt}
  \setlength{\columnsep}{1.5cm}
  \newcommand{\tmop}[1]{\ensuremath{\operatorname{#1}}}
  \newcommand{\grad}{$^{\circ}$}
  \begin{document}
  \title{}
  \author{}
  \date{}
  \maketitle

Formato para hacer un libro con tabla de contenidos

  documentclass{article}
  \usepackage[utf8]{inputenc}
  \usepackage[hidelinks]{hyperref}
  \usepackage{makeidx}
  \makeindex
  \usepackage{graphicx}
  \graphicspath{ {img/} }
  \begin{document}
  \title{}
  \author{}
  \date{}
  \maketitle
  \pagenumbering{roman}
  \newpage
  \renewcommand*\contentsname{Índice}
  \tableofcontents
  \newpage
  \pagenumbering{arabic}
  \end{document}
  \[[[sub]sub]sub]section{text}
  \[sub]paragraph{text}
  \usepackage{PackageName}

1.5. Ecuaciones

  $ecuacion$ si está dentro de un texto
  \begin{equation} \label{eq:foobar}
  ecuaciones
  \end{equation}
  Lo de arriba se puede citar como la ecuación \eqref{eq:foobar}
  \begin{equation*} \end{equation*} Así no pone un número a la ecuación
  \left( \left[ \right] \right) hace los (), [] del tamaño de las ecuaciones
  \frac{a}{b}
  \log_a{b}
  \sqrt[n]{x} = raiz n-esima de x
  \pm = +-
  \simeq = ~=
  \sim = ~
  \dot = ·
  \int^a_b f(x) dx = integral de f(x)dx entre a y b
  \int_S = integral en la superficie S
  \oint_C = integral de contorno (con el circulito)

1.6. Matrices

https://kogler.wordpress.com/2008/03/21/latex-multiline-equations-systems-and-matrices/

  \begin{[b|p|v|ø]matrix}
  1 & 0 \\
  0 & 1
  \end{[b|p|v|ø]matrix}
  Esto hace una matriz unidad 2x2 con **b**rackets [], **p**aréntesis (), lineas **v**erticales ||, o nada
  \cdots ...    \ddtos .
  \vdots                 .
  .                        .
  .
  .

1.7. Vectores

  \vec{p} dentro de equation*
  $\mathbf{v}$ dentro de texto

1.8. Formato

  \usepackage[margin = 1.5in]{geometry}
  ``entre comillas''
  Espacios
  \, < \: < \; cada uno es mayor
  \\ = cambio de parrafo, \\* = cambio de linea
  \linebreak, \newline, \newpage
  \ragged[left|right]{texto} = texto alineado derecha izquierda
  \centering{text} = texto alineado centro
  \begin{verbatim} Exactamente lo que ponga aqui \end{verbatim}
  % comentario
  Para poner unidades,
  $v= 10\text{ m/s}$, $v= 10\mathrm{ m/s}$
  o poner espacios
  $v = 10\:m/s$
  \usepackage{multicol}
  \begin{multicols}{2}
  Texto en 2 columnas
  \end{multicols}

  \usepackage{titling}
  \setlength{\droptitle}{-1in}

1.8.1. Fuentes

Para instalar las fuentes en Linux:

  # apt-get install texlive-fonts-recommended texlive-fonts-extra

Fonts with math support
Charter font (parecida a una Times)

  \usepackage[bitstream-charter]{mathdesign}
  %\usepackage[T1]{fontenc} (no hace falta)
  Palatino Linotype
  \usepackage{pxfonts, newpxmath}
  \texttt{Fuente monoespaciada para codigo}
  \textbf{bold}, \textit{italics}

1.9. Imágenes

  \includegraphics[width = \linewidth]{foo.jpg}
  \includegraphics[scale = 0.5]{bar.jpg}
  \caption{Descripcion de la foto}
  \label{fig:foo}
  .
  .
  .
  Como vemos en la figura \ref{fig:foo}
  \includegraphics[width=\linewidth, trim= left bottom right top, clip[=true]]
  Para alinear imágenes:
  \usepackage[export]{adjustbox}
  .
  .
  .
  \includegraphics[width=\linewidth, "[right|left|right]"]

1.10. Hyperref

  \usepackage[hidelinks]{hyperref}
  Si se pone un \label{nombre} despues de \begin{equation} y se incluye hyperref, cuando se pone \eqref{nombre},
  hyperref hace los links automáticamente

hyperref conviene colocarlo al final de todos los usepackage, puede causar problemas junto con otros paquetes en caso contrario.
apacite hay que ponerlo después de hyperref, creo que al ser más reciente no se lleva bien con hyperref

1.11. Bibtex

https://www.overleaf.com/learn/latex/Bibliography_management_with_bibtex

\bibliographystyle{unsrt} % bibliografía ordenada por orden de aparición

.
.
.
% al final de todo

\bibliography{refs} % Entries are in the refs.bib file

Página web a bibtex:
https://www.getbibtex.com/

1.12. Listas indentadas

https://www.scijournal.org/articles/latex-bullet-points

\renewcommand{\labelenumii}{\Roman{enumii}}

 \begin{enumerate}

   \item This item is in the first level

   \item This item is in the first level

   \begin{enumerate}

     \item This item is in the second level

     \item This item is in the second level

     \begin{enumerate}

       \item This item is in the third level

       \item This item is in the third level

       \begin{enumerate}

         \item This item is in the fourth level

         \item This item is in the fourth level

       \end{enumerate}

     \end{enumerate}

 \end{enumerate}

 \end{enumerate}

1.13. Español

  Para usar tildes y ñ normalmente:
  \usepackage[utf8]{inputenc}
  \'a = á
  ?` = ¿
  !` = ¡
  \~n = ñ

1.14. Lilypond

  \include "lilypond-book-preamble.ly"
  \paper {
    #(define dump-extents #t)
    indent = 0\mm
    line-width = 160\mm
    force-assignment = #""
    line-width = #(- line-width (* mm  3.000000))
  }

Genera un montón de basura al compilar a png.

  $ lilypond  --png -dresolution=200 li.ly
  Genera
  li-1.eps
  li.eps
  li.ly
  li.png
  li-systems.count
  li-systems.tex
  li-systems.texi
  function lily2png {
  file=${1%.*};
  lilypond  --png -dresolution=200 $1 && rm -f "$file"-1.eps "$file".eps "$file"-systems.count "$file"-systems.tex "$file"-systems.texi && echo "Eliminando archivos auxiliares...";
  }
  function lytex2pdf {
  rand=`cat /dev/urandom | tr -cd 'a-f0-9' | head -c 8`
  file=${1%.*};
  mkdir $rand && lilypond-book --output=lilyout --pdf $1 && cd lilyout && texi2pdf --clean "$file".tex && mv "$file".pdf ../ && cd .. && rm -rf $rand;
  }

Author: Julian Lopez Carballal

Created: 2024-09-16 Mon 06:59