I am rendering a document in Quarto to pdf and want all the call outs (warning, notes, etc) to be in black and white. I've been trying to create a .sty-file with the following code:
\usepackage[most]{tcolorbox}
\renewtcolorbox{callout}[2][]{%
enhanced,
breakable,
sharp corners,
colback=white,
colframe=black,
coltitle=black,
colbacktitle=white,
boxrule=0.5pt,
fonttitle=\bfseries,
title=#2,
#1
}
\tcbset{
quartocalloutdefault/.style={},
quartocalloutnote/.style={},
quartocalloutwarning/.style={},
quartocallouttip/.style={},
quartocalloutimportant/.style={},
quartocalloutcaution/.style={},
quartocalloutseealso/.style={}
}
And added this to the yaml-file:
format:
pdf:
include-in-header:
- text: |
\usepackage{fvextra}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}
\usepackage[font={it,small}]{caption}
- file: callout-style.sty
Any tips on how to make it work? The index.qmd, callout-style.sty and _quarto.yml is in the same folder. Other .qmd-files being rendered are in subfolders.
Although your approach seems reasonable, it can't work because the LaTeX markup for the callouts is injected via Lua filters. A closer examination of the callout attributes shows that the colors are stored in the variables
local callout_attrs = {
note = {
...
latex_color = "quarto-callout-note-color",
latex_frame_color = "quarto-callout-note-color-frame",
...
},
warning = {
...
latex_color = "quarto-callout-warning-color",
latex_frame_color = "quarto-callout-warning-color-frame",
...
},
...
}
Hence, if you want to change the color of the header, background/lines and icons to black and white you can modify these variables. One approach for doing this is to use LaTex Includes (you may want to change the colors depending on your needs):
---
title: "Custom callout color test"
format:
pdf:
include-before-body:
text: |
%%% Define custom colors
% Note
\definecolor{quarto-callout-note-color}{rgb}{0.0, 0.0, 0.0}
\definecolor{quarto-callout-note-color-frame}{HTML}{000000}
% Warning
\definecolor{quarto-callout-warning-color}{rgb}{0.0, 0.0, 0.0}
\definecolor{quarto-callout-warning-color-frame}{HTML}{000000}
---
::: {.callout-note}
Note that there are five types of callouts, including:
`note`, `warning`, `important`, `tip`, and `caution`.
:::
::: {.callout-warning}
Callouts provide a simple way to attract attention, for example, to this warning.
:::
The above example is a bit "sloppy" because include-before-body
inserts the definitions in the corresponding .tex file after the \begin{document}
, what is maybe not the most desired structure of the file (notice that include-in-header
does not work because it inserts the custom definitions before the injections made by Lua). Another possibility is to use Template Partials. Looking at template.tex
shows that e.g. before-title.tex
can be used as a storage for the definitions. It is currently empty, so we can just insert the definitions and include it in the main file, it yields the same result as above:
before-title.tex
%%% Define custom colors
% Note
\definecolor{quarto-callout-note-color}{rgb}{0.0, 0.0, 0.0}
\definecolor{quarto-callout-note-color-frame}{HTML}{000000}
% Warning
\definecolor{quarto-callout-warning-color}{rgb}{0.0, 0.0, 0.0}
\definecolor{quarto-callout-warning-color-frame}{HTML}{000000}
index.qmd
---
title: "Custom callout color test"
format:
pdf:
template-partials:
- before-title.tex
documentclass: scrartcl
classoption:
- DIV=11
- numbers=noendperiod
papersize: letter
---
::: {.callout-note}
Note that there are five types of callouts, including:
`note`, `warning`, `important`, `tip`, and `caution`.
:::
::: {.callout-warning}
Callouts provide a simple way to attract attention, for example, to this warning.
:::