BibTeX, biblatex and biberBiBTeX and hyphenation

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

BiBTeX and hyphenation

Post by meho_r »

Hi

Is it possible to define hyphenation points for entries in bibliography (.bib) file? I'm using jurabib package. Example: I've got an entry goes by title: "El-Mutetahhirun" for which I need these hyphenation points: "El-Mu-te-tah-hi-run" (the first one, after 'El', is real dash, not a hyphenaton point, and must not be breakable, so I used \mbox{-} to prevent this (El\mbox{-}); if there is a better solution for nonbreakable hyphens, I'd be grateful to hear it too).

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

BiBTeX and hyphenation

Post by meho_r »

OK, I found some kind of solution (the only one?). Manual hyphenation points can be set by using {\-} in .bib file (instead of just \- which is used in main text in a doc. For the example above: El\mbox{-}Mu{\-}te{\-}tah{\-}hi{\-}run). The problem is that all entries in .bib file should be written this way and it is a tedious job indeed :( If anyone have simpler solution, please share.
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Re: BiBTeX and hyphenation

Post by phi »

It should be possible to use the \hyphenation command in the main TeX file.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: BiBTeX and hyphenation

Post by meho_r »

Thanks for the reply. Unfortunately, it seems that \hyphenation in the main text doesn't apply to bibtex entries :(
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

BiBTeX and hyphenation

Post by phi »

It's not a problem with BibTeX, but you have to enable hyphenation after every hyphen. Here is an example:

Code: Select all

@article {
uuu,
title = "uuu",
journal = "uuu",
author = "{aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa El\nobreakhyphen Mutetahhirun}",
year = "1234"
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And the document:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\hyphenation{Mu-te-tah-hi-run}
\makeatletter
\newcommand*\nobreakhyphen{\hbox{-}\nobreak\hskip\z@skip}
\makeatother
\begin{document}
\cite{uuu}
\bibliographystyle{plain}
\bibliography{BibTeXHyphenation}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

BiBTeX and hyphenation

Post by meho_r »

Thank you for the example, phi, it was very helpful. I managed to solve the part with the book titles in .bib file, but for some reason, if I put \nobreakhyphen in author field, I always get a space after the hyphen. Here's an example for testing:

1. Content of bibliography file (named: bib.bib):

Code: Select all

@book{ik-vs,
author = {Ibn\nbh Kajjim},
title = {Ibn\nbh Kajjim El\nbh Vabilus\nbh sajjib -- El-Vabilus-sajjib},
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I repeated the author in "title" field just to present the difference, and the title to be sure everything is working OK. With your code, hyphenation is working fine, I don't even have to input every term in \hyphenation{} in the main text, many of them are hyphenated automatically.

2. Main file:

Code: Select all

Code, edit and compile here:
\documentclass[a4paper,10pt]{scrbook}
\usepackage{jurabib}
\jurabibsetup{%
authorformat={allreversed},
titleformat={italic,commasep,all},
titleformat={italic,noreplace},
citefull=all,
commabeforerest,
ibidem=strict,
oxford=true,
super,
dotafter=bibentry,
bibformat={numbered}
}
\renewcommand{\bibansep}{, }
\renewcommand{\bibbdsep}{,}
\renewcommand{\bibatsep}{}
\renewcommand{\bpubaddr}{,}
\renewcommand{\biblnfont}{\normalfont}
\renewcommand{\bibfnfont}{\normalfont}
\renewcommand{\bibtfont}[1]{\textit{#1}}
\usepackage{bibtopic}
\bibliographystyle{jurabib}
\makeatletter
\newcommand\nbh{\hbox{-}\nobreak\hskip\z@skip}
\makeatother
\begin{document}
Test\cite{ik-vs}
\begin{btSect}{bib}
\chapter{Bibliography}
\btPrintCited
\end{btSect}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BTW, just a thought, there are many packages for many purposes in LaTeX, have anybody created a package that controls hyphens and dashes (nonbreakable ones and "no-break-after-hyphen/dash" in particular?)
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

BiBTeX and hyphenation

Post by phi »

meho_r wrote:Thank you for the example, phi, it was very helpful. I managed to solve the part with the book titles in .bib file, but for some reason, if I put \nobreakhyphen in author field, I always get a space after the hyphen.
BibTeX tries to parse the author names to be able to sort and format them. To prevent this, put them into a pair of braces. Because ordinary strings are already delimited either by braces or by quotation marks, you'll have to type "{ ... }" or {{ ... }}. I chose the former in my example. You should do the same in the title tag, too, because it is converted to lowercase letters otherwise.
BTW, just a thought, there are many packages for many purposes in LaTeX, have anybody created a package that controls hyphens and dashes (nonbreakable ones and "no-break-after-hyphen/dash" in particular?)
Your requirement is a bit uncommon. The TeX standards (always break at hyphens, never break automatically if there is a hard or soft hyphen in the same word) are OK for the English language where there are only short words and few hyphens. It is not sufficient for languages with long words and many hyphens, like German. So the language support for German in the babel package enables some shorthands: "~ for a non-breaking hyphen, "- for a soft hyphen without disabling automatic hyphenation, "" for enabling automatic hyphenations if they were disabled, and so on. "~ is basically \leavevmode\hbox{-} and "" is \nobreak\hskip\z@skip, like in my \nobreakhyphen command. (I simply copied the definition from there.) So these definition do exist for languages that need them. But as I said, your request is perhaps too uncommon so no one has created a specific package yet.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: BiBTeX and hyphenation

Post by meho_r »

Thanks a lot for your help, phi :)

I don't think the idea about creating a package for nonbreaking hyphens/dashes or "no-line-breaking" after them is so uncommon though. Even in English language, you don't want that after an en-dash in, let say, 123--456, the last number, 456, goes in the next line. It isn't nice to have em-dash at the end of a line too. And in languages in my area (bosnian, croatian, serbian) if we get a hyphen at the end of a line (like in writing arabic terms like El-Kitab), it should be repeated at the beginning of the next line too so it can be clearly distinguished of normally hyphenated words (with only one hyphen -- at the end of the line, as usual). But it is preferrable to have the word with a hyphen hyphenated before or after the actual hyphen (like in English, as far as I know). The good thing is of course TeX "programmability" so one can define his own commands that do things right, but the text can look a little bit messy :)
Post Reply