1

The following LaTeX code was saved in ~/Test.tex.

\begin{filecontents*}[overwrite]{\jobname.bib}
@book{hebook,
   author = {אריק and בנץ},
   title = {כותרת},
   year = {2022}
}
\end{filecontents*}
\begin{filecontents*}[overwrite]{hebrew.lbx}
\ProvidesFile{hebrew.lbx}
[\abx@lbxid]
\DeclareRedundantLanguages{hebrew}{hebrew}
\DeclareBibliographyStrings{and = {{ו}{ו}}}
\endinput
\end{filecontents*}
\documentclass{article}
\usepackage[bidi=basic,hebrew,provide=*]{babel}
\babelfont{rm}[Renderer=HarfBuzz]{FreeSans}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\cite{hebook}
\printbibliography
\end{document}

The code creates a file named Test.bib containing a BibTex bibliography consisting of a single entry: a book written by two authors. The code then creates a file named hebrew.lbx containing biblatex localization strings for the hebrew locale. This file contains only one entry: the Hebrew word for the conjunction and, the conjunction used, e.g., between two authors. The code then creates a simple article, whose main language is established, via the babel package, to be Hebrew. The body of the article contains a reference to the bibliography entry, and a bibliography.

Then the following commands were executed in the Terminal.

> cd ~
> lualatex Test
> biber Test
> lualatex Test

Consequently the file ~/Test.pdf was generated. When opened in a PDF viewer, the file displayed as follows. (I captured in the screenshot only the relevant part of the display.)

Hebrew bibliography containing a book with two authors

(Note that Hebrew is a right-to-left language.)

As can be seen, the output is as expected. All is well, then, right? Not quite. The problem is that in Hebrew, unlike in European languages, the conjunction and is not a standalone word, but rather a particle that is attached as a prefix to the following word (i.e. the word to its left, since Hebrew is a right-to-left language). However, as the screenshot shows, the Hebrew conjunction is treated as a standalone word, and is separated from the following author's name by a space.

How can this space be eliminated?

0

1 Answer 1

3

enter image description here

After the specified tokens there are some biblatex helper macros, then \space so you can insert a macro that looks ahead and gobbles space.

\begin{filecontents*}[overwrite]{\jobname.bib}
@book{hebook,
   author = {אריק and בנץ},
   title = {כותרת},
   year = {2022}
}
\end{filecontents*}
\begin{filecontents*}[overwrite]{hebrew.lbx}
\ProvidesFile{hebrew.lbx}
[\abx@lbxid]
\DeclareRedundantLanguages{hebrew}{hebrew}
\DeclareBibliographyStrings{and = {{ו\foo}{ו\foo}}}
\endinput
\end{filecontents*}
\documentclass{article}
\usepackage[bidi=basic,hebrew,provide=*]{babel}
\babelfont{rm}[Renderer=HarfBuzz]{FreeSans}
\usepackage{biblatex}
\def\foo#1\space{#1}
\addbibresource{\jobname.bib}
\begin{document}
\cite{hebook}
\printbibliography
\end{document}
2
  • Thanks for this great answer. However, one day hopefully the hebrew.lbx file will be part of the biblatex distribution, in which case the \foo command would need to be a part of the .lbx file, not of the .tex file. How can this be accomplished? I tried to move the \foo definition to the top of the .lbx file, just after the \ProvidesFile line, and it didn't work.
    – Evan Aad
    Dec 5, 2022 at 0:10
  • 1
    you could add it to the lbx I think (you may need \gdef not \def) but anyway if proposing to add to biblatex, flag this with the maintainers they could probably add an option (or there may be one already) that prevents \space being added rather than removing it later. Dec 5, 2022 at 0:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .