Pandoc: svgnames and x11names not supported for xcolor color names

Created on 3 Feb 2020  路  11Comments  路  Source: jgm/pandoc

svgnames and x11names not supported for xcolor color names.

Despite of the documentation saying it should:

image

dvipsnames

$ pandoc basic-example.md \
--from markdown \
--to pdf \
-o bug.pdf \
--pdf-engine=pdflatex
---
urlcolor: "RedOrange"
---

[link](http://example.org)

svgnames

$ pandoc basic-example.md \
--from markdown \
--to pdf \
-o bug.pdf \
--pdf-engine=pdflatex
Error producing PDF.
! Package xcolor Error: Undefined color `DarkOrange'.

See the xcolor package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.56 \href{http://example.org}{link}
---
urlcolor: "DarkOrange"
---

[link](http://example.org)

x11names

$ pandoc basic-example.md \
--from markdown \
--to pdf \
-o bug.pdf \
--pdf-engine=pdflatex
Error producing PDF.
! Package xcolor Error: Undefined color `DarkOrange2'.

See the xcolor package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.56 \href{http://example.org}{link}
---
urlcolor: "DarkOrange2"
---

[link](http://example.org)
LaTeX writer

Most helpful comment

According to the manual is a mechanism for deferred definition. It's the first time I come across them so I might be missing something, but it seems to boil down to not defining the colors unless they are explicitly mentioned in the preamble with \definecolors - if I add in a header \definecolors{DarkOrange,DarkOrange2} to the examples above they work with the default template.

I guess they were added in this way to avoid using too much memory (at least this is the motivation for these types of options in the xcolor manual).

All 11 comments

I had a similar issue. In my case changing the default template from

\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}

to

\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}

solves the problem.

Is there any cost to enabling these in the default template?
(E.g. does it require additional dependencies?)

Not that I know, and at least in my case I didn't need to change anything else.
I have also tried the three cases above (with -t latex instead of --pdf-engine) and it works without problems.

What do the asterisks in the current default template even mean?
[I assume they're there for a reason, but I can't recall what it is.]

According to the manual is a mechanism for deferred definition. It's the first time I come across them so I might be missing something, but it seems to boil down to not defining the colors unless they are explicitly mentioned in the preamble with \definecolors - if I add in a header \definecolors{DarkOrange,DarkOrange2} to the examples above they work with the default template.

I guess they were added in this way to avoid using too much memory (at least this is the motivation for these types of options in the xcolor manual).

The example by @noraj works for me with pandoc 2.7.3. The preamble of the generated .tex document contains

\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}

I'm not sure the change to the starred version is relevant. If it matters, the relevant NEWS entry is:

Use starred versions of xcolor names (Andrew Dunning). Prevents changes to documents defined using the dvipsnames list (e.g. Blue gives a different result with svgnames enabled).

@adunning can you comment on the proposed change?
(See also #6524)
I'm not feeling confident about the implications.

Some colours are defined under the same name under the three different colour sets. See section 2.15.1 of the xcolor manual, 'Name clashs between dvipsnames and svgnames'. In loading all three sets but using the starred versions, I was trying to ensure that earlier documents wouldn't be changed from the earlier stage when we were only loading dvipsnames. There might be a better way to do it.

I did a lot of things, and nothing seemed to work, until I did find a guy in RStudio community who saved me.
Christophe Dervieux.
He proposed me to use this fragment in my RMarkdown header

(watch out the indentation)
it should looks like:

output:
---pdf_document:
-----keep_text: true
classoption: x11names
(replace -- with spaces)

None of the approaches above this code did work for me. Only this one.
Pandoc should has some issue passing _parameters_ to xcolor... I think is the precedence order... but I am only guessing. By far I am not an expert.

I think I'm going to remove the asterisks.

OK, looking into this more...
I can't reproduce the problem on my system.
RedOrange works just fine with the existing default template.
So does DarkOrange.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jgm picture jgm  路  62Comments

jgm picture jgm  路  117Comments

jgm picture jgm  路  51Comments

kevinushey picture kevinushey  路  79Comments

graymalkin picture graymalkin  路  54Comments