mirror of
https://github.com/TeachBooks/template.git
synced 2026-11-12 22:25:52 +00:00
Exercise 9
This commit is contained in:
parent
e3da25e82d
commit
d27b8e6f85
1 changed files with 100 additions and 0 deletions
100
book/syntax_exercises/009.md
Normal file
100
book/syntax_exercises/009.md
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
# Exercise 9: Cross-referencing content
|
||||
|
||||
In this exercise, you will learn how to create references to other parts of your book, such as chapters, equations, tables, and figures.
|
||||
|
||||
::::::{topic} Exercise objective
|
||||
Can you create internal references to other sections, equations, tables, and figures?
|
||||
::::::
|
||||
|
||||
```{tip}
|
||||
Referencing elements properly ensures that readers can navigate your book more easily. More details can be found in the [JupyterBook documentation](https://jupyterbook.org/en/stable/content/references.html).
|
||||
```
|
||||
|
||||
## 1. Referencing a Chapter or Section
|
||||
|
||||
To create a reference to another chapter or section, use the following syntax:
|
||||
|
||||
```md
|
||||
[Text to display](path/to/file.md)
|
||||
```
|
||||
|
||||
For example, if you want to link to Exercise 7, you can write:
|
||||
|
||||
```md
|
||||
[Go to Exercise 7](../exercises/007.md)
|
||||
```
|
||||
|
||||
|
||||
## 2. Referencing an Equation
|
||||
|
||||
To reference an equation, you need to define a label using `{eq}` and refer to it elsewhere in your text:
|
||||
|
||||
```md
|
||||
```{math}
|
||||
:label: eq-example
|
||||
E = mc^2
|
||||
```
|
||||
```
|
||||
|
||||
You can then reference this equation using:
|
||||
|
||||
```md
|
||||
Equation {eq}`eq-example`
|
||||
```
|
||||
|
||||
## 3. Referencing a Table
|
||||
|
||||
To reference a table, assign a label when defining it:
|
||||
|
||||
```md
|
||||
```{table} Example Table
|
||||
:label: tab-example
|
||||
| Column 1 | Column 2 |
|
||||
|----------|----------|
|
||||
| A | B |
|
||||
```
|
||||
```
|
||||
|
||||
And refer to it using:
|
||||
|
||||
```md
|
||||
Table {numref}`tab-example`
|
||||
```
|
||||
|
||||
## 4. Referencing a Figure
|
||||
|
||||
To reference a figure, label it when inserting it:
|
||||
|
||||
```md
|
||||
```{figure} figures/example.png
|
||||
---
|
||||
width: 80%
|
||||
align: center
|
||||
name: fig-example
|
||||
---
|
||||
Example figure.
|
||||
```
|
||||
```
|
||||
|
||||
And refer to it using:
|
||||
|
||||
```md
|
||||
Figure {numref}`fig-example`
|
||||
```
|
||||
|
||||
## 5. Commit Your Changes
|
||||
|
||||
1. Once you have added your references, commit your changes to the repository.
|
||||
2. Click the green `Commit changes` button.
|
||||
3. Add a commit message.
|
||||
4. View your changes using the `Actions` tab and check if they appear correctly.
|
||||
|
||||
```{admonition} Check your understanding
|
||||
:class: note
|
||||
|
||||
Before moving on to the next exercise, make sure you understand the following:
|
||||
- How do you reference another chapter?
|
||||
- How do you create a reference to an equation?
|
||||
- How can you refer to a table or a figure in your book?
|
||||
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue