<- '## "stx2A; shiga-like toxin II A subunit encoded by bacteriophage BP-933W; K11006 shiga toxin subunit A" '
a a
[1] "## \"stx2A; shiga-like toxin II A subunit encoded by bacteriophage BP-933W; K11006 shiga toxin subunit A\" "
Below are some tips and tricks that I needed to use alongside the regular Quarto settings, which were unfortunately not enough to fully format my thesis just like how I wanted. I had to scour the internet and stackoverflow alongside some latex documentation, and I hope this will help someone one day. Or else it serves as a nice little documentation for future usage.
As of 2024, there are support packages for acronyms and glossaries in Quarto. - https://rchaput.github.io/acronyms/ - https://debruine.github.io/glossary/index.html
However I still use the acronyms package in LaTeX, as it seems to still be more powerful. Current issue is that I can’t use it in the caption of a longtblr (tabularrray).
How to add only part of figure caption in list of figures but keep the full description in the caption.
Based on this discussion which leads to the usage of the short-captions pandoc filter.
First add the filter to the yaml header:
filters:
- "pandoc-filters/short-captions.lua"
[**Bold caption.** Additional caption. End with a citation. [@citation]](figures/figure.png){#fig:label short-caption="**Short bold caption**."} !
Cross-reference in-line with this syntax : @fig-label
Based on this thread, or this one from stackoverflow, you can run this LaTeX code to do so :
\begin{figure}
\includegraphics{figure.jpg}
\caption[\textbf{Bold caption.}]
\textbf{Figure or table description. (\cite{Meza-Meza.2020}) or Adapted from \textcite{Author}}
{\label{fig-label}
\end{figure}
Note that I return to a new line to make it easier to read.
Write \listoffigures
to generate the list of figures.
Then you can crossreference the figure using a LaTeX command : **(Figure \ref{label})**
I originally used this method because I didn’t know about the pandoc filters. I’d have to say the pandoc way is easier to write, and you can have a miniature image in source or visual mode inside R Studio.
One minor hiccup of the latex way is that if you ever switch to the source pane, any bolded crossreference with latex syntax will be undone. Such as : From **(Figure \ref{fig:vitd3})**
to **(Figure** \ref{fig:vitd3})
when going to source and back. This is quite annoying. So I’d rather use pandoc from now.
Update : The cleveref package Section 4.1 solves this problem.
Unknowingly, the figure attribute fig-scap solves the problem.
{#fig-label fig-scap="A short caption"}
Instead of using (**Figure \ref{figure:stuff}**)
, use \cref{figure:stuff}
which will automatically put “Figure” or “Table” or something else as appropriate.
To add automatic bold, add to the preambule :
header-includes:
- \usepackage[capitalise,noabbrev, nameinlink]{cleveref} # Allows \cref{} to cite latex table as "Table 3"
# Specify which cross-reference should automatically be bolded : Tables and Figures
# Use \cref{} ; For some reason this only works with this exact disposition :
# Only #1, nameinlink and each of the reference specified. namelink + #1#2#3 would give an error.
- \crefdefaultlabelformat{#2\textbf{#1}#3} # <-- Only #1 in \textbf
- \crefname{table}{\textbf{Table}}{\textbf{Tables}}
- \Crefname{table}{\textbf{Table}}{\textbf{Tables}}
- \crefname{figure}{\textbf{Figure}}{\textbf{Figures}}
- \Crefname{figure}{\textbf{Figure}}{\textbf{Figures}}
The parameter nameinlink
could be removed, but it allows the link to span both the number and the cross-referenced material (Table + #) and not just the number, which I find more practical.
The generated pdf document has a convenient bookmark function for ease of navigation. The bookmark automatically includes pandoc headers, except your table of content.
Add the bookmark package to include headers, and then use the following command:
header-includes:
- \usepackage{setspace} # Example of another package used. This syntax will not work with only one package.
- \usepackage{bookmark}
% Add the command just before the toc.
\pdfbookmark[section]{\contentsname}{toc}
% Next command is to rename the table of content
\renewcommand{\contentsname}{Table des matières}
\tableofcontents{}
\newpage
Well that’s simple:
Move
\label{fig: hasse}
after\caption{Hasse diagram}
since\caption
has to come before\label
. This applies to figures and tables in general. I would not use spaces in label names. Also note Gonzalos comment regarding\centering
.
Instead of the center environment you could use the command right after \begin{figure}[htbp]; the environment adds extra vertical space which (in most cases) is undesired – Gonzalo Medina
Use \renewcommand{\thesubfigure}{\Alph{subfigure}}
in your preamble.
If you want something like Figure 1, Figure 2 instead of Figure 1.1, Figure 1.2, you need to use the following latex command :
\counterwithout{figure}{chapter}
- \counterwithout{figure}{section} -
This is working for me, using scrreport as the document class (KOMA class).
Changing the numbering of (e.g.) figures involves two modifications:
Redefining whether or not the figure counter will be reset whenever the chapter/section counter is incremented;
Redefining the “appearance” of the figure counter (), i.e., removing (or adding) the chapter/section prefix.
\counterwithout{somecounter}{anothercounter}
\counterwithout{somecounter}{anothercounter}
removes the link between somecounter
and anothercounter
so that they are independent. For any pair of counters, you can switch between using \counterwithout
and \counterwithin
, as the following example shows for the example
and section
counters—you can open this example in Overleaf using the link provided below the code.
You need to combine .unlisted with .unnumbered to achieve this, as stated in Pandoc documentation.
(I have looked inside the Pandoc documentation however and I have no idea where that is stated).
Also, I discovered it was literally marked in the Quarto documentation itself !
# Abstract {.unnumbered .unlisted}
# Acknowledgements {.unnumbered .unlisted}
# Chapter 1
Can be used only in the preamble:
If you compile your bibliography with biber, simply add:
header-includes:
# Define a command to remove the "note" field from the bibliography
- \AtEveryBibitem{\clearfield{note}}
If for some unknown reason, you’re trying to generate your bibliography and Quarto hits you with
generating bibliography\Users\Minh-Anh\AppData\Local\Temp\par-4d696e682d416e68\cache-5e43119d746c745befc6eda076997d4ff7d8b07a\19c9b262.pm line 25.
Couldn't load any math lib(s), not even fallback to Calc.pm at C: etc.
Go to the specified file path and delete the folders. What a headache.
Also, biber --cache
shows you where it is (and if it’s bugged, you’ll be greeted with this awesome bug error).
Modern way of making tables, combining automatic column resizing from tabularx, longtable and working captions (ltablesx has a caption error where shortcaptions doesn’t seem to work).
\begingroup
\small
% Insert table code
\endgroup
NewTblrTheme{tinyfr}{\SetTblrStyle{head}{font=\small}
\DefTblrTemplate{caption-tag}{default}{\textbf{Table\hspace{0.25em}\thetable}}
\DefTblrTemplate{caption-sep}{default}{\enskip--\enskip}
\DefTblrTemplate{contfoot-text}{default}{\scriptsize\itshape\color{gray} (Suite à la page suivante)}
\DefTblrTemplate{conthead-text}{default}{(Suite)}
}%\begingroup
%\small
\begin{landscape}
\begin{longtblr}[
theme = tinyfr,\textbf{Opinion des méta-analyses sur les études observationnelles concernant l'existence d'une relation entre la vitamine D et la COVID-19.}},
caption = {
entry = {Opinion des méta-analyses sur les études observationnelles concernant l'existence d'une relation entre la vitamine D et la COVID-19.},
label = {tblr:meta-analyses-obs}
]{
colspec = {lXX},\small},
cells= {font = \bfseries \small, halign=c},
row{1} = {font=
rowhead = 1
}
\toprule
\\
Étude & Design et taille de l'échantillon & Opinion \midrule
Long lines in the output will not be (hard-)wrapped automatically unless you break them manually.
<- '## "stx2A; shiga-like toxin II A subunit encoded by bacteriophage BP-933W; K11006 shiga toxin subunit A" '
a a
[1] "## \"stx2A; shiga-like toxin II A subunit encoded by bacteriophage BP-933W; K11006 shiga toxin subunit A\" "
Perhaps you see it is wrapped in RStudio, but that is because <pre>
has the CSS attribute white-space: pre-wrap;
. For LaTeX output, the output is in the verbatim
environment by default, which will not wrap long lines (everything is shown as is).
You can redefine the output hook function so that you can instruct some chunks to hard-wrap their output lines, e.g.
library(knitr)
= knit_hooks$get('output')
hook_output $set(output = function(x, options) {
knit_hooks# this hook is used only when the linewidth option is not NULL
if (!is.null(n <- options$linewidth)) {
= xfun::split_lines(x)
x # any lines wider than n should be wrapped
if (any(nchar(x) > n)) x = strwrap(x, width = n)
= paste(x, collapse = '\n')
x
}hook_output(x, options)
})
Now see the output of a
(note linewidth
is not a default knitr option):
a
[1] "## \"stx2A; shiga-like toxin II A subunit encoded by
bacteriophage BP-933W; K11006 shiga toxin subunit A\" "
Just include double brackets around your {{organization}} and citeproc will format correctly.
Citation of author : \autocite{{D’Ecclesiis.2022}}
@article{IOM.2011.org,
year = {2011},
title = {{Dietary Reference Intakes for Calcium and Vitamin D}},
author = {{Institute of Medicine}},
journal = {The National Academies Press},
doi = {10.17226/13050},
pages = {1115},
keywords = {},
}
@article{D’Ecclesiis.2022,
year = {2022},
rating = {5},
title = {{Vitamin D and SARS-CoV2 infection, severity and mortality: A systematic review and meta-analysis}},
author = {D’Ecclesiis}
journal = {PLoS ONE},
doi = {10.1371/journal.pone.0268396},
pmid = {35793346},
pmcid = {PMC9258852},
pages = {e0268396},
number = {7},
volume = {17}, }
This is actually the intended, default behavior of biblatex-chicago package:
The Manual doesn’t clarify how to treat multiple works by the same author, in one or more of which their name doesn’t appear on the title page. By default, biblatex-chicago will, after the first appearance in the reference list, replace identical authors with the 3-em dash, regardless of any authortype field that may be present. If you want to distinguish between works certainly written by and works merely ascribed to a given author, then you can use the dashed option in the options field of individual entries, and possibly also a sortname, to get the results you want.
Example when using biblatex : remove doi, isbn and 3 em dash for repeated authors
header-includes:\usepackage[authordate, backend=biber, doi=false, isbn=false, dashed=false]{biblatex-chicago} -