Labels and cross-references · Etiquetas y referencias cruzadas
Never write "see Section 3" by hand
- If you write a number by hand and later add a section, every number is wrong.
- LaTeX solves this with labels. Tag something:
- The name
sec:methodsis just a nickname you choose.
Nunca escribas "ver Sección 3" a mano
- Si escribes un número a mano y después agregas una sección, todos los números estarán mal.
- LaTeX resuelve esto con etiquetas. Etiqueta algo:
\section{Methods}\label{sec:methods}
- El nombre
sec:methodses simplemente un apodo que tú elijas.
Refer to it anywhere
- Then point at it with
\ref— LaTeX inserts the current number:
- The
~is a space that never breaks across lines, so "Section" and its number stay together.
Refiérete a él en cualquier lugar
- Luego señala hacia él con
\ref— LaTeX inserta el número actual:
As shown in Section~\ref{sec:methods}, ...
- El
~es un espacio que nunca se rompe entre líneas, así que "Sección" y su número permanecen juntos.
It needs two passes
- On the first compile LaTeX learns the numbers; on the second it fills them in.
- Our Run does this for you automatically. (The same trick powers a table of contents.)
Necesita dos pasadas
- En la primera compilación, LaTeX aprende los números; en la segunda, los completa.
- Nuestro Ejecutar hace esto por ti automáticamente. (El mismo truco impulsa una tabla de contenidos.)
Common mistakes
- Put
\label{...}after what you want to name, then refer to it with\ref{...}. - Compile twice so cross-references settle to the right numbers.
Errores comunes
- Coloca
\label{...}después de lo que quieras nombrar, luego refiérete a él con\ref{...}. - Compila dos veces para que las referencias cruzadas se ajusten a los números correctos.
Label the Methods section with \label{sec:methods}, then refer to it from the last line with \ref{sec:methods}. LaTeX fills in the correct number for you. · Etiqueta la sección de Métodos con \label{sec:methods}, luego haz referencia a ella en la última línea con \ref{sec:methods}. LaTeX rellena automáticamente el número correcto.
The same numbering machinery builds a table of contents. Add \tableofcontents as the first line of the body — LaTeX lists every section automatically. · El mismo mecanismo de numeración construye una tabla de contenidos. Añade \tableofcontents como primera línea del cuerpo — LaTeX lista cada sección automáticamente.