Pandoc `-V linkcolor` not working correctly when generating PDF with LaTeX
Asked Answered
S

1

2

I am using Pandoc 2.13.

If I run the following

pandoc -s foo.md                                        \ 
       -f markdown_phpextra+autolink_bare_uris+raw_tex  \
       --toc                                            \
       -V title="Pandoc Lunch and Learn"                \
       -V linkcolor:blue                                \
       -V mainfont="DejaVu Serif"                       \
       -V monofont="DejaVu Sans Mono"                   \
       -V geometry:letterpaper                          \
       -V geometry:margin=2cm                           \
       -V documentclass:article                         \
       -o foo.pdf

My links are blue, as expected.

However, if I try to use -V linkcolor:red or any other color for that matter the links still end up blue. If I use V urlcolor=red the link colors change as I'd expect. Why doesn't linkcolor work? Per the manual it seems like it should: https://pandoc.org/MANUAL.html#variables-for-latex

EDIT: This is foo.md

# Foo

## Foo Bar Baz

[This link][1] will always be blue, even when I pass `-V linkcolor:red`

[1]: https://mcmap.net/q/409480/-pandoc-v-linkcolor-not-working-correctly-when-generating-pdf-with-latex

Note that the link is blue when run with Pandoc 2.13 with this following command line args:

pandoc -s foo.md                                        \
       -f markdown_phpextra+autolink_bare_uris+raw_tex  \
       --toc                                            \
       -V title="Pandoc Lunch and Learn"                \
       -V linkcolor:red                                 \
       -V mainfont="DejaVu Serif"                       \
       -V monofont="DejaVu Sans Mono"                   \
       -V geometry:letterpaper                          \
       -V geometry:margin=2cm                           \
       -V documentclass:article                         \
       -o foo.pdf

Result: enter image description here

Sazerac answered 24/1, 2022 at 14:30 Comment(5)
Can you make a minimal reproducible example so we can see which types of links you are trying to change?Carding
Yes, see my edit.Sazerac
Note, if I explicitly specify --pdf-engine=pdflatex that doesn't change the behavior. Nor does using --pdf-engine=xelatex.Sazerac
your markdown link is converted to \href{...}{...}. This is an external link for the hyperref package, thus linkcolor, which is used to set the colour of internal links, does not apply.Carding
Ah, that makes sense, and now I see it in the manual: "linkcolor, filecolor, citecolor, urlcolor, toccolor color for internal links, external links, citation links, linked URLs, and links in table of contents, respectively" Could you please answer the question so I can accept your answer?Sazerac
C
4

The option linkcolor of the hyperref package is to change the colour of internal links, e.g. if you link to another section in your document.

However your link gets converted to \href{...}{...} macro, thus the colour is to be specified via the urlcolor option.

For more information about these hyperref options, see section "3.5 Extension options" of the user manual

Carding answered 24/1, 2022 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.