gusbrs / zref-clever

Clever LaTeX cross-references based on zref
LaTeX Project Public License v1.3c
11 stars 4 forks source link

Unable to override \zcsetup{cap=true} with \zcRefTypeSetup{item}{cap = false} #23

Closed Enivex closed 7 months ago

Enivex commented 7 months ago

I prefer to have most things capitalized, with a few exceptions, like item.

It's therefore easiest to use \zcsetup{cap=true} and \zcRefTypeSetup{item}{cap = false}. However, this does not work. Item will still be capitalized.

What does work is to use \zcref[cap=false] every time I reference items, but that's tedious.

gusbrs commented 7 months ago

Hi @Enivex , thanks for the report. But this is actually documented behavior (and you do have another way to achieve what you want). The "Reference format" section of the User manual says about the precedence order of different option scopes:

There are four scopes in which reference formatting can be specified by the user, in the following precedence order: i) as general options; ii) as type-specific options; iii) as language- and type-specific options; and iv) as language-specific default options.

[...]

“General” options (i) can be given by the user in the optional argument of \zcref, but also set through \zcsetup (see Section 7). “Type” specific options (ii) are handled by \zcRefTypeSetup (see Section 5). “Language” options, whether “type” specific (iii) or “default” (iv) have their user interface in \zcLanguageSetup, and have their values populated by the package’s built-in language files (see Section 10).

So, yes, the option set with \zcsetup has precedence over that set with \zcRefTypeSetup (zref-clever treats options set with \zcsetup as pretty much the same as those set as keyval options to \zcref, the latter only gets local precedence over the former because it is set latter). But you can set a language specific default with something like:

\documentclass{article}

\usepackage{zref-clever}
% Or whatever language(s) you are using
\zcLanguageSetup{english}{cap=true}
\zcRefTypeSetup{item}{cap=false}

\begin{document}

\begin{enumerate}
\item \label{item1}Item.
\end{enumerate}

\zcref{item1}

\end{document}

Screenshot from 2024-01-18 10-58-52

You could also do everything as language specific settings:

\documentclass{article}

\usepackage{zref-clever}
% Or whatever language(s) you are using
\zcLanguageSetup{english}{
  cap=true,
  type=item,
    cap=false,
}

\begin{document}

\begin{enumerate}
\item \label{item1}Item.
\end{enumerate}

\zcref{item1}

\end{document}
Enivex commented 7 months ago

Thanks. I did actually try to figure it out from the documentation, but I guess I didn't read it carefully enough.

gusbrs commented 7 months ago

I did actually try to figure it out from the documentation, but I guess I didn't read it carefully enough.

That's fine. I didn't assume otherwise. And I do understand why you expected our initial attempt to work. These different options scopes are indeed more intricate than I'd like them to be. Alas, I couldn't figure a better way to expose the UI to users.