Search code examples
latexpandoc

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


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://stackoverflow.com/questions/70835461/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


Solution

  • 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