What is the recommended way, to insert text into BibLaTeX databases, in order to enable LaTeX to hyphenate the entries accordingly to avoid overfull lines due to dashes in composed words?
I suppose, you all have faced the problem. You carefully edit the databases, that contain the bibliographical information given to BibLaTeX. Of course, every information is precious and the more the better, one would argue. So you also take care, that every detail is present in your databases and most of those information pieces will get extracted by biber
and therefore will be presented in a LaTeX file (within the bibliography section).
Of course, LaTeX has to typeset the content of your databases, in order to make up the final page. Therefore it has to hyphenate the content.
I am a native german, most of my documents are in the german language. Therefore, my documents of course incorporate
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[german]{csquotes}
\usepackage[backend=biber,style=numeric]{biblatex}
to set up the german language and be able, to have proper hyphenation schemes.
Most of the text in my documents use the babel shorthand "=
to insert a dash, at which LaTeX may hyphenate the word and will also check the following hyphenation possibilities in the remaining word. This looks something like
... das Corporate"=Design, welches als Kopier"=Vorlage ...
This works really fine. In fact, inserting the "=
instead of the normal dash (-
) is now a the normal way for me and has become a second nature to me. I use it everywhere.
But this does not work for the entries in my BibLaTeX databases. After the requested entries have been extracted and manipulated by BibLaTeX, they are once again compiled by LaTeX, but instead of replacing the shorthand with the dash, the shorthand letters are copied into the final document.
On the other hand: inserting the regular dash into the BibLaTeX databases results in the normal LaTeX behaviour, in that the dash prevents LaTeX to hyphenate everything in the word following the dash. This surely will produce overfull hboxes!
Both solutions are not satisfying at all! Either you have words containing "=
in the output or overfull lines.
I thought, that biber
s job is only, to extract the needed entries from the databases, manipulate them as dictated by the chosen style and output everything into a LaTeX like file, which is then interpreted by the latex
(or pdflatex
, lualatex
, xelatex
...) compiler again. And while this is true to some extent, is is obviously not true, when it comes to replacing the defined babel shorthands and hyphenation of words, that have been concatenated with such a shorthand. The trick, that worked so well for the rest of the document, suddenly stops working, when compiling the bibliography section.
So the question is: what is the correct way, to safe and sound input some sort of dash-like characters, shorthands, macros, ..., which will be hyphenated and afterwords typeset by LaTeX, to produce the high quality output, we all know and love.
EDIT
As mentioned by David Carlisle, using -\hspace{0pt}
does the trick. LaTeX is now able to hyphenate after an -
. But I am sad to say, that this addition make the entries less unreadable.
@Book{voss21:wissenschaftliche-arbeit-mit-latex,
author = {Voss, Herbert},
title = {Die wissenschaftliche Arbeit mit \LaTeX},
indextitle = {Wissenschaftliche Arbeit mit LaTeX, die},
year = 2021,
month = 6,
subtitle = {unter Verwendung von \LuaTeX{}, KOMA-\hspace{0pt}Script und
Biber/\BibLaTeX},
series = {DANTE-\hspace{0pt}Edition},
note = {Ist für Juni 2021 angekündigt.},
langid = {ngerman},
pubstate = {Zweite, überarbeitete und erweiterte Auflage},
location = {Berlin},
publisher = lob,
abstract = {\TeX{} wurde vor mehr als 35 Jahren für das
Erstellen von Dokumenten im wissenschaftlichen
Bereich erstellt. Anfänglich nur für Manuskripte von
mathematisch orientierten Büchern geschaffen, wurde
das Satzsystem \TeX{} sehr schnell als
prädestiniertes System für den gesamten
wissenschaftlichen Bereich erkannt. Mit dem neuen
\TeX-\hspace{0pt}Compiler \LuaTeX{}, welcher auf dem
traditionellen\TeX{} aufbaut, dem \TeX-\hspace{0pt}Format
\LaTeX{} und den Dokumentenklassen von KOMA–\hspace{pt}Script
lassen sich wissenschaftliche Arbeiten für jeden
Bereich und in jeder Sprache erstellen. Die
wissenschaftliche Arbeit stellt nicht nur besondere
Anforderungen an die Art und Weise von
Literaturverweisen und der Ausgabe der Bibliografie,
sondern auch an typografische Gepflogenheiten. Mit
diesem Buch bekommt jeder viele Hinweise für das
Erstellen von wissenschaftlichen Arbeiten auf
höchstem Niveau.},
keywords = {book},
pagetotal = 448,
edition = 2,
isbn = {978-3-96543-217-8},
}
Ulrike Fischer mentioned to use \hyphen
and \hyphenation
offered by BibLaTeX. Inserting \hyphen
instead of an -
will produce an identical result.
Quoting from the BibLaTeX manual
langid field (identifier)
The language id of the bibliography entry. The alias hyphenation is provided for backwards compatibility. The identifier must be a language name known to the babel/polyglossia packages. This information may be used to switch hyphenation patterns and localise strings in the bibliography.
Localisations works well, but the hyphenation is my problem.
And please forgive me: I consider inserting hspace{0pt}
to be an ugly workaround at best. This can't be the long term solution. Neither will it be, to switch from justified blocks to ragged lines, or being \sloppy
when typesetting the bibliography.
In my eyes, it is inconsistent, to have such a good hyphenation algorithm, being blocked by whatever the reason this might be.
(This question might sound similar to an earlier question of mine. That is true. But as that particular question is still not marked as solved and only has one answer, which specifically requires a LuaLaTeX compiler, I'd be pleased, if someone can advise me in a more general way, how to solve my problem.)
Corporate-\hspace{0pt}Design
would work\hyphenate
and\hyphen
for this.langid
key at every entry.