Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not set prefix defaults with cleveref #189

Open
tolot27 opened this issue Jul 25, 2018 · 6 comments
Open

do not set prefix defaults with cleveref #189

tolot27 opened this issue Jul 25, 2018 · 6 comments

Comments

@tolot27
Copy link

tolot27 commented Jul 25, 2018

Currently, prefix defaults like fig. will be set even if cleveref is in use (cref: true). If the language is set to a language which is also supported by cleveref (i. e. german; lang: de-DE locale: de-DE), figure labels get translated by cleveref as expected (in this case into Abbildung #:) but references are prefixed with fig. instead of Abb. because the prefixes were overwritten by pandoc-crossref.

I suggest to change crefnames only if set in YAML or variable or differ from default.

@lierdakil
Copy link
Owner

This is a tricky subject. On one hand, I get where you're coming from. On the other hand, the behaviour you're suggesting can be very confusing when outputting to multiple formats.

FWIW, custom LaTeX templates allow you to modify the default behaviour however you wish.

@zwz
Copy link

zwz commented Dec 4, 2018

I was going to post a similar issue when I found this one.
I am using a custom template, in which I would require package cleveref and set crefnames.
However, in the document preamble of the generated tex file, there is

\@ifpackageloaded{cleveref}{}{\usepackage{cleveref}}
\crefname{figure}{xxx.}{xxxs.}
\Crefname{figure}{Fig.}{Figs.}
\crefname{table}{tbl.}{tbls.}
\Crefname{table}{Tbl.}{Tbls.}
\crefname{equation}{eq.}{eqns.}
\Crefname{equation}{Eq.}{Eqns.}
\crefname{listing}{lst.}{lsts.}
\Crefname{listing}{Lst.}{Lsts.}
\crefname{section}{sec.}{secs.}
\Crefname{section}{Sec.}{Secs.}
\crefname{codelisting}{\cref@listing@name}{\cref@listing@name@plural}
\Crefname{codelisting}{\Cref@listing@name}{\Cref@listing@name@plural}

which overwrites my crefname customization. Is it better to put those crefname setting within the \@ifpackageloaded, as:

\@ifpackageloaded{cleveref}{}{\usepackage{cleveref}
\crefname{figure}{xxx.}{xxxs.}
\Crefname{figure}{Fig.}{Figs.}
\crefname{table}{tbl.}{tbls.}
\Crefname{table}{Tbl.}{Tbls.}
\crefname{equation}{eq.}{eqns.}
\Crefname{equation}{Eq.}{Eqns.}
\crefname{listing}{lst.}{lsts.}
\Crefname{listing}{Lst.}{Lsts.}
\crefname{section}{sec.}{secs.}
\Crefname{section}{Sec.}{Secs.}
\crefname{codelisting}{\cref@listing@name}{\cref@listing@name@plural}
\Crefname{codelisting}{\Cref@listing@name}{\Cref@listing@name@plural}}

@lierdakil
Copy link
Owner

@zwz, ifpackageloaded suggestion seems reasonable, I will make a note to amend it like you suggest (although \crefname{codelisting} should probably be run regardless, since codelisting is a non-standard float environment). However, there are two ways around this currently.

Pandoc's LaTeX template (pandoc -D latex) contains this code:

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

This is specifically what pandoc-crossref uses to add commands to the preamble.

So the first and easiest workaround is to just remove this, and add your own definitions instead.

You could also just add your own package customization after this code, inside AtBeginDocument, e.g.

$for(header-includes)$
$header-includes$
$endfor$
% Customize cleveref prefixes
\AtBeginDocument{%
\crefname{figure}{...}{...}
...
}

@zwz
Copy link

zwz commented Dec 4, 2018

Or another way to use cref, which is what I am doing, is to set figPrefix, figureTitle and etc. even when cref: true. It will generates the right document preamble.

Maybe you can make a note in the document of pandoc-crossref.

@lierdakil lierdakil added this to the v0.4 milestone Mar 3, 2019
@LukasCBossert
Copy link

Is there the possibility to omit all the prefix defaults and use pandoc-crossref only for converting the references in the text?
E.g. [@fig:xy] to \cref{fig:xy}?
This is helpful especially when one uses a custom made documentclass in which all the prefixes for cleveref are already set up.

@lierdakil
Copy link
Owner

lierdakil commented Aug 21, 2019

@LukasCBossert if you're using a custom pandoc LaTeX template, just remove this from the template:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants