Reproducible CSAS Reports with .docx output
β οΈ Experimental Package: This package is under active development.
csasdown2 is a rewrite of csasdown that focuses on generating .docx output compliant with CSAS (Canadian Science Advisory Secretariat) formatting requirements, bilingual-language support, and accessibility standards.
- π Three document types: Research Documents, Fisheries Science Advisory Reports (FSARs), and Technical Reports
- π Reproducible workflow: Use R Markdown to go from data to document in a reproducible pipeline
- π¨ CSAS-compliant formatting: Produce Word .docx files that use the official styles
- π Bilingual support: English and French language configurations
- βΏ Accessibility: Built with accessibility standards in mind
- π Multi-file support: Organize large documents across multiple R Markdown files
- π Automatic numbering: Figures, tables, and cross-references handled automatically
- π Bibliography management: Integrated citation and reference formatting
Install the development version from GitHub:
# Using pak (recommended)
pak::pak("pbs-assess/csasdown2")
# Or using remotes
remotes::install_github("pbs-assess/csasdown2")Create a new Research Document in the current working directory:
csasdown2::draft("resdoc")Or specify an existing custom directory:
csasdown2::draft("resdoc", directory = "my-research-doc")csasdown2::draft("fsar")csasdown2::draft("techreport")Open index.Rmd and click the "Knit" button in RStudio, or run:
csasdown2::render()Your compiled .docx file will appear in the _book/ directory.
After running csasdown2::draft(), your project will contain:
-
index.RmdMain file containing YAML metadata (title, authors, dates, report numbers) and the abstract. This is where you configure document-wide settings. -
_bookdown.ymlConfiguration file specifying the order of R Markdown files to merge, output filename, and other bookdown settings. -
01-introduction.Rmd,02-methods.Rmd, etc. Chapter files for your document. Add, remove, or rename these as needed, updating_bookdown.ymlto match. -
99-references.RmdPlaceholder for the bibliography section (automatically populated from your .bib file).
-
figs/πΌοΈ Store external figures and images here. Reference them in your .Rmd files with relative paths. -
data/πΎ Store data files (.csv, .rds, etc.) used in your analysis. -
csl/π Citation Style Language files for formatting your bibliography. -
bib/π BibTeX files containing your references (e.g.,refs.bib).
_book/π¦ Generated directory containing your compiled .docx file and intermediate files.
- Research Documents in English and French
- Fisheries Science Advisory Reports in English and French
- Technical Reports in English and French
- Science Responses to come
Edit the YAML header in index.Rmd to customize:
- Title
- Author names and affiliations
- Report numbers and dates
- Language settings
- Abstract text
- Create a new
.Rmdfile (e.g.,03-results.Rmd) - Add it to
_bookdown.ymlin the desired order. For example:
rmd_files:
- "index.Rmd"
- "01-introduction.Rmd"
- "02-methods.Rmd"
- "03-results.Rmd"
- "99-references.Rmd"Use R code chunks with captions:
```{r my-figure, fig.cap="My caption."}
plot(year, abundance)
```Reference with Figure \@ref(fig:my-figure).
Include an existing figure:
```{r my-other-figure, fig.cap="My other caption."}
knitr::include_graphics("figs/myfigure.png", dpi = NA)
```Create a table:
```{r my-table}
flextable::flextable(data) |>
set_caption(caption = "My caption.")
```Reference with Table \@ref(tab:my-table).
Create an equation:
\begin{equation}
1 + 1 = 2
(\#eq:example-eq)
\end{equation}Reference with Equation \@ref(eq:example-eq).
Inline math:
The symbol $\beta$ represents...Include citations:
A statement [e.g., @Smith2024; @Johnson2025]. @Johnson2025 said this.Turns into:
A statement (e.g., Smith et al. 2024, Johnson et al. 2025). Johnson et al. (2025) said this.
With entries in the bibliography at the end.
Start an appendix:
# APPENDIX `r new_appendix()`. ADDITIONAL ANALYSES {#app:additional}Reference with Appendix \@ref(app:additional)
csasdown2 uses a multi-stage rendering pipeline:
- bookdown merges multiple R Markdown files
- officedown converts to Word with CSAS styles
- officer post-processes the document (injects frontmatter, replaces bookmarks, assembles final document)
Bug reports and feature requests are welcome on the GitHub issue tracker.
This package is licensed under the MIT License.
csasdown2 builds on the original csasdown package and the excellent bookdown, officedown, and officer packages.
