Custom syntax highlighting theme with bookdown to produce pdf

Viewed 152

I am writing a new version of my Java book with bookdown. The book format is pdf.

I would like to customize the code highlight, specially the multi-line comments. I want only one color and the same style for all characters in these type of comments.

Here is what I have now (with unwanted style in multi-line comments):

Code with unwanted style in multi-line comments

I tried with pandoc_args: "--highlight-style=my.theme" in _output.yml:

bookdown::pdf_book:
  includes:
    in_header: preamble.tex
  latex_engine: xelatex
  citation_package: natbib
  keep_tex: yes
  pandoc_args: "--highlight-style=my.theme"
bookdown::epub_book: default

But the following error ocurs:

Could not read highlighting theme my.theme
Error: pandoc document conversion failed with error 6

I generated my.theme this way:

pandoc --print-highlight-style pygments > my.theme

The file my.theme is not the problem because it is working with standalone pandoc this way:

pandoc -f markdown libro_generado/libro_completo.md -o libro_generado/aprendejava.pdf --pdf-engine xelatex --highlight-style my.theme --include-in-header configuracion/titlesec.tex

I would like to use bookdown instead of standalone pandoc because I can have all the chapters, configuration and everything more organized.

I have been dealing with this problem for more than a week. I will be very grateful if I get some help.

0 Answers
Related