Dr. Ajay Kumar Koli \(\cdot\) 2nd SARA Bootcamp
Create a new GitHub repository (repo) for your book project.
HTTPS LinkCreate a file named _quarto.yml. It will contain the configuration settings for your thesis.
_quarto.yml:Create the content files for your chapters (e.g., index.qmd, chapter1.qmd, chapter2.qmd).
Write your content using Markdown syntax. You can also include code, figures, and other elements.
Example index.qmd
Markdown is a lightweight markup language for creating formatted text using a plain-text editor. Developed by John Gruber in 2004.
| Markdown Syntax | Output |
|---|---|
| normal | |
| italics | |
| bold | |
| bold italics |
Source: Quarto guide
| Markdown Syntax | Output |
|---|---|
| superscript2 | |
| subscript2 | |
verbatim code |
Source: Quarto guide
| Markdown Syntax | Output |
|---|---|
Header 1 |
|
Header 2 |
|
Header 3 |
|
Header 4 |
|
Header 5 |
|
Header 6 |
| Markdown syntax | Output |
|---|---|
| https://saraedu.netlify.app/ |
| Markdown syntax | Output |
|---|---|
| SARA |
If image is saved in your computer,

If image is taken from the internet,

| Markdown Syntax | Output |
|---|---|
|
| Markdown Syntax | Output |
|---|---|
|
| Markdown Syntax | Output |
|---|---|
|
| Markdown Syntax | Output |
|---|---|
continues after
|
| Markdown Syntax | Output |
|---|---|
|
Use
$delimiters for inline math.
Use
$$delimiters for display math.
`{r} `
Input: The mean age of the participants is `{r} mean(age)`.
Output: The mean age of the participants is 3.
Type this in your .qmd file:
Output:
| Name | Age | City |
|---|---|---|
| Ajay | 25 | Delhi |
| Kiram | 30 | Sonipat |
Note
kable() is the go-to function for simple, clean tables in R.
```{r}
library(kableExtra)
kable(head(mtcars), caption = "Styled Table") |>
kable_styling(
bootstrap_options = "striped",
full_width = FALSE
)
```striped β alternating row colorshover β highlight on mouse hovercondensed β compact layoutExercise 1
Create a table showing 5 rows of any dataset of your choice.
β
Add a caption
β
Make it striped
β
Set full_width = FALSE
Tip
Always add fig-alt for accessibility β itβs good research practice!
```{r}
#| label: fig-cars
#| fig-cap: "Relationship between Speed and Distance"
plot(cars$speed, cars$dist,
xlab = "Speed", ylab = "Distance")
```label β must start with fig- for cross-referencingfig-cap β your figure captionExercise 2
ggplot figure using the iris datasetfig-capIn a thesis, you write:
βAs shown in Figure 3.2, the results indicateβ¦β
Quarto handles the numbering automatically - you just use labels!
In your code chunk:
In your text:
Important Rule
Figure labels must start with fig-
Table labels must start with tbl-
In your code chunk:
In your text:
Quarto automatically converts @tbl-summary \(\rightarrow\) Table 1
Exercise 3
tbl- labelfig- label@Exercise 4
Using the built-in airquality dataset:
Temp column_quarto.ymlexecute:
echo: false # hide code in final thesis
warning: false # hide warnings
message: false # hide messages
format:
html:
fig-width: 7
fig-height: 5Tip
Set echo: false globally so your thesis shows only output, not code.
| Option | Purpose |
|---|---|
echo: false |
Hide code, show output |
eval: false |
Show code, donβt run it |
fig-width: 7 |
Set figure width |
fig-height: 5 |
Set figure height |
tbl-cap |
Add table caption |
fig-cap |
Add figure caption |
In a Quarto thesis, everything is connected
Your data, code, and writing live in one place.
When data changes β tables and figures update automatically.
Note
That is Reproducible Research in action! π
Think of Zotero as a smart bookshelf for your research.
Note
Zotero is free and open source β perfect for researchers!
| Without Zotero | With Zotero + Quarto |
|---|---|
| Type references manually | References inserted automatically |
| Format APA by hand | Style applied instantly |
| Risk of typos | Always accurate |
| Hard to update | One click to refresh |
| Separate reference list | Auto-generated bibliography |
Tip
The browser extension lets you save a paper in one click while browsing Google Scholar or any journal website.
Three easy ways:
This plugin exports your library in a format Quarto understands.
.xpi file.xpi file.bibreferences.bib inside your Quarto project folderWarning
Save the .bib file in the same folder as your _quarto.yml
_quarto.ymlproject:
type: book
book:
title: "My Thesis"
author: "Your Name"
bibliography: references.bib
csl: apa.csl # citation style (optional)
format:
html:
theme: cosmo
pdf:
documentclass: scrreprtNote
bibliography: tells Quarto where your references file lives.
If you only want bibliography in one .qmd file:
Every reference in your .bib file has a citation key like:
@peng2011reproducible
@wickham2016ggplot2
@gandrud2016reproducible
| What you want | Syntax | Output |
|---|---|---|
| Author (Year) | @peng2011 |
Peng (2011) |
| (Author, Year) | [@peng2011] |
(Peng, 2011) |
| Multiple sources | [@peng2011; @knuth1984] |
(Peng, 2011; Knuth, 1984) |
| Page number | [@peng2011, p. 45] |
(Peng, 2011, p. 45) |
| Suppress author | [-@peng2011] |
(2011) |
Reproducible research has been defined as sharing data and
code alongside findings [@peng2011].
As @buckheit1995 argued, the actual scholarship is the
complete software environment that produced the results.
Several studies [@peng2011; @gandrud2016; @knuth1984]
have emphasized the importance of literate programming.At the end of your document, Quarto automatically generates:
## References
Peng, R. D. (2011). Reproducible research in computational
science. *Science*, 334(6060), 1226β1227.
Buckheit, J., & Donoho, D. (1995). WaveLab and reproducible
research. *Wavelets and Statistics*, 55β81.
Tip
No need to type the reference list β Quarto does it for you! π
Exercise 1
references.bib to your project folder_quarto.ymlCSL = Citation Style Language
It controls how your citations look:
.csl file_quarto.yml:| Style | File Name | Used In |
|---|---|---|
| APA 7th | apa.csl |
Social sciences |
| Chicago | chicago-author-date.csl |
Humanities |
| Vancouver | vancouver.csl |
Medicine |
| Harvard | harvard-cite-them-right.csl |
General |
| IEEE | ieee.csl |
Engineering |
Tip
Check with your university which style they require for your thesis!
Exercise 2
csl: apa.csl to your _quarto.ymlRStudioβs Visual Editor connects directly to Zotero!
.qmd file in RStudioNote
No need to remember citation keys β RStudio finds them for you!
Insert β Citation
βββββββββββββββββββββββββββββββββββ
β π Search: reproducible β
β β
β π My Library β
β βββ Peng 2011 β
β βββ Buckheit 1995 β
β βββ Gandrud 2016 β
β β
β [ Insert ] [ Cancel ] β
βββββββββββββββββββββββββββββββββββ
Make sure RStudio can find your Zotero:
In Source mode, type @ and start typing:
RStudio will autocomplete from your .bib file:
@peng2011reproducible β select this!
@penman2019...
Tip
This works like autocomplete in coding β fast and accurate!
Exercise 3
.qmd file in Visual mode.bib File β A Closer Look.bib File Looks Like@article{peng2011reproducible,
title = {Reproducible Research in Computational Science},
author = {Peng, Roger D},
journal = {Science},
volume = {334},
number = {6060},
pages = {1226--1227},
year = {2011}
}
@book{gandrud2016reproducible,
title = {Reproducible Research with R and RStudio},
author = {Gandrud, Christopher},
publisher = {CRC Press},
year = {2016}
}@article{peng2011reproducible,
^^^^^^^^^^^^^^^^^^^^
This is the citation key you use in text
Convention: AuthorYearKeyword
e.g., peng2011reproducible
wickham2016ggplot
gandrud2016reproducible
Note
Better BibTeX generates these keys automatically for you!
| Problem | Fix |
|---|---|
| Citation not found | Check the key matches exactly in .bib |
| Bibliography not showing | Add bibliography: references.bib to YAML |
| Wrong style | Check .csl file name and path |
.bib not updating |
Re-export from Zotero with Keep Updated |
| RStudio canβt find Zotero | Check Global Options β Citations |
references.bib is in the project folderbibliography: references.bib is in _quarto.yml.bib file.csl file is downloaded and path is correctNever format a reference manually again!
Zotero + Quarto means:
Reproducibility
Iterative Workflow
Customization and Flexibility
Multi-Format Output
Collaboration
Reduced Formatting Issues
Integration with Other Tools
Documentation and Support
