I think this works:
\makeatletter
\AtEveryCitekey{%
\blx@langsetup\abx@field@hyphenation%
\blx@hyphenreset%
}
\makeatother
In \abx@field@hyphenation
is hyphenation value. Probably it needs some testing, if it is set.
edit:
Some time ago, I was looking at biblatex language switching because of problem with my citation style[1]. I didn't understand this code at all, so I ended with ugly hack[2].
But when I looked yesterday on biblatex's patch of babel you posted, I have found line
\blx@langsetup\languagename\select@language
Function \blx@langsetup
uses edef
to define \blx@languagename
, which is used by macro \blx@hyphenreset
to load hyphenation patterns, and then loads localization strings for given language. So in fact, instead of
\blx@langsetup\abx@field@hyphenation%
it is possible to use just
\edef\blx@languagename{\abx@field@hyphenation}%
Then there is problem with French language. When used as the main document language, instead of
... (Fis-
el 1985)...
there is
...(FISCHEL
1985)...
I think there is issue only with French, I tried Czech, Russian and Spanish and they worked correctly.
With babel
, we can solve this issue with
\select@language\abx@field@hyphenation%
but, polyglossia
in xelatex has same issue and this trick is there not working, I don't know how to fix that.
Anyway, if you don't need French with polyglossia
, this is the current solution
\makeatletter
\AtEveryCitekey{%
\ifcsdef{abx@field@hyphenation}{%
\edef\blx@languagename{\abx@field@hyphenation}%
\select@language\abx@field@hyphenation%
\blx@hyphenreset%
}{}%
}
\makeatother
[1] Biblatex - using two languages in one reference entry
[2] Biblatex - using two languages in one reference entry
As far as I can see, you problem is not that hyphenation and hyphenation pattern in general do not work properly. Your overall problem is that words containing hyphens cannot be hyphenated elsewhere (see e.g. Adequate hyphenation of words already containing a hyphen) and specifically your problem is that the babel-german
solution "=
does not quite work with biblatex
(as also documented in your earlier question babelshorthand "= does not work with BibLaTeX?).
It might be instructive to briefly discuss why "=
does not work. "=
relies on "
being a shorthand/an active character and thus ultimately on category codes. At least for me, catcodes are one of the more tricky aspects of TeX programming. Essentially (but quite possibly not entirely correctly) TeX remembers the category code of each character it encounters. That category code is essentially frozen and cannot be changed after it has been read. So the category code settings at the point when code is "read" is relevant for how it behaves later on even if the category code of the characters involved are later changed.
biblatex
reads the contents of your bibliography items from the .bbl
file at \begin{document}
. This is done so that all data is available throughout the whole document. Crucially the file is read before babel
selects the document language. In particular even if your document language is ngerman
, where "
is an active character/shorthand, the .bbl
file is read at a time when "
is still a normal character and not at all a shorthand.
In fact "=
works fine if we already make "
a shorthand before \begin{document}
, because then "
is an active character when the .bbl
file is read (I cannot tell you if has any bad side-effects later on)
\documentclass[english,ngerman]{scrartcl}
\usepackage[style=numeric]{biblatex}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{dtk-logos}
\begin{filecontents}{\jobname.bib}
@Manual{class:scrguide,
title = {KOMA-Script},
author = {Kohm, Markus},
month = May,
year = 2016,
url = {http://www.komascript.de/~mkohm/scrguide.pdf},
langid = {ngerman},
note = {Bestandteil der Online"=Dokumentation von
\TeXLive, Datei \url{scrguide.pdf}},
keywords = {manual},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\shorthandon{"}
\begin{document}
Der Eintrag~\cite{class:scrguide} aus meiner
Literatur"=Datenbank erscheint im Quellen"=Verzeichnis leider mit
einem \verb|"=| in der Ausgabe.
\printbibliography
\end{document}
As Ulrike Fischer pointed out in the comments, biblatex
provides the command \hyphen
as a replacement for "=
that does not rely on (non-standard) category codes and thus works out of the box with all language settings.
\documentclass[english,ngerman]{scrartcl}
\usepackage[style=numeric]{biblatex}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{dtk-logos}
\begin{filecontents}{\jobname.bib}
@Manual{class:scrguide,
title = {KOMA-Script},
author = {Kohm, Markus},
month = May,
year = 2016,
url = {http://www.komascript.de/~mkohm/scrguide.pdf},
langid = {ngerman},
note = {Bestandteil der Online\hyphen Dokumentation von
\TeXLive, Datei \url{scrguide.pdf}},
keywords = {manual},
}
@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\hyphen Script und
Biber/\BibLaTeX{} und anderem mehr mehr},
series = {DANTE\hyphen Edition},
langid = {ngerman},
location = {Berlin},
keywords = {book},
pagetotal = 448,
edition = 2,
isbn = {978-3-96543-217-8},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Der Eintrag~\cite{class:scrguide,voss21:wissenschaftliche-arbeit-mit-latex} aus meiner
Literatur"=Datenbank erscheint im Quellen"=Verzeichnis leider mit
einem \verb|"=| in der Ausgabe.
\printbibliography
\end{document}
Note how "DANTE-Edition" is hyphenated correctly according to German rules even though it contains a hyphen.
If you prefer typing "=
over \hyphen
, you may be able to post-process your file to replace all "=
s by \hyphen
s.
biblatex
's \hyphen
is defined as \nobreak-\nobreak\hskip\z@skip
and so pretty much ends up doing what David Carlisle suggested in the comments.
Corporate\hyphen Design
is essentially
Corporate-\hspace{0pt}Design
Best Answer
Besides including hyphenation fields in your
.bib
file, you need to set thebabel
option ofbiblatex
(presumably toautolang=other
). See section 3.1.2.1 of the manual for details.