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/box

Repository files navigation

box

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

Run

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

Usage

The simplest usage would be to 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.pdf).

:::{.box}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren.

:::

Resulting in

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published