Pandoc lua-filter collection that creates a box around text.
There are two options:
- pandoc-div-box, that uses the pandoc markdown div
:::
section. See sample_div.pdf or - pandoc-callout-box, that uses the callouts from obsidian with
> [!info]
. See sample_callout.pdf.
Download either pandoc-div-box.lua or pandoc-callout-box.lua and
Run filter e.g. with pandoc your_markdown.md --lua-filter=pandoc-div-box.lua --output=output.pdf
or
pandoc your_markdown.md --lua-filter=pandoc-callout-box.lua --output=output.pdf
respectively.
Wrap three colons :::
with the {.box}
attribute around some text. box
creates a box around it with the default border and fill color of tcolorbox
(see sample_div.pdf).
:::{.box}
Lorem ipsum dolor sit amet
:::
Resulting in

Run this filter e.g. with pandoc sample_div.md --lua-filter=pandoc-div-box.lua --output=sample_div.pdf
.
It is also possible to use predefined boxes aka. admonitions. All you need to do is to call the classes .important
, .info
, .danger
, .warning
and .plain
(see sample_types.md).

You can add titles and define fill and border colors with
:::{.box fillcolor="#ababab" bordercolor="#000000"}
> Your title as a blockquote followed by an empty line
Your regular markdown content here such as
Here is some **Text** that you can *display* inside a Box!
You can also add your favorite markdown commands such as
> a nice blockquote
Maybe a table?!
| Here | Here|
|------|----:|
|Here | and here |
And some bullet points
- Some
- important
- bullet
- points
and enumerations
1. first
2. second
3. third
> The last line as a blockquote results in adding a lower part of the box.
:::

This pandoc filter is basically wrapping a tcolorbox
around the text in markdown and provides the options:
- the title set by the first blockquote paragraph (see the important information below when you only want to put a quote inside the box)
- a lower part set by the last blockquote
- fillcolor: the background color of the box. Supports
HTML
(#...
) and latexxcolor
colors - bordercolor: the framecolor of the box. Supports
HTML
(#...
) and latexxcolor
colors
- So far the display of images with captions are not supported, since pandoc centers every image once it has a caption. Latex throws an error message
! LaTeX Error: Not in outer par mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.108 \centering
There are some semi optimal solutions to this, though.
- The
tcolorbox
package provides much more options than this filter. If you think that this filter should have more options, any PR redarding this issue is welcome.
- If you have your own
header-includes
file, you need to additionally importtcolorbox
with\usepackage{tcolorbox}
. - If you only want to put a quote
>
into a box consider adding an empty title and empty bottom quote like this:
:::{.box}
>
> I think therefore I am
>
:::
Resulting in this:

- allow identification with
crossref
Use obsidians's callout syntax to create a box around text (see sample_callout.pdf). All types are supported (see obsidian's webpage).
> [!todo] To Do
> - [ ] Pick up Milk