From d7fc0a3a70dbb6cc283c90bae3f1de600bfb7aee Mon Sep 17 00:00:00 2001 From: Katia Gatt Date: Tue, 25 Mar 2025 23:51:57 +0100 Subject: [PATCH] Update 009.md --- book/syntax_exercises/009.md | 45 ++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/book/syntax_exercises/009.md b/book/syntax_exercises/009.md index e2dc43f..63743c6 100644 --- a/book/syntax_exercises/009.md +++ b/book/syntax_exercises/009.md @@ -10,7 +10,7 @@ Can you create internal references to other sections, equations, tables, figures 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 +## Referencing a Chapter or Section 1. Open a new or existing Markdown file where you want to add a reference. 2. Let's start with the simplest way to create a reference to another chapter. This is by directly linking it through the file path as shown in the following syntax: @@ -25,15 +25,14 @@ For example, if you want to link to Exercise 7, you can write: [Go to Exercise 7](../exercises/007.md) ``` -3. If we want to refer to a section within the same file, we can use local refencing by directly inputting the name of the required section. +3. If we want to refer to a section within the same file, we can use local refencing by directly inputting the name of the required section. For example: [Jump to the next section](#referencing-an-equation) ```md -[Jump to the next section](# 2. Referencing an Equation) +[Jump to the next section](#referencing-an-equation) ``` -[Jump to the next section](# 2. Referencing an Equation) -4. Try out another way of referencing by using a target header. Navigate to the chapter or section you want to reference and assign it an identifier using `{ref}` as shown in the example below. This could be once again in the same markdown file, or a different file altogether. +4. Try out another way of referencing by using a target header. Navigate to the chapter or section you want to reference and assign it an identifier using `{ref}` as shown in the example below. This could be once again in the same markdown file, or a different file in the same repository. ```md (exercise_1)= @@ -41,33 +40,30 @@ For example, if you want to link to Exercise 7, you can write: Let's start with the most basic edit: add some text to a file and see that the website is updated... ``` -5. Now, let's explore three different ways to reference this section or chapter! For the first method, we use the standard title text by calling the identifier as follows: +5. Now, let's explore three different ways to reference this section or chapter! For the first method, we use the standard title text by calling the identifier as follows. This will display: My favourite exercise was {ref}`exercise_1`. ```md My favourite exercise was {ref}`exercise_1`. ``` - This will display: My favourite exercise was {ref}`exercise_1`. -6. For the second method, we want to refer to the section using a custom title text. Try this out by placing the text that you want to be displayed within the `` and calling the identifier within the <> as follows: +6. For the second method, we want to refer to the section using a custom title text. Try this out by placing the text that you want to be displayed within `` and calling the identifier within <>. +This will display: My favourite exercise was {ref}`the first one `. ```md My favourite exercise was {ref}`the first one `. ``` - This will display: My favourite exercise was {ref}`the first one `. -7. The last method uses markdown syntax to also display a custom title text. Refer to the desired section once again, this time by putting the custom text within the [] and calling the identifier within the <> as shown below: +7. The last method uses markdown syntax to also display a custom title text. Refer to the desired section once again, this time by putting the custom text within the [] and calling the identifier within the <> as shown below. This will display: My favourite exercise was [this one](exercise_1). ```md My favourite exercise was [this one](exercise_1). ``` - This will display: My favourite exercise was [this one](exercise_1). - -## 2. Referencing an Equation +## Referencing an Equation 8. Now we will test our knowledge using an equation. Similar to the code below, create an equation using $$ and identify it using a label within the brackets. @@ -80,25 +76,26 @@ Let's start with the most basic edit: add some text to a file and see that the w $$ F = m \cdot a$$ (eq:Newton) -8. To refer to this equation we need to use {eq} and call the identifier within the ``. This will display: Refer to Equation {eq}`eq:Newton`. +8. To refer to this equation we need to use `{eq}` and call the identifier within the `` to achieve: Refer to Equation {eq}`eq:Newton`. ```md Refer to Equation {eq}`eq:Newton` ``` -## 3. Referencing a Table +## Referencing a Table -9. Similar methods can also be used to refer to a table. Start by creating a table by copying the markdown below. The identifier is defined using ':name:'. +9. Similar methods can also be used to refer to a table. Start by creating a table by copying the code below. The identifier is defined using `:name:`. -```md + ```md ```{table} Example Table :name: tab-example | Column 1 | Column 2 | |----------|----------| | A | B | ``` -``` + ``` + ```{table} Example Table name: tab-example @@ -115,11 +112,11 @@ name: tab-example ``` -## 4. Referencing a Figure +## Referencing a Figure -11. This can also be done for a figure. Let's add a figure as we learnt in [Exercise 7](007.md), but this time adding an identifier using 'name:'. +11. This can also be done for a figure. Let's add a figure as we learnt to do in [Exercise 7](007.md), but this time adding an identifier using `name:`. -```md + ```md ```{figure} figures/example.png --- width: 80% @@ -128,7 +125,7 @@ name: tab-example --- Example figure. ``` -``` + ``` 12. Refer to the figure in the format {numref}`Figure {number} ` using `{numref}` as follows: @@ -136,7 +133,7 @@ name: tab-example {numref}`Figure {number} ` ``` -## 5. Referencing a Link +## Referencing a Link 13. Finally, lets reference a link, using the following syntax: @@ -151,8 +148,6 @@ Here is the [link to the template](https://teachbooks.github.io/template/). ``` -## 6. Commit Your Changes - 14. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button. 15. Add a commit message.