Skip to content

Commit

Permalink
Further work and refinement in preparation for SheffieldR
Browse files Browse the repository at this point in the history
  • Loading branch information
slackline committed Oct 8, 2023
1 parent 3ff6370 commit cac0714
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 35 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.quarto/
_site
_site/*
\#*
*~
.quarto/*
_extensions/*
5 changes: 4 additions & 1 deletion .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ config:
allowed_elements:
- div

# Globs
globs:
- "**/*.md"
- "**/*.qmd"

ignore:
- ".quarto/*"
- "_site/*"

# Fix any fixable errors
fix: true
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,13 @@ self](https://rse.shef.ac.uk/blog/pre-commit/) or refer to the official document

## Extensions

There is a growing number of useful [Quarto extensions](https://quarto.org/docs/extensions/). Three are included in this
There are a growing number of useful [Quarto extensions](https://quarto.org/docs/extensions/). Three are included in this
template and they are also installed during the publishing and deployment of the resulting slides as they are listed in
the `quarto-publish.yml`. You should have installed these locally as instructed above.

``` bash
quarto install --no-prompt extension jmbuhr/quarto-qrcode
quarto install --no-prompt extension grantmcdermott/quarto-revealjs-clean
quarto install --no-prompt extension ArthurData/quarto-confetti
```

If you use additional extensions you **MUST** remember to add them to the `Install Quarto Extensions` section of
`.github/workflows/quarto-publish.yaml`.
If you use additional extensions then as well as installing them locally on your computer you **MUST** remember to add
them to the `Install Quarto Extensions` section of `.github/workflows/quarto-publish.yaml` otherwise your pages will not
build and deploy.

### QR Code generation

Expand All @@ -128,12 +123,21 @@ results, whether that is tables, figures, or numbers, can be included in the res
languages including perhaps the two of the most popular languages [R](https://www.r-project.org) and
[Python](https://www.python.org).

### R (**TODO**)
### R

You will likely have [R](https://www.r-project.org) installed locally along with all the packages that are required (and
perhaps even use reproducible environments using [renv](https://rstudio.github.io/renv/) or
[pak](https://pak.r-lib.org)).

For slides to build and execute your R code correctly you need to enable installation of R and the required packages in
the `.github/workflows/quarto-publish.yaml`. A sample section is already present that should just need un-commenting,
but may need tweaking if you use any packages to manage a reproducible environment.

You need to enable installation of R and the required packages in the `.github/workflows/quarto-publish.yaml` and a
sample section is already present that should just need un-commenting.
### Python

### Python (**TODO**)
Similarly with Python you likely have Virtual Environments configured locally to run your Python code, and these should
have be detailed in a `requirements.txt` file so they can be installed when the GitHub Workflow is executed to build
your pages on GitHub.

As with R need to enable installation of R and the required packages in the `.github/workflows/quarto-publish.yaml` and
a sample section is already present that should just need un-commenting.
You will need to enable installation of Python and these packages in the `.github/workflows/quarto-publish.yaml` and
a sample section is already present that can be un-commented if required.
Binary file added img/OSC_Sheffield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 129 additions & 18 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ project:

## Quarto RevealJS Slides

This is a website [Quarto](https://quarto.org/) website of [RevealJS](https://revealjs.com/) slides.
This is a [Quarto](https://quarto.org/) template for creating [RevealJS](https://revealjs.com/) slides.

The template can be used as a starting point for your own slides and includes a number of different layouts and examples
of Markdown syntax, slide layout, links, embedding images and configuration options.
Expand All @@ -44,8 +44,6 @@ Quarto slides are written in [Markdown](https://quarto.org/docs/authoring/markdo
| `superscript^1^`, `subscript~2~` | superscript^1^, subscript~2~ |
| `~~strikethrough~~` | ~~strikethrough~~ |
| ```code``` | `code` |
| `# Header 1` | |
| `## Header 2` | |
| `[Quarto](https://quarto.org)` | [Quarto](https://quarto.org) |

::: {.notes}
Expand All @@ -60,7 +58,7 @@ different types.
:::: {.columns}

::: {.column width="50%"}
Unordered...
**ToDo** (code)

```markdown
+ Learn Markdown
Expand All @@ -71,7 +69,7 @@ Unordered...
:::

::: {.column width="50%"}
Unordered...
**ToDo** (Rendered)

+ Learn Markdown
+ Create Quarto Slides
Expand All @@ -81,18 +79,15 @@ Unordered...
::::

::: {.notes}
We can create unordered lists.
Slides can have columns and we can create unordered lists.
:::

## Columns and Lists (cont.)

Slides can have columns and you can create [lists](https://quarto.org/docs/authoring/markdown-basics.html#lists) of
different types.

:::: {.columns}

::: {.column width="50%"}
Ordered...
**Ordered** (code)

```markdown
1. A comes before
Expand All @@ -103,7 +98,7 @@ Ordered...
:::

::: {.column width="50%"}
Ordered...
**Ordered** (Rendered)

1. A comes before
2. B which is followed by
Expand Down Expand Up @@ -161,36 +156,147 @@ You can write equations if you need to.

## Embed Images

[Figures](https://quarto.org/docs/authoring/figures.html) can be embeded using a URL and resized.

```markdown
![Relaxing in the mountains](https://live.staticflickr.com/65535/53144704609_c5e6fa8c77_k.jpg){width=700}
```

![Relaxing in the Julian Alps](https://live.staticflickr.com/65535/53144704609_c5e6fa8c77_k.jpg){width=700}

::: {.notes}
:::

## Embed Images (*cont.*)

You can also include images locally.^[Make sure to `git add` them otherwise they won't publish] and make them hyperlinks.

```markdown
![[OSC Sheffield](https://osc-international.com/osc-sheffield)](img/OSC_Sheffield.png){width=300}
```

![[OSC Sheffield](https://osc-international.com/osc-sheffield)](img/OSC_Sheffield.png){width=300}

::: {.notes}
:::

## R code

```{R}
:::: {.columns}

::: {.column width="50%"}
Include [R code and output](https://quarto.org/docs/computations/r.html) with automatic referencing (see @fig-airquality2)

```{r}
#| label: fig-airquality
#| fig-cap: "Temperature and ozone level."
#| warning: false
#| eval: false
#| echo: true
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess")
```

:::
::: {.column width="50%"}

```{r}
#| label: fig-airquality2
#| fig-cap: "Temperature and ozone level."
#| warning: false
library(ggplot2)
library(reticulate)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess")
```

:::

::::

::: {.notes}
[R](https://www.r-project.org/) code can be embeded and executed to produce tables and figures.
:::

## Python code

Requires you to load the `reticulate` library in R first.
::: {.column width="50%"}
Include [Python code and output](https://quarto.org/docs/computations/python.html) too

```{.python}
#| label: fig-polar
#| fig-cap: "A line plot on a polar axis."
#| warning: false
#| eval: false
#| echo: true
import numpy as np
import matplotlib.pyplot as plt
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
subplot_kw = {'projection': 'polar'}
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```

:::
::: {.column width="50%"}

```{python}
```{.python}
#| label: fig-polar2
#| fig-cap: "A line plot on a polar axis."
#| warning: false
#| eval: true
#| echo: true
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
subplot_kw = {'projection': 'polar'}
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```

:::
::::

::: {.notes}
As can [Python](https://www.python.org) code.
You can include [Python](https://www.python.org) code too
:::

## General code

There are lots of options for showing, hiding, highlighting code blocks.
There are lots of options for showing, hiding, highlighting [code
blocks](https://quarto.org/docs/presentations/revealjs/#code-blocks).

```{.python code-line-numbers="6-8"}
#| eval: true
#| echo: true
import numpy as np
import matplotlib.pyplot as plt
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```

## The Documentation is Good

Expand All @@ -209,6 +315,11 @@ The official documentation is really good.
There are an increasing number of [Extensions](https://quarto.org/docs/extensions/) for themes and other functionality
such as QR codes or confetti (press `c` whilst viewing these slides :wink: ).

+ [Shortcode/Filter](https://quarto.org/docs/extensions/listing-filters.html)
+ [Journal Articles](https://quarto.org/docs/extensions/listing-journals.html)
+ [Custom Formats](https://quarto.org/docs/extensions/listing-formats.html)
+ [**RevealJS**](https://quarto.org/docs/extensions/listing-revealjs.html)

:::
::: {.column width=50%}
{{< qrcode <https://ns-rse.github.io/quarto-revealjs-template> >}}
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
matplotlib
numpy
pandas

0 comments on commit cac0714

Please sign in to comment.