# How to change the background color and border of a Pandoc-generated blockquote?

This question has a possible solution, but it's for the ConTeXt writer, which I can't use.

ConTeXt: How to change the background color and border of a Pandoc-generated blockquote?

What would be a LaTeX solution to achieve the same?

EDIT: pandoc version is 1.9.4.2 on a debian wheezy system. This is the tex generated from pandoc -V geometry:a4paper -V geometry:margin=2cm test.md -o test.tex

\section{Test 1}
\subsection{Test 2}
\ldots{} this is a test.
\begin{verbatim}
Block
quote
123
\end{verbatim}
\ldots{} more text.


I don't use a custom template. If I put the example (\startsetups framedsetups ...) from the link in a file framedtext.tex and include it via -H, I get (and yes, I know I'd have to change the environment verbatiminstead of blockquote):

>\$ pandoc -H framedtext.tex -V geometry:a4paper -V geometry:margin=2cm test.md -o test.pdf
pandoc: Error producing PDF from TeX source.
! Undefined control sequence.
l.39 \startsetups

• Welcome to TeX.SX! Can you please add the code generated by Pandoc? Jan 17, 2014 at 11:46
• Is your problem how to change the result LaTeX file, or how to make pandoc create what you want? Jan 17, 2014 at 13:03
• The latter. The link at the top has a solution, but it's for ConTeXt. I need a solution for LaTeX, i.e. a file I could include via the -H option.
– Jan
Jan 17, 2014 at 14:29

You simply need to use LaTeX code if you are going to produce a LaTeX document. A very simple example:

% mystylefile.pandoc
\usepackage{tcolorbox}
\newtcolorbox{myquote}{colback=red!5!white, colframe=red!75!black}
% redefine the 'quote' environment to use this 'myquote' environment
\renewenvironment{quote}{\begin{myquote}}{\end{myquote}}


Then the markdown file:

<!-- test.md -->
This is not a block quote.

>    This question has a possible solution, but it's for the ConTeXt writer, which I can't use.
>    ConTeXt: How to change the background color and border of a Pandoc-generated blockquote?
>    What would be a LaTeX solution to achieve the same?

This is not a block quote.


Then the pandoc line:

pandoc -H mystylefile.pandoc -V geometry:a4paper -V geometry:margin=2cm test.md -o test.tex


If you have not modified the latex.template file (see here for some hints how to modify it), you should end up with a .tex file that looks like this:

\documentclass[]{article}

% Note: I have cut out all the default stuff that ends up here
% to highlight what the effects are of including mystylefile.sty

\usepackage{tcolorbox}

\newtcolorbox{myquote}{colback=red!5!white, colframe=red!75!black}

\renewenvironment{quote}{\begin{myquote}}{\end{myquote}}

% Other default stuff removed

\begin{document}

This is not a block quote.

\begin{quote}
This question has a possible solution, but it's for the ConTeXt writer,
which I can't use. ConTeXt: How to change the background color and
border of a Pandoc-generated blockquote? What would be a LaTeX solution
to achieve the same?
\end{quote}

This is not a block quote.

\end{document}


This is the quick hack. The better solution is to create a latex.template file and use that (if I remember correctly, that's what the -D switch is for).

Using jon's answer and the latest version of pandoc, I was able to put the commands in the front matter of the markdown itself using header-includes: as follows:

metadata.yml:

header-includes:
- \usepackage{tcolorbox}
- \newtcolorbox{myquote}{colback=red!5!white, colframe=red!75!black}
- \renewenvironment{quote}{\begin{myquote}}{\end{myquote}}


Use in markdown:

> Here's a blockquote


PDF result: