lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
948 stars 76 forks source link

[LaTeX] Pass nameinlink to cleveref when appropriate #203

Open themightyoarfish opened 6 years ago

themightyoarfish commented 6 years ago

In my metadata block I use

…
cref: True
nameInLink: True
…

Nonetheless, I get and undefined command error for \cref when converting to Latex pdf unless I specifically include \usepackage{cleveref} in my template.tex.

Likewise, I need to pass the nameinlink option in the template, it doesn't work when put into the metadata block.

What could the problem be?

lierdakil commented 6 years ago

cref: True specifically converts pandoc-crossref references to \cref LaTeX command when outputting to LaTeX (or PDF via LaTeX). It also tries to add relevant stuff into document preamble, but that won't really work if you're using a custom template (mostly for obvious reasons). If you want to allow pandoc-crossref to include TeX code it thinks it needs to into your template, you need to have something like this in your preamble:

$for(header-includes)$
$header-includes$
$endfor$

nameInLink doesn't apply to LaTeX output. nameInLink changes the behaviour of linkReferences option, which is documented thusly:

This has no effect on LaTeX output, since in this case, hyperlinking references is handled with hyperref LaTeX package.

So you might just as well use your custom template anyway and include \usepackage[nameinlink]{cleveref} manually.

All that said, I agree that nameInLink pandoc-crossref option could be repurposed to pass nameinlink to cleveref. So I'll treat this as an enhancement request. Will try to implement when I have some free time (which I seem to be rather short on lately)

themightyoarfish commented 6 years ago

I see. Not so familiar with Pandoc, thanks for the explanation. I think passing nameinlink to cleverf would be a reasonable and straightforward effect of setting this pandoc option.

zwz commented 5 years ago

@lierdakil I was using a custom template with cref. I removed

$for(header-includes)$
$header-includes$
$endfor$

I used --listings option for pandoc. But there came an complain: LaTeX Error: Environment codelisting undefined.

So do I have to copy the codelisting definition generated by 'header-includes' to my custom template?

lierdakil commented 5 years ago

@zwz. Please do not hijack issues, I have a hard enough time tracking those as it is. Create a new one if you have a question that's not immediately relevant to any open issues. That said, I've already explained this in https://github.com/lierdakil/pandoc-crossref/issues/197