moewew / biblatex-ext

Extensions for the biblatex standard styles
LaTeX Project Public License v1.3c
24 stars 3 forks source link

offer bibmacro number #32

Closed bastien-roucaries closed 2 years ago

bastien-roucaries commented 2 years ago

Allow localization of number by for instance using \num for siunit-x

It will allow better localisation of bibliography

moewew commented 2 years ago

Thanks for the suggestion. Do you have a use case for this?

If you want to apply siunitx's \num wouldn't \DeclareFieldFormat help with that already?

It appears to me that the macros that currently use the bare \printfield{number} are already fairly short (6 lines max) and fairly specialised. In fact number has slightly different semantics in each of these cases, so I'm wondering if it actually makes sense to have all of them handled by the same bibmacro.

bastien-roucaries commented 2 years ago

Even number could be for conference proceeding something like A11 therefore I use something brute force: \exp_args:Nne \tl_set:Nn \l_tmpa_tl {\thefield{number}} \regex_replace_all:nnN{[-]} {\c{hyp}} {\l_tmpa_tl} \regex_replace_all:nnN{(\d+)} {\c{num}[group-separator={,}]{\1}} {\l_tmpa_tl} \l_tmpa_tl

bastien-roucaries commented 2 years ago

Adding something like: \renewbibmacro{number}{% \ifbibmacroundef{number:\thefield{entrytype}} {\usebibmacro{number:}} {\usebibmacro*{number:\thefield{entrytype}}} It will be perfect

moewew commented 2 years ago

Hmm, can't you do that with \DeclareFieldFormat, though? \DeclareFieldFormat can naturally have different definitions for different entry types.

bastien-roucaries commented 2 years ago

Hmm, can't you do that with \DeclareFieldFormat, though? \DeclareFieldFormat can naturally have different definitions for different entry types.

Do not know but for my patent package (need to be publied but in the way), I will prefer to have this kind of macro

moewew commented 2 years ago

I'm still not convinced that this macro is useful. I don't want to add all possible macros in this bundle, the idea is to find a healthy balance. I think new bibmacros are especially useful if the \printfield they replace are used in a long chunk of code (directly in a driver for example), but here the \printfields are already pretty specialised and used in very short macros.

Presumably you are going to rewrite the patent driver code for your project anyway, then it should be easy enough to also add this bibmacro in your project where it is useful.

moewew commented 2 years ago

In light of https://github.com/moewew/biblatex-ext/issues/26 and the fact that type+number is used only for two drivers (@patent and @report), it appears to me that it would be easiest to just rewrite the @patent driver to use its own bibmacro for type and number, then you have full control over that. As I say above, I expect you essentially have to rewrite the @patent driver anyway, so this shouldn't be a roadblock.

But even if that is not an option, most simple use cases could easily be dealt with via field format it appears to me.

I'll close this, because I think it is outside the scope of this style bundle: We don't need a macro for every single field.