8

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? – karlkoeller Jan 17 '14 at 11:46
  • Is your problem how to change the result LaTeX file, or how to make pandoc create what you want? – Raphael Jan 17 '14 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 '14 at 14:29
7

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

1

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:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.