Labels and cross-references · Rótulos e referências 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 escreva "veja Seção 3" manualmente
- Se você escrever um número manualmente e depois adicionar uma seção, todos os números estarão errados.
- O LaTeX resolve isso com rótulos. Marque algo:
\section{Methods}\label{sec:methods}
- O nome
sec:methodsé apenas um apelido que você escolhe.
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.
Referencie-o em qualquer lugar
- Então aponte para ele com
\ref— o LaTeX insere o número atual:
As shown in Section~\ref{sec:methods}, ...
- O
~é um espaço que nunca quebra entre linhas, mantendo "Seção" e seu número 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.)
Precisa de duas passagens
- Na primeira compilação, o LaTeX aprende os números; na segunda, ele os preenche.
- Nosso Executar faz isso automaticamente para você. (A mesma técnica alimenta uma tabela de conteúdos.)
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.
Erros comuns
- Coloque
\label{...}após o que deseja nomear, depois referencie-o com\ref{...}. - Compile duas vezes para que as referências cruzadas se ajustem aos números corretos.
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. · Rotule a seção Methods com \label{sec:methods}, depois refira-se a ela na última linha com \ref{sec:methods}. O LaTeX preencherá o número correto para você.
The same numbering machinery builds a table of contents. Add \tableofcontents as the first line of the body — LaTeX lists every section automatically. · A mesma máquina de numeração constrói uma tabela de conteúdos. Adicione \tableofcontents como a primeira linha do corpo — o LaTeX lista todas as seções automaticamente.