Labels and cross-references · תוויתות והפניות פנימיות
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.
לעולם אל תכתבו "ראו פרק 3" ידנית
- אם תכתבו מספר ידנית ובהמשף תוסיפו פרק, כל המספרים יהיו שגויים.
- LaTeX פותר בעיה זו באמצעות תוויות. סימנו דבר מה:
\section{Methods}\label{sec:methods}
- השם
sec:methodsהוא פשוט כינוי שתבחרו.
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.
התייחסו אליה בכל מקום
- הצביעו עליה עם
\ref— LaTeX תדפיס את המספר הנוכחי:
As shown in Section~\ref{sec:methods}, ...
- ה-
~הוא מרווח שאינו נשבר בין שורות, כך שה"פרק" ומספרו נשארים יחד.
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.)
זה דורש שני מעברים
- במעבר הה compilation הראשון LaTeX לומד את המספרים; במעבר השני הוא ממלא אותם.
- ה-Run שלנו עושה זאת עבורכם באופן אוטומטי. (אותה טריק משמש גם לעמוד תוכנים.)
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.
טעויות נפוצות
- הניחו
\label{...}אחרי מה שאתם רוצים לקרוא לו, ואז התייחסו אליו עם\ref{...}. - בצעו שני compiles כדי שההפניות החוצות יתייצבו למספרים הנכונים.
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. · תווה את החלק "שיטות" עם \label{sec:methods}, ולאחר מכן התייחס אליו בשורה האחרונה עם \ref{sec:methods}. LaTeX ממלא עבורך את המספר הנכון.
The same numbering machinery builds a table of contents. Add \tableofcontents as the first line of the body — LaTeX lists every section automatically. · אותו מנגנון מספור בונה גם טבלת תוכנים. הוסף \tableofcontents כשורה הראשונה בגוף המסמך — LaTeX רשום אוטומטית כל חלק.