Quarto Extension
This is a Quarto extension that allows to highlight text in a document for various formats: HTML, LaTeX, Typst, Docx, PowerPoint, Reveal.js, and Beamer.
This will install the extension under the _extensions subdirectory.
If you’re using version control, you will want to check in this directory.
To use the extension, add the following to your document’s front matter:
Then you can use the span syntax markup to highlight text in your document.
The extension supports both British and American English spelling for colour attributes:
You can use abbreviated attribute names (v1.1.1):
Supported attributes:
ink, fg, colour, or colorpaper, bg, bg-colour, or bg-colorbc, border-colour, or border-colorbs or border-style (values: solid, dashed, dotted, double; defaults to solid)Red textRed text
Blue textBlue text
Green text (ink alias)Green text (ink alias)
Red backgroundRed background
Blue backgroundBlue background
Yellow background (paper alias)Yellow background (paper alias)
White text, Red backgroundWhite text, Red background
White text, Blue backgroundWhite text, Blue background
Black text, Orange background (ink/paper aliases)Black text, Orange background (ink/paper aliases)
Text with solid borderText with solid border
Text with dashed borderText with dashed border
Text with dotted borderText with dotted border
Text with double borderText with double border
Red border, yellow backgroundRed border, yellow background
Blue border, white on redBlue border, white on red
text with a linktext with a link
Define colours once in _brand.yml and reference them throughout your documents (v1.1.0):
Reference these colours directly by name:
Note
The old brand-color. prefix syntax (e.g., colour="brand-color.red") is deprecated but still supported (v1.4.0). You’ll see a warning when using it. Use the colour name directly instead: colour="red".
With Quarto CLI ≥1.7.28, you can define different colours for light and dark themes (v1.2.0):
Option 1: Define themes in document front matter:
Option 2: Use external _brand.yml file:
Then reference theme-aware colours:
Note
Only HTML formats support dynamic light/dark mode switching. Other formats will use the light mode colours if available, or fall back to dark mode colours otherwise, unless specified otherwise.
Using colours defined in the brand section of this document’s front matter:
Light: White/Red | Dark: Red/WhiteLight: White/Red | Dark: Red/White
The old brand-color. prefix syntax still works but shows a deprecation warning:
Using deprecated syntaxUsing deprecated syntax
Note
Use the colour name directly without the brand-color. prefix (e.g., fg="fg" instead of colour="brand-color.fg").
You can highlight entire blocks using div syntax.
This is a block-level highlighted section. It can contain multiple paragraphs, lists, and other block elements.
All content within this div is highlighted.
This is a block-level highlighted section. It can contain multiple paragraphs, lists, and other block elements.
All content within this div is highlighted.
This block has a red solid border with a light yellow background.
This block has a red solid border with a light yellow background.
This block has a blue dashed border with a light grey background.
This block has a blue dashed border with a light grey background.
This block has a green dotted border without background.
This block has a green dotted border without background.
This block uses ink/paper aliases with white text on purple background.
This block uses ink/paper aliases with white text on purple background.
This block uses brand colours that adapt to light/dark themes.
In light mode, this appears as white text on red background.
In dark mode, this appears as red text on white background.
This block uses brand colours that adapt to light/dark themes.
In light mode, this appears as white text on red background.
In dark mode, this appears as red text on white background.
The LaTeX \colorbox command does not support line wrapping for highlighted text with background colours. Long highlighted text may overflow or break awkwardly.
For inline highlighting: Use the par=true attribute to add \parbox{\linewidth} (XeLaTeX and PDFLaTeX only):
For block-level highlighting: Automatic line wrapping is enabled for all engines. Block divs automatically use \parbox for non-LuaLaTeX engines.
Best solution: Use LuaLaTeX as your PDF engine for proper line wrapping with the lua-ul package:
Note
LuaLaTeX is the default PDF engine in Quarto CLI ≥1.8.25.
Example without workaround (inline):
LaTeX \colorbox command does not support wrapping/line breaks in the text to be highlighted. This means that the above example will not work well in LaTeX output when using XeLaTeX or PDFLaTeX engines.LaTeX \colorbox command does not support wrapping/line breaks in the text to be highlighted. This means that the above example will not work well in LaTeX output when using XeLaTeX or PDFLaTeX engines.
Example with par=true (inline):
LaTeX \colorbox command does not support wrapping/line breaks in the text to be highlighted. This means that the above example will not work well in LaTeX output when using XeLaTeX or PDFLaTeX engines.LaTeX \colorbox command does not support wrapping/line breaks in the text to be highlighted. This means that the above example will not work well in LaTeX output when using XeLaTeX or PDFLaTeX engines.
Example with block-level highlighting:
LaTeX \colorbox command does not support wrapping/line breaks in the text to be highlighted.
Block divs automatically handle line wrapping for all PDF engines, including XeLaTeX and PDFLaTeX.
LaTeX \colorbox command does not support wrapping/line breaks in the text to be highlighted.
Block divs automatically handle line wrapping for all PDF engines, including XeLaTeX and PDFLaTeX.
Links are not supported in highlighted text in PowerPoint output.
Border colour is not supported in PowerPoint output.
Links are not supported in highlighted text in Word output.