biblatex icon indicating copy to clipboard operation
biblatex copied to clipboard

Add support for bidirectional biblographies

Open EvanAad opened this issue 3 years ago • 3 comments

Please enable the same bibliography to contain some bibliographic entries that are left-aligned with left-to-right text flow, and other entries that are right-aligned with right-to-left text flow. This would make it possible to typeset properly multilingual bibliographies containing entries from left-to-right languages such as English as well as entries from right-to-left languages such as Hebrew. For comparison, the bidi package provides the LTRbibitems and RTLbibitems environments for this very purpose.

One way you might be able to implement this feature is by adding to the biblatex formatting commands described in section 3.12.1 of the manual (v. 3.18b July 12 2022) commands \bibentrysetup and \bibentrycleanup, similar to \bibsetup and \citesetup, enabling to specify arbitrary code to be executed at the beginning and end of the processing of each bibliographic entry. This way it would be possible to inject, say, babel's language-switching command \selectlanguage before each bibliographic entry, or to wrap babel's \foreignlanguage environment around each bibliographic entry.

The biblatex tools available for inspecting bibliographic entries inside a \DeclareSourcemap's steps, as described on section 4.5.3 'Dynamic Modification of Data' of the manual, should be available to the code inside \bibentrysetup and \bibentrycleanup, so that selective actions can be taken based on the current entry. For example, if the value of the current entry's langid field is <x>, the babel command \setlanguage{<x>} should be inserted in front of the the code for the next bibliographic entry.

See also the following TeX StackExchange post: https://tex.stackexchange.com/q/666344/21685

EvanAad avatar Nov 25 '22 07:11 EvanAad

As mentioned in https://github.com/plk/biblatex/issues/1142 and https://github.com/plk/biblatex/issues/1139, I have little experience with bidi typesetting. So for a proper solution we'd need help from someone who knows how to properly deal with this.

Even at the moment biblatex offers a way to switch languages between entries according to the langid value (have a look at the language option in connection with autolang), but this does not appear to be enough as seen in https://github.com/plk/biblatex/issues/1142 because we're switching inside a list (which does not seem to yield good results).

moewew avatar Nov 25 '22 08:11 moewew

It's worthwhile to know that of the three right-to-left languages mentioned in the tickets you referenced, namely Arabic, Farsi, and Hebrew, Hebrew (by which I mean modern Hebrew for general-purpose prose) is the easiest to typeset, since it has no ligatures and its typography has no special cases. Each letter is unto itself. Each letter is a glyph, and vice versa, and they don't connect or change shape according to context (technically this is not true - four letters have a different shape when they appear at the end of the word - but you can safely ignore this, since for all intents and purposes these variations are treated as extra letters, for instance they occupy their own separate keyboard keys like any other letter, and users have to type them out explicitly, rather than expect the text processing software to infer them based on context). And the numerics are those used in English. It is essentially just like English, except from right to left. In fact, it is simpler than English, since, unlike English, there are no ligatures and special cases. So you might want to start your explorations and experimentations from Hebrew to get an idea how the right-to-left thing works.

EvanAad avatar Nov 25 '22 09:11 EvanAad

With babel, wrap the LTR items with otherlanguage. An example from the OP in stackexchange is:

\documentclass{article}
\usepackage[bidi=basic, hebrew,  provide=*]{babel}
\babelfont{rm}[Renderer=Harfbuzz]{Arial}

\begin{document}

\begin{thebibliography}{99}
\bibitem LLea Goldberg. \emph{An Apartment for Rent}. 1959
\bibitem LLea Goldberg. \emph{An Apartment for Rent}. 1959
\begin{otherlanguage}{english}
\bibitem SShel Silverstein. \emph{The Giving Tree}. 1964
\end{otherlanguage}
\bibitem LLea Goldberg. \emph{An Apartment for Rent}. 1959
\begin{otherlanguage}{english}
\bibitem SShel Silverstein. \emph{The Giving Tree}. 1964
\end{otherlanguage}
\bibitem LLea Goldberg. \emph{An Apartment for Rent}. 1959
\end{thebibliography}
\hrule
\end{document}

Some minor changes in margins and the like will be necessary.

bib-bidi

jbezos avatar Nov 26 '22 08:11 jbezos