2

I have the following text in my .md file:

### Table of Contents, List of Tables, List of Figures

The example below shows how to place a table of contents, a list of
tables, and a list of figures, each in its own page.

~~~ latex
\newpage
\tableofcontents
\newpage
\listoftables
\newpage
\listoffigures
\newpage
~~~

When this is processed with the below command:

pandoc --number-sections \
    --toc --variable lof=true --variable lot=true \
    --filter pantable \
    --filter pandoc-tablenos \
    --filter pandoc-fignos \
    --filter pandoc-latex-fontsize \
    --from markdown \
    --standalone \
    --template=template.latex
    --variable subparagraph:yes \
    --variable colorlinks:yes \
    --to latex \
    --output document.txt \
    document.md

The code block does not have a shaded block around it. When I have the same sections, but without the latex after the first set of ~~~, the shaded block is produced, but I loose the language formatting. I looked at a bunch of potential solutions including adding the following to the template.latex file:

$if(highlighting-macros)&
$highlighting-macros&
$end$

I get the following error:

LaTeX Error: Command \VerbBar already defined.
             Or name \end... illegal, see p.192 of the manual.

The code that is generated by pandoc for the above is:

\begin{Shaded}
\begin{Highlighing}
\FunctionTok{\textbackslash{}newpage}
\FunctionTok{\textbackslash{}tableofcontents}
\FunctionTok{\textbackslash{}newpage}
\FunctionTok{\textbackslash{}listoftables}
\FunctionTok{\textbackslash{}newpage}
\FunctionTok{\textbackslash{}listoffigures}
\FunctionTok{\textbackslash{}newpage}
\end{Highlighing}
\end{Shaded}

When not indicating the language, the same section would be generated as:

\begin{verbatim}
\newpage
\tableofcontents
\newpage
\listoftables
\newpage
\listoffigures
\newpage
\end{verbatim}

The version of pandoc that I am using is:

pandoc 2.2.2
Compiled with pandoc-types 1.17.4.2, texmath 0.11, skylighting 0.7.0.2

using Tex Live 2013/Debian.

and is running on (I cannot upgrade at this time):

Linux myhostname 4.4.0-96-generic #119-14-04.1-Ubuntu SMP Wed Sep 13 08:40:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I need to be able to use code blocks with language specifiers that generate shaded blocks around the code when generating a PDF file.

NOTE: I am not having an issue with generating an HTML file.

1

$ pandoc --to latex test.md --highlight-style tango -o test.pdf

mwe

To see the available styles: pandoc --list-highlight-styles

  • Thanks. This did what I was looking to do. In the end I exported the tango style to a file, updated it for my needs and use that file on the --highlight-style qualifier. This is exactly what I needed. – JonBelanger Dec 21 '18 at 15:56
0

You should add --highlight-style=<xxxx> to your Pandoc command. For possible values of <xxxx> make your pick from pandoc --list-highlight-styles.

I frequently use --highlight-style=espresso. (I slightly modified your Markdown to fit all output on one page, and to really show highlighting of LaTeX code for the screenshot below.) The result:

enter image description here

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.