Skip to content

A pandoc latex-lua-filter that displays a box around text

License

Notifications You must be signed in to change notification settings

hayribakici/pandoc-box

Repository files navigation

pandoc-box

Pandoc lua-filter collection that creates a box around text.

There are two options:

  1. pandoc-div-box, that uses the pandoc markdown div ::: section. See sample_div.pdf or
  2. pandoc-callout-box, that uses the callouts from obsidian with > [!info]. See sample_callout.pdf.

Installation and running filter

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.

pandoc-div-box

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

Run this filter e.g. with pandoc sample_div.md --lua-filter=pandoc-div-box.lua --output=sample_div.pdf.

Admonition

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).

Customizing

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 latex xcolor colors
  • bordercolor: the framecolor of the box. Supports HTML (#...) and latex xcolor colors

Caveats

  1. 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.

  1. 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.

Important information

  1. If you have your own header-includes file, you need to additionally import tcolorbox with \usepackage{tcolorbox}.
  2. 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:

Future ideas

  • allow identification with crossref

pandoc-callout-box

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

Releases

No releases published

Packages

No packages published