Create a lightbox in Markdown

I am looking to create a box around some text in a Markdown document. Nothing fancy, just a box around a section of text.

Am using Markdown for the plain text, but then am using Pandoc to convert it to PDF. Am using using the eisvogel.tex template for conversion. Any quick and easy suggestions for adding a box to the markdown text?

Thanks.

• eisvogel already supports tcolorbox: github.com/Wandmalfarbe/pandoc-latex-template/blob/master/…
– DG'
Sep 17 '20 at 19:42
• Good to know. I figured that was the case. I am still rather new to Markdown having used LaTeX primarily. How would I go about referencing the tcolorbox within my Markdown? Apologies for the newbie question. Sep 18 '20 at 15:06
• So, I found the following link that explains how to insert markdown within a Latex document and create a tcolorbox: tex.stackexchange.com/questions/529616/… How would I go about doing the reverse? That is, inserting LaTeX code into a Markdown document? I have a header document for my Markdown that references the most basics, i.e. titlepage: true and toc:true. How and where could I add tcolorbox to a markdown doc? Thanks. Sep 18 '20 at 15:13
• I am not sure, what you are asking. eisvogel gives you the tools to make a box in markdown, using tcolorbox, just look at the examples. Maybe you could clarify, what you want to achieve by providing a minimal working example (MWE)
– DG'
Sep 18 '20 at 16:40

I figured it out and am sharing the result here. Most everything was gleaned off the following pages:

https://github.com/chdemko/pandoc-latex-environment

https://github.com/Wandmalfarbe/pandoc-latex-template

To start, I run pandoc in a Docker file, so I needed to download some additional packages in order for this to work. Here is a small selection of the packages I downloaded within my "Dockerfile" and then how I started it up:

FROM pandoc/latex:2.10

#RUN tlmgr option repository http://ctan.math.washington.edu/tex-archive/systems/texlive/tlnet \
RUN tlmgr option repository http://ctan.math.utah.edu/tex-archive/systems/texlive/tlnet \
&& tlmgr update --self \
&& tlmgr install adjustbox awesomebox babel-german background bidi collectbox csquotes
everypage environ etoolbox filehook fontawesome5 footmisc footnotebackref framed fvextra
letltxmacro ly1 mdframed mweights needspace pagecolor pgf sourcecodepro sourcesanspro
tcolorbox titling tools trimspaces ucharcat ulem unicode-math upquote xcolor xecjk xurl
zref

ghc cabal libc-dev zlib-dev python3 py3-pip

RUN cabal update

#RUN cabal --global --prefix=/usr/local v2-install cabal-install
#RUN cabal --global --bindir=/usr/local/bin v2-install pandoc-include-code-1.4.0.0
#RUN pip3 install pandoc-extract-code pandocfilters

RUN pip3 install pandoc-extract-code pandocfilters pandoc-latex-environment


The key ingredient here was to include all the required packages needed by tcolorbox for eisvogel, i.e. install, tools, xcolor, tcolorbox, etc., and also to download and include pandoc-latex-environment in the statement "RUN pip3 install....."

Next, I needed to add the argument “--filter pandoc-latex-evironment” to my pandooc command. I use a shell script that is already highly customized for my environment, so I simply added an extra line to use the filter "pandoc-latex-environment".

Then I had to add some lines to the Markdown file's preamble:

header-includes:
- |
{=latex}
\usepackage{tcolorbox}
\newtcolorbox{info-box}{colback=cyan!5!white,arc=0pt,outer arc=0pt,colframe=cyan!60!black}
\newtcolorbox{warning-box}{colback=orange!5!white,arc=0pt,outer arc=0pt,colframe=orange!80!black}
\newtcolorbox{error-box}{colback=red!5!white,arc=0pt,outer arc=0pt,colframe=red!75!black}


And then, while still in the preamble below that, add the following:

pandoc-latex-environment:
tcolorbox: [box]
info-box: [info]
warning-box: [warning]
error-box: [error]


Once the code was in the preamble, I could start adding to the Markdown text itself. Taking examples I gleaned off of various pages here in StackExchange, I added the following:

## Standard Box

\begin{tcolorbox}

\abovedisplayskip=0pt%
\belowdisplayskip=0pt%
%\vspace{-1\baselineskip}
\begin{align}
\sigma & = \beta_{0}      \label{eq:Model0}   \\
\sigma & = \beta_{0} + \beta_{1}K + \beta_{2}K^2
\label{eq:Model1}   \\
\sigma & = \beta_{0} + \beta_{1}K + \beta_{2}K^2 + \beta_{3}(T-t) + \beta_{5}K(T-t)
\label{eq:Model2}   \\
\sigma & = \beta_{0} + \beta_{1}K + \beta_{2}K^2 +
\beta_{3}(T-t) + \beta_{4}(T-t)^2 + \beta_{5}K(T-t)
\label{eq:Model3}
\end{align}

\end{tcolorbox}


Then I began customizing the colors of each box:

::: info
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet libero
quis lectus elementum fermentum.
:::

::: warning
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet libero
quis lectus elementum fermentum.
:::

::: error
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet libero
quis lectus elementum fermentum.
:::
`

Now, I am able to get the following image rendered when I convert my Markdown file to a PDF file.

Much thanks to everyone who posted a small portion of the solution here on StackExchange. There were about 5-6 pages I was able to glean partial solutions from.