Hide/Show the code
<- rnorm(10) x
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur posuere vestibulum facilisis. Aenean pretium orci augue, quis lobortis libero accumsan eu. Nam mollis lorem sit amet pellentesque ullamcorper. Curabitur lobortis libero eget malesuada vestibulum. Nam nec nibh massa. Pellentesque porttitor cursus tellus. Mauris urna erat, rhoncus sed faucibus sit amet, venenatis eu ipsum.
This document provides a template based on the quarto system for contributions to Computo Computo Team (2021). We show how Python
(Perez, Granger, and Hunter 2011) or R
(R Core Team 2020) code can be included.
First make sure that you are able to build your manuscript as a regular notebook on your system.
This section covers basic formatting guidelines. Quarto is a versatile formatting system for authoring HTML based on markdown, integrating LaTeX and various code block interpreted either via Jupyter or Knitr (and thus deal with Python, R and many other langages). It relies on the Pandoc Markdown markup language.
To render/compile a document, run quarto render
. A document will be generated that includes both content as well as the output of any embedded code chunks within the document:
quarto render content.qmd # will render to html
Bold text or italic
But we can also do a numbered list
LaTeX code is natively supported1, which makes it possible to use mathematical formulae:
will render
f(x_1, \dots, x_n; \mu, \sigma^2) = \frac{1}{\sigma \sqrt{2\pi}} \exp{\left(- \frac{1}{2\sigma^2}\sum_{i=1}^n(x_i - \mu)^2\right)}
It is also posible to cross-reference an equation, see Equation 1:
\begin{aligned} D_{x_N} & = \frac12 \left[\begin{array}{cc} x_L^\top & x_N^\top \end{array}\right] \, \left[\begin{array}{cc} L_L & B \\ B^\top & L_N \end{array}\right] \, \left[\begin{array}{c} x_L \\ x_N \end{array}\right] \\ & = \frac12 (x_L^\top L_L x_L + 2 x_N^\top B^\top x_L + x_N^\top L_N x_N), \end{aligned} \tag{1}
Quarto includes a nice support for theorems, with predefined prefix labels for theorems, lemmas, proposition, etc. see this page. Here is a simple example:
Theorem 1 (Strong law of large numbers) The sample average converges almost surely to the expected value:
\overline{X}_n\ \xrightarrow{\text{a.s.}}\ \mu \qquad\textrm{when}\ n \to \infty.
See Theorem 1.
Quarto uses either Jupyter or knitr to render code chunks. This can be triggered in the yaml header, e.g., for Jupyter (should be installed on your computer) use
---
title: "My Document"
author "Jane Doe"
jupyter: python3
---
For knitr (R + knitr must be installed on your computer)
---
title: "My Document"
author "Jane Doe"
---
You can use Jupyter for Python code and more. And R + KnitR for if you want to mix R with Python (via the package reticulate Ushey, Allaire, and Tang (2020)).
R
code (R Core Team 2020) chunks may be embedded as follows:
<- rnorm(10) x
---
title: "My Document"
author "Jane Doe"
jupyter: python3
---
import matplotlib.pyplot as plt
import numpy as np
= plt.subplots()
fig, ax 10)) ax.plot(np.arange(
Plots can be generated as follows:
library("ggplot2")
<- ggplot(mpg, aes(displ, hwy)) +
p geom_point() +
geom_smooth()
p
It is also possible to create figures from static images:
Tables (with label: @tbl-mylabel
renders Table 1) can be generated with markdown as follows
Tables | Are | Cool |
---|---|---|
col 1 is | left-aligned | $1600 |
col 2 is | centered | $12 |
col 3 is | right-aligned | $1 |
Table can also be generated by some code, for instance with knitr here:
::kable(summary(cars), caption = "Table caption.") knitr
speed | dist | |
---|---|---|
Min. : 4.0 | Min. : 2.00 | |
1st Qu.:12.0 | 1st Qu.: 26.00 | |
Median :15.0 | Median : 36.00 | |
Mean :15.4 | Mean : 42.98 | |
3rd Qu.:19.0 | 3rd Qu.: 56.00 | |
Max. :25.0 | Max. :120.00 |
References are displayed as footnotes using BibTeX, e.g. [@computo]
will be displayed as (Computo Team 2021), where computo
is the bibtex key for this specific entry. The bibliographic information is automatically retrieved from the .bib
file specified in the header of this document (here: references.bib
).
As already (partially) seen, Quarto includes a mecanism similar to the bibliographic references for sections, equations, theorems, figures, lists, etc. Have a look at this page.
Check our mock version of the t-SNE paper for a full and advanced example using the Jupyter kernel.
The template available in the Computo Quarto extension uses advanced features and the KnitR kernel (interactive plots and pseudocode).
sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS
Matrix products: default
BLAS/LAPACK: /home/runner/micromamba-root/envs/computorbuild/lib/libopenblasp-r0.3.27.so; LAPACK version 3.12.0
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.5.0
loaded via a namespace (and not attached):
[1] Matrix_1.6-5 gtable_0.3.4 jsonlite_1.8.8 dplyr_1.1.4
[5] compiler_4.3.3 tidyselect_1.2.0 Rcpp_1.0.12 splines_4.3.3
[9] scales_1.3.0 png_0.1-8 yaml_2.3.8 fastmap_1.1.1
[13] reticulate_1.36.0 lattice_0.22-6 R6_2.5.1 labeling_0.4.3
[17] generics_0.1.3 knitr_1.46 htmlwidgets_1.6.4 tibble_3.2.1
[21] munsell_0.5.1 pillar_1.9.0 rlang_1.1.3 utf8_1.2.4
[25] xfun_0.43 cli_3.6.2 withr_3.0.0 magrittr_2.0.3
[29] mgcv_1.9-1 digest_0.6.35 grid_4.3.3 lifecycle_1.0.4
[33] nlme_3.1-164 vctrs_0.6.5 evaluate_0.23 glue_1.7.0
[37] farver_2.1.1 fansi_1.0.6 colorspace_2.1-0 rmarkdown_2.26
[41] tools_4.3.3 pkgconfig_2.0.3 htmltools_0.5.8.1
@article{doe2024,
author = {Doe, Jane and Doe, John},
publisher = {Société Française de Statistique},
title = {Template for Contribution to {Computo}},
journal = {Computo},
date = {2024-04-21},
url = {https://computo.sfds.asso.fr/template-computo-quarto},
doi = {xxxx},
issn = {2824-7795},
langid = {en},
abstract = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur posuere vestibulum facilisis. Aenean pretium orci augue,
quis lobortis libero accumsan eu. Nam mollis lorem sit amet
pellentesque ullamcorper. Curabitur lobortis libero eget malesuada
vestibulum. Nam nec nibh massa. Pellentesque porttitor cursus
tellus. Mauris urna erat, rhoncus sed faucibus sit amet, venenatis
eu ipsum.}
}