Skip to content

Commit

Permalink
Merge pull request the-turing-way#3392 from llewelld/3349-community-h…
Browse files Browse the repository at this point in the history
…andbook-cross-ref-cases

Rationalise cross referencing examples
  • Loading branch information
llewelld authored Nov 14, 2023
2 parents b9a4db2 + 73665e3 commit 8b7d049
Showing 1 changed file with 11 additions and 37 deletions.
48 changes: 11 additions & 37 deletions book/website/community-handbook/style/style-crossref.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,62 +80,36 @@ This label can be created in the corresponding file for the suggested section na

### Examples of cross-referencing

**Examples for cross-referencing sections of chapters and subchapters**

Here we provide examples of how to cross-reference chapters, sections of chapters and subchapters.
We will use examples for the chapters in the "Reproducible Research" guide located in the `book/website` directory.

**_Case 1_**: When you cross-reference a section of the chapter within the same file _before_ a label has been created.
**_Example 1_**: Cross-referencing a chapter or subchapter (chapter/subchapter).

Taking the previous example of `rr-overview-resources-addmaterial`, we can use this label to cross-reference
it in an earlier section within the same file using the following:
On the landing page of the chapter "Open Research", we have created a label `rr-open`.
We can cross-reference it at any other point in the book by using the following:

```
{ref}`rr-overview-resources-addmaterial`
{ref}`rr-open`
```

This will appear in the online book like so: {ref}`rr-overview-resources-addmaterial`.

**_Case 2_**: When you cross-reference a section of the chapter within the same file _after_ a label has been created.

In the same subchapter "Resources", we have created a label `rr-overview-resources-reading` for the section "Further Reading".
We can cross-reference it in a later section within the same file using the following:

```
{ref}`rr-overview-resources-reading`
```
It will appear in your chapter like this: {ref}`rr-open`.

It will appear in your chapter like this: {ref}`rr-overview-resources-reading`.
It doesn't matter whether the label appears before or after the reference, or even on a completely different page.
The same syntax can be used whether you are cross-referencing chapters and subchapters within the same chapter, or in other chapters across the book.

**_Case 3_**: When you cross-reference a section of a chapter in a different file (chapter) before or after a label has been created.
**_Example 2_**: Cross-referencing a section of a chapter.

In the subchapter "Definitions" of the "Overview" chapter, we have created a label
`rr-overview-definitions` for the section "Table of definitions for reproducibility".

We can cross-reference it in a different subchapter or chapter.
In this case, let's cross-reference it in the landing (main) page of the "Overview" chapter by using the following:
We can cross-reference it elsewhere in the book by using the following:

```
{ref}`rr-overview-definitions`
```

It will appear in your chapter like this: {ref}`rr-overview-definitions`.

Though we are demonstrating this example for subchapters within the same chapter ("Overview"), the similar syntaxes can be used for cross-referencing in other chapters within the book.

**Examples for Cross referencing chapters and subchapters**

**_Case 4_**: Cross-referencing a chapter or subchapter in a different file (chapter/subchapter) before or after a label has been created.

For example, in the landing page of the chapter "Open Research", we have created a label `rr-open`.
We can cross-reference it in the section "What to learn next?" in a different subchapter "Resources" of the "Overview" chapter by using the following:

```
{ref}`rr-open`
```

It will appear in your chapter like this: {ref}`rr-open`.

Though we are demonstrating this example for cross-referencing chapters and subchapters across the book, the same syntax can be used for cross-referencing subchapters within the same chapter.
As before it doesn't matter where the label appears relative to the reference, this same syntax can be used whether you are cross-referencing sections within the same chapter, or in other chapters across the book.

### Providing an alternative title for the references

Expand Down

0 comments on commit 8b7d049

Please sign in to comment.