2

Based on the labelalpha style, I defined by own BibLaTex label, which consists of the first author's full name and the date of the publication. However, if the author's name is long and the citation is near the end of the lines, the label is hyphenated. A MWE looks like this:

\documentclass[%
   12pt,             
   english        
   paper = A4          
]{scrbook}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{Verylongname_74,
  author = {Verylongname, Tom S. and Longname, Bob C.},
  year = {1974},
  title = {The economics of brushing teeth},
  journal = {Journal of Political Economy},
  volume = {82},
  number = {4},
  pages = {887--891},
}
\end{filecontents}

\usepackage[%
  citestyle = alphabetic, 
  labelalpha = true,
  defernumbers = true,
  backend = biber, 
  maxalphanames = 1,
  firstinits = true
]{biblatex}%

% own BibLaTeX label definition -------------------------------

\renewcommand*{\labelalphaothers}{+}

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{shorthand}
    \field[compound=false]{labelname}
    \field{label}
  }
  \labelelement{
    \literal{\addnbthinspace}
  }
  \labelelement{
    \field[strwidth=2,strside=right]{year}
  }
}

\DeclareFieldFormat{labelalphawidth}{\mkbibbrackets{#1}}

% avoid hyphenation, not working!
\DeclareFieldFormat{labelalpha}{\nohyphenation #1}

%--------------------------------------------------------------

\addbibresource{\jobname.bib}

\begin{document}

This is a  line of text. This is a line of text. An example citation here is
\cite{Verylongname_74}.  The BibLaTeX  label, which is the
author's name, is hyphenated!

\end{document}

How can I tell BibLaTex not to hyphenate labels?

enter image description here

  • 1
    Try \AtEveryCitekey{\hyphenrules{nohyphenation}} in your preamble. mrunix.de/forums/… – Johannes_B Dec 12 '14 at 16:53
  • Hm, I get the error: ERROR: Package babel Error: You haven't defined the language nohyphenation yet. ? – Robinaut Dec 12 '14 at 18:31
  • babel is not loaded in your example. – Johannes_B Dec 12 '14 at 18:38
  • @Johannes_B Babel As far as I know, babel is loaded with the documentclass scrbook – Robinaut Dec 13 '14 at 8:16
  • @Johannes_B Had to install the language 'nohyphenation', now it's working! – Robinaut Dec 14 '14 at 7:38
2

With \AtEveryCitekey{\hyphenrules{nohyphenation}} in the preamble, hyphenation can be disabled for all BibLaTeX keys (the langugage nohyphenation must be defined in babel).

1

I tried the solution by Robinaut but did not get it to work with MikTeX 2.9 and Windows 10. I always got the following error:

Package babel Error: You haven't defined the language nohyphenation yet.

I did also not manage to edit the languages.ini like suggested here.

However, I found a working solution. If you have a look in the languages.ini there are some languages without hyphenation (they use zerohyph.tex as loader). Based on this, one can use one of these languages (e.g. arabic):

\AtEveryCitekey{\hyphenrules{arabic}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.