diff --git a/book/syntax_exercises/009.md b/book/syntax_exercises/009.md index 5a99762..cd60613 100644 --- a/book/syntax_exercises/009.md +++ b/book/syntax_exercises/009.md @@ -1,180 +1,70 @@ -# Exercise 9: Cross-referencing content +# Exercise 9: Use equations -In this exercise, you will learn how to create references to other parts of your book, such as chapters, sections, equations, tables and figures, as well as links. +In this exercise, you will learn how to write and format mathematical equations in your TeachBook, both inline and as standalone blocks. ::::::{topic} Exercise objective -Can you create internal references to other sections, equations, tables, figures, and links? +Can you format and reference equations correctly in your book? :::::: ```{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). +Using properly formatted equations makes mathematical expressions clearer and more professional. More details can be found in the [JupyterBook documentation](https://jupyterbook.org/en/stable/content/math.html). ``` -## Referencing a Chapter or Section +## Writing equations -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. Try this out by directly linking the chapter through the file path as shown in the following syntax. +1. Open a new or existing Markdown file where you want to include an equation. +2. Start with a simple block equation using double dollar signs. Try adding the following equation in your Markdown file: ```md -[Text to display](path/to/file.md) +$$ F_{res} = m \cdot a $$ ``` -For example, if you want to link to Exercise 7, you can write: - -```md -[Go to Exercise 7](../exercises/007.md) -``` - -If you leave the text part empty, the title of the chapter you're referring to will be used: - -```md -[](path/to/file.md) -``` - -```{tip} -If the chapter you're referring to is in different directory than your chapter, you'll need to refer it using relative parts. If the to be referenced chapter is in a subdirectory of the directory of the chapter, go deeper with `subdirectory/` (e.g. `/.md`). If the to be referenced chapter is in another directory, move upwards with `../` (e.g. `../..//` ) -``` - -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. Use the example below to test this out. - -```md -[Jump to the next section](#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 within brackets 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)= -# 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... -``` -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. - -```md -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 `` and calling the identifier within <>. - -```md -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 [] and calling the identifier within <> as shown below. +3. Now, add an inline equation by enclosing the equation with single dollar signs. Try this example: ```md -My favourite exercise was [this one](exercise_1). +The displacement can be found using the equation $s = v \cdot t$. ``` +## Formatting mathematical symbols -## 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. +4. In this step we will experiment with different LaTeX symbols. Use the following table and test each example in your Markdown file: -```md +| Name | Script | +|---|---| +| Square root | `\sqrt{4}` | +| Power | `^{2x}` | +| Fraction | `\frac{2}{3}` | +| Subscript | `_{gem}` | +| Superscript | `^{N}` | +| Multiplication | `\cdot` | -$$ F = m \cdot a$$ (eq:Newton) +5. Extend this exercise by trying more advanced mathematical expressions: -``` +| Name | Script | +|---|---| +| Derivative | `\frac{\Delta f}{\Delta t}` | +| Integral | `\int_a^b dx` | +| Sine function | `\sin(x)` | - $$ F = m \cdot a$$ (eq:Newton) +6. Test your understanding by adding a new equation of your choice, ideally one that requires many LaTex symbols! -9. Refer to this equation by using `{eq}` and calling the identifier within the ``. This will automatically insert the number of the equation. You can add text as you did in exercise 6. +7. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button. -```md -Refer to Equation {eq}`eq:Newton` -``` +8. Add a commit message. -Alternatively, you can use the default `[]()`. +9. To see your changes, go to {octicon}`play;1em` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting). -## Referencing a Table - -10. 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 -```{table} Example Table -:name: tab-example -| Column 1 | Column 2 | -|----------|----------| -| A | B | -``` -```` - - -```{table} Example Table -:name: tab-example -| Column 1 | Column 2 | -|----------|----------| -| A | B | -``` - -11. Refer to the table like with custom text 'My table' and the number using `{numref}` and `{number}` as follows. You can add text as you did in exercise 6. - - -```md -{numref}`My table {number} ` -``` - -Alternatively, you get an automatic text 'Table ' and the number when using `` {numref}`` ``. Or use `{ref}` to use the table name instead of number. Next to all of that you can use the default `[]()`. - -## Referencing a Figure - -12. This can also be done for a figure. Let's add a figure as we learnt to do in [Exercise 8](008.md), but this time adding an identifier using `name:`. - -````md -```{figure} figures/example.png ---- -width: 80% -align: center -name: fig-example ---- -Example figure. -``` -```` - - -13. Refer to the figure in the with custom text 'Figure' and the number using `{numref}` as follows. You can add text as you did in exercise 6. - -```md -{numref}`Figure {number} ` -``` - -Alternatively, you get an automatic text 'Fig.' and the number when using `` {numref}`` ``. Or use `{ref}` to use the figure name instead of number. Next to all of that you can use the default `[](
)`. - - -## Referencing a Link - -14. Finally, let's reference a link, using the following syntax: - -```md -[Text to display](url) -``` -For example, you can use the code. - - -```md -Here is the [link to the template](https://teachbooks.github.io/template/). -``` - - -15. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button. - -16. Add a commit message. - -17. To see your changes, go to {octicon}`play;1em` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting). -18. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page. +10. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page. ```{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 or section? -- How do you create a reference to an equation, table or figure in your book? -- How do you reference a link? -``` \ No newline at end of file +- What is the difference between inline and block equations? +- How do you use LaTeX formatting for different mathematical symbols? + +``` + diff --git a/book/syntax_exercises/010.md b/book/syntax_exercises/010.md new file mode 100644 index 0000000..baa6312 --- /dev/null +++ b/book/syntax_exercises/010.md @@ -0,0 +1,65 @@ +# Exercise 10: Create tables + +In this exercise, you will learn how to create and format tables in your TeachBook using Markdown and reStructuredText. + +::::::{topic} Exercise objective +Can you correctly format tables and reference them within your book? +:::::: + +```{tip} +Tables help organize and present structured data clearly. JupyterBook supports Markdown tables and reStructuredText list-tables. +``` + +## Writing Tables with Markdown + +1. Open a new or existing Markdown file where you want to insert a table. +2. Add a simple table using the `|` separator and `---` for column alignment. Try the following example: + +```md +| Column 1 | Column 2 | Column 3 | +|---|---|---| +| Data 1 | Data 2 | Data 3 | +| Data 4 | Data 5 | Data 6 | +``` + +## Creating Tables with reStructuredText + +3. You can also create tables using the `list-table` directive. The advantage of this method is that it allows referencing (refer to [Exercise 11](011.md)). Try the following example: + +````md +```{list-table} Sample Data Table +:header-rows: 1 +* - Category + - Value 1 + - Value 2 +* - Item A + - 10 + - 20 +* - Item B + - 15 + - 30 +``` +```` + +5. To test your understanding, try and create a new table from scratch with at least three columns, ensuring proper alignment and formatting, using both methods described above. + +6. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button. + +7. Add a commit message. + +8. To see your changes, go to {octicon}`play;1em` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting). + +9. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page. + + + +```{admonition} Check your understanding +:class: note + +Before moving on to the next exercise, make sure you understand the following: +- How do you create a basic table using Markdown? +- When would you choose to use a `list-table` instead of a Markdown table? +- What syntax is required to define a `list-table`? +- How do you specify column headers in a `list-table`? +``` + diff --git a/book/syntax_exercises/011.md b/book/syntax_exercises/011.md new file mode 100644 index 0000000..352cd63 --- /dev/null +++ b/book/syntax_exercises/011.md @@ -0,0 +1,180 @@ +# Exercise 11: Cross-referencing content + +In this exercise, you will learn how to create references to other parts of your book, such as chapters, sections, equations, tables and figures, as well as links. + +::::::{topic} Exercise objective +Can you create internal references to other sections, equations, tables, figures, and links? +:::::: + +```{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). +``` + +## 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. Try this out by directly linking the chapter through the file path as shown in 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) +``` + +If you leave the text part empty, the title of the chapter you're referring to will be used: + +```md +[](path/to/file.md) +``` + +```{tip} +If the chapter you're referring to is in different directory than your chapter, you'll need to refer it using relative parts. If the to be referenced chapter is in a subdirectory of the directory of the chapter, go deeper with `subdirectory/` (e.g. `/.md`). If the to be referenced chapter is in another directory, move upwards with `../` (e.g. `../..//` ) +``` + +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. Use the example below to test this out. + +```md +[Jump to the next section](#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 within brackets 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)= +# 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... +``` +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. + +```md +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 `` and calling the identifier within <>. + +```md +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 [] and calling the identifier within <> as shown below. + + +```md +My favourite exercise was [this one](exercise_1). +``` + + +## 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. + + +```md + +$$ F = m \cdot a$$ (eq:Newton) + +``` + + $$ F = m \cdot a$$ (eq:Newton) + +9. Refer to this equation by using `{eq}` and calling the identifier within the ``. This will automatically insert the number of the equation. You can add text as you did in exercise 6. + +```md +Refer to Equation {eq}`eq:Newton` +``` + +Alternatively, you can use the default `[]()`. + +## Referencing a Table + +10. 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 +```{table} Example Table +:name: tab-example +| Column 1 | Column 2 | +|----------|----------| +| A | B | +``` +```` + + +```{table} Example Table +:name: tab-example +| Column 1 | Column 2 | +|----------|----------| +| A | B | +``` + +11. Refer to the table like with custom text 'My table' and the number using `{numref}` and `{number}` as follows. You can add text as you did in exercise 6. + + +```md +{numref}`My table {number} ` +``` + +Alternatively, you get an automatic text 'Table ' and the number when using `` {numref}`` ``. Or use `{ref}` to use the table name instead of number. Next to all of that you can use the default `[](
)`. + +## Referencing a Figure + +12. This can also be done for a figure. Let's add a figure as we learnt to do in [Exercise 8](008.md), but this time adding an identifier using `name:`. + +````md +```{figure} figures/example.png +--- +width: 80% +align: center +name: fig-example +--- +Example figure. +``` +```` + + +13. Refer to the figure in the with custom text 'Figure' and the number using `{numref}` as follows. You can add text as you did in exercise 6. + +```md +{numref}`Figure {number} ` +``` + +Alternatively, you get an automatic text 'Fig.' and the number when using `` {numref}`` ``. Or use `{ref}` to use the figure name instead of number. Next to all of that you can use the default `[](
)`. + + +## Referencing a Link + +14. Finally, let's reference a link, using the following syntax: + +```md +[Text to display](url) +``` +For example, you can use the code. + + +```md +Here is the [link to the template](https://teachbooks.github.io/template/). +``` + + +15. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button. + +16. Add a commit message. + +17. To see your changes, go to {octicon}`play;1em` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting). +18. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page. + + +```{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 or section? +- How do you create a reference to an equation, table or figure in your book? +- How do you reference a link? +``` \ No newline at end of file