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

Implement bibliography string (formatting) classes (#555, #1027) #1028

Closed
wants to merge 3 commits into from

Conversation

moewew
Copy link
Collaborator

@moewew moewew commented Jul 18, 2020

Inspired by #555, #1027, etc. This should make it easier to apply formatting to bibstrings. While it is tempting to just include formatting commands like \mkbibemph directly in the strings, it doesn't always yield best results as demonstrated in

\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authortitle-ibid, backend=biber]{biblatex}

\DefineBibliographyStrings{french}{
  andothers = {\mkbibemph{et\addabbrvspace al\adddot}},
  ibidem    = {\mkbibemph{ibid\adddot}},
}

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson}
ipsum \autocite{sigfridsson}
dolor \autocite{aksin}
\printbibliography
\end{document}

The "ibid." in the second footnotes fails to be capitalised properly
screenshot of the footnotes from the MWE: in particular footnote 2 shows "ibid." in lowercase.

  1. ibid.

With this commit we can define a new class for Latin terms and apply additional formatting (in the right place) only to those strings.

\documentclass[british,french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authortitle-ibid, backend=biber]{biblatex}

\DefineBibliographyStrings{french}{
  andothers = {et\addabbrvspace al\adddot},
  ibidem    = {ibid\adddot},
}

\DefineBibliographyExtras{french}{%
  \DeclareBibstringSet{latin}{andothers,ibidem}%
  \DeclareBibstringSetFormat{latin}{\mkbibemph{#1}}}

\UndefineBibliographyExtras{french}{%
  \UndeclareBibstringSet{latin}}

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson}
ipsum \autocite{sigfridsson}
dolor \autocite{aksin}
\printbibliography

\selectlanguage{british}
Lorem \autocite{sigfridsson}
ipsum \autocite{sigfridsson}
dolor \autocite{aksin}
\printbibliography
\end{document}

screenshot of the footnotes from the MWE: Footnote 2 now is correctly capitalised to "Ibid.". The English footnotes do not show any of the italic formatting for the French text.


This also helps with #899.


@plk (and anyone else who wants to have a go) As always I don't feel particularly confident about the name. Suggestions are welcome. Other comments are of course also appreciated.

@moewew moewew mentioned this pull request Jul 18, 2020
@moewew moewew added the localisation concerns lbx files or localisation in general label Jul 18, 2020
@plk
Copy link
Owner

plk commented Jul 29, 2020

I like the idea - if the "class" is only used to determine the format, how about just:

  \DeclareBibstringFormat{andothers,ibidem}{\mkbibemph{#1}}}

@moewew
Copy link
Collaborator Author

moewew commented Jul 29, 2020

Good point. At least at the moment the classes are only for formatting. And I don't see much use apart from formatting.

The problem with

\DeclareBibstringFormat{andothers,ibidem}{\mkbibemph{#1}}}

would be that allowing a comma-separated list in the first argument would is inconsistent with \DeclareFieldFormat and friends.

If we have \DeclareBibstringFormat I'd also want a way to define format aliases (so that people can say ibidem and andothers are latin and latin is defined as ...). Normally the name for that is built by replacing Format with Alias (cf. \DeclareNameFormat - \DeclareNameAlias), this doesn't quite work here, I feel, since \DeclareBibstringAlias sounds like it does something different.

Plus there is the whole shenanigans about cleaning up after yourself, which needs some thoughts (currently via \UndeclareBibstringClass{...}). For that it appears to be easier to have a named object. Otherwise we'd have to list each string separately.

@plk
Copy link
Owner

plk commented Jul 29, 2020

How about:

\DeclareBibstringSet{latin}{...}
\DeclareBibstringFormat{latin}{...}

We already have "set" as a general concept in other places and it really is a set ... I don't think we need to say "SetFormat" as formats will only apply to sets and it'll be documented like that.

@moewew
Copy link
Collaborator Author

moewew commented Jul 29, 2020

I like 'set'. fd333b1 hopefully changes all occurrences of 'class' to 'set'.

I chickened out of going for \DeclareBibstringFormat and went for \DeclareBibstringSetFormat to make it clear to users that we are formatting all bibstrings in a set and that \DeclareBibstringFormat can't natively be used to format a single bibstring. If you feel strongly about dropping the Set here, I can reconsider that decision.

moewew added a commit that referenced this pull request Mar 28, 2021
@moewew
Copy link
Collaborator Author

moewew commented Mar 28, 2021

Merged manually in e0816f1, 091ca1f, f9ed28e, 4579cca, 4348f30.

@moewew moewew closed this Mar 28, 2021
@moewew moewew added this to the v3.17 milestone Mar 28, 2021
@moewew moewew deleted the bibstringformat branch April 30, 2021 07:01
@moewew moewew mentioned this pull request Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement localisation concerns lbx files or localisation in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants