diff --git a/book/syntax_exercises/009.md b/book/syntax_exercises/009.md index 14111bc..7b071a2 100644 --- a/book/syntax_exercises/009.md +++ b/book/syntax_exercises/009.md @@ -1,6 +1,6 @@ # 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. +In this exercise, you will learn how to create references to other parts of your book, such as chapters, sections, equations, tables, and figures. ::::::{topic} Exercise objective Can you create internal references to other sections, equations, tables, and figures? @@ -24,6 +24,36 @@ For example, if you want to link to Exercise 7, you can write: [Go to Exercise 7](../exercises/007.md) ``` +Alternatively, you can use `{ref}` to reference a section with a target header. + +First, define the section you want to reference by assigning it an identifier: + +```md +(exercise_1)= +# Exercise 1: First file edit + +Let's start with the most basic edit: add some text to a file and see that the website is updated... +``` + +Then, you can reference this section in three ways: + +- Using the standard title text: + ```md + My favourite exercise was {ref}`exercise_1`. + ``` + This will display: *My favourite exercise was Exercise 1: First file edit.* + +- Specifying a custom title text: + ```md + My favourite exercise was {ref}`the first one `. + ``` + This will display: *My favourite exercise was the first one.* + +- Using Markdown syntax: + ```md + My favourite exercise was [this one](exercise_1). + ``` + This will display: *My favourite exercise was this one.* ## 2. Referencing an Equation @@ -93,8 +123,6 @@ Figure {numref}`fig-example` :class: note Before moving on to the next exercise, make sure you understand the following: -- How do you reference another chapter? +- How do you reference another chapter or section? - How do you create a reference to an equation? - How can you refer to a table or a figure in your book? - -``` \ No newline at end of file