Template for contribution to Computo

Example based on the quarto system

Creative Commons BY License ISSN 2824-7795

This document provides a template based on the quarto system for contributions to Computo, using the jounral extension and the knitr kernel (R user).

Authors
Affiliations
Published

April 21, 2024

Modified

April 21, 2024

Keywords

key1, key2, key3

Status

draft

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.

1 Introduction

1.1 About this document

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.

1.2 Advice for writting your manuscript

First make sure that you are able to build your manuscript as a regular notebook on your system.

2 Formatting

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

2.1 Basic markdown formatting

Bold text or italic

  • This is a list
  • With more elements
  • It isn’t numbered.

But we can also do a numbered list

  1. This is my first item
  2. This is my second item
  3. This is my third item

2.2 Mathematics

2.2.1 Mathematical formulae

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}

2.2.2 Theorems and other amsthem-like environments

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.

2.3 Code

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)).

2.3.1 R

R code (R Core Team 2020) chunks may be embedded as follows:

Hide/Show the code
x <- rnorm(10)

2.3.2 Python

---
title: "My Document"
author "Jane Doe"
jupyter: python3
---
Hide/Show the code
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
ax.plot(np.arange(10))

2.4 Figures

Plots can be generated as follows:

Hide/Show the code
library("ggplot2")
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  geom_smooth()
p

It is also possible to create figures from static images:

2.5 Tables

Tables (with label: @tbl-mylabel renders Table 1) can be generated with markdown as follows

Table 1: my table caption
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:

Hide/Show the code
knitr::kable(summary(cars), caption = "Table caption.")
Table caption.
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

2.6 Handling references

2.6.1 Bibliographic references

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).

2.6.2 Other cross-references

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.

For more information

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).

References

Computo Team. 2021. “Computo: Reproducible Computational/Algorithmic Contributions in Statistics and Machine Learning.” Computo.
Perez, Fernando, Brian E Granger, and John D Hunter. 2011. “Python: An Ecosystem for Scientific Computing.” Computing in Science
& Engineering
13 (2): 13–21.
R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Ushey, Kevin, JJ Allaire, and Yuan Tang. 2020. Reticulate: Interface to Python. https://github.com/rstudio/reticulate.

Session information

Hide/Show the code
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

Footnotes

  1. We use katex for this purpose.↩︎

Reuse

Citation

BibTeX citation:
@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.}
}
For attribution, please cite this work as:
Doe, Jane, and John Doe. 2024. “Template for Contribution to Computo.” Computo, April. https://doi.org/xxxx.