Hyphenation when using non breaking space for names like in `F.\,Fugmann`

A trick learned from egreg. If you put \nobreak\hspace{0pt} between the nonbreakable space and the last name, the last name will be reevaluated as its own entity for hyphenation. Below, I codify that as \? to place the small unbreakable space and reset the "hyphenability" of the following word.

\documentclass{article}
\newcommand\?{\,\nobreak\hspace{0pt}}
\textwidth0pt\relax
\begin{document}
\hyphenation{Fug-mann}
Start
Fugmann 
F.\,Fugmann
F.\?Fugmann
\end{document}

enter image description here

In a comment, Gustavo adds a pointer to Knuth's explanation on why this works, found on page 454 of the TeXbook:

enter image description here

The key in Knuth's explanation is that "hyphenation is abandoned (until after the next glue item)" if "any other type of item occurs before a suitable starting letter." Therefore, the solution, by adding \hspace{0pt} is adding a "glue item" that restarts the hyphenation search, and the \nobreak prevents a line break from being inserted after the \, and before the last name, which could otherwise happen with a glue item.


Steven should take full credit; I add some considerations about the problem.

The separator between initials and surname seems to be controversial and you may be requested to use a normal space instead of the thin space.

So it's much better to define a macro that will take care of the issue: just changing its definition will modify the global behavior.

Here the macros; the main one has a *-form: I believe that names should be hyphenated only as a last resort; in case a particular name gives problems, it's easy to change \name{...} into \name*{...}.

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\setupnames}{m}
 {
  \keys_set:nn { fredfisch/name } { #1 }
 }
\NewDocumentCommand{\name}{sm}
 {
  \IfBooleanTF{#1}
   {
    \keys_set:nn {fredfisch/name} { hyphen=true }
   }
   {
    \keys_set:nn {fredfisch/name} { hyphen=false }
   }
  \fredfisch_name:n { #2 }
 }

\keys_define:nn { fredfisch/name }
 {
  hyphen .bool_set:N = \l_fredfisch_name_hyphen_bool,
  initials-sep .tl_set:N = \l_fredfisch_name_initials_sep_tl,
  surname-sep .tl_set:N = \l_fredfisch_name_surname_sep_tl,
 }

\seq_new:N \l_fredfisch_name_initials_seq
\tl_new:N \l_fredfisch_name_surname_tl

\cs_new_protected:Nn \fredfisch_name:n
 {
  \seq_set_split:Nnn \l_fredfisch_name_initials_seq { . } { #1 }
  \seq_pop_right:NN \l_fredfisch_name_initials_seq \l_fredfisch_name_surname_tl
  \seq_if_empty:NTF \l_fredfisch_name_initials_seq
   {
    \mode_if_horizontal:F { \leavevmode }
    \kern0pt\nobreak\scan_stop:
   }
   {
    \seq_use:Nn \l_fredfisch_name_initials_seq { . \l_fredfisch_name_initials_sep_tl }
    .
    \l_fredfisch_name_surname_sep_tl
    \nobreak
   }
  \bool_if:NT \l_fredfisch_name_hyphen_bool { \hspace{0pt} }
  \l_fredfisch_name_surname_tl
 }

\ExplSyntaxOff

\hyphenation{Fug-mann}

\begin{document}

\setupnames{
  initials-sep = {\,},
  surname-sep = {\,},
}

\parbox{0pt}{
Start
Fugmann 
\name{F. Fugmann}
\name*{F. Fugmann}
\name{P.A.M. Dirac}
}

\bigskip

\setupnames{
  initials-sep={\,},
  surname-sep={~},
}

\parbox{0pt}{
Start
Fugmann 
\name{F. Fugmann}
\name*{F. Fugmann}
\name{P.A.M. Dirac}
}

\bigskip

\setupnames{
  initials-sep={~},
  surname-sep={~},
}

\parbox{0pt}{
Start
Fugmann 
\name{F. Fugmann}
\name*{F. Fugmann}
\name{P.A.M. Dirac}
\name{Fugmann}
\name*{Fugmann}
}

\end{document}

enter image description here

Note that, independently of how you input the initials, they will always be separated by the chosen space.

Some explanations. The argument to \name is split at periods and the last part is taken as the surname. Then the initials are delivered, separated by a period followed by the chosen separator; then the separator between the initials and the surname is inserted (note that it can be different from the separator between initials) along with \nobreak; if the *-variant is used, we also insert \hspace{0pt} that allows hyphenation in the surname.

Typing \name{Fugmann} will disallow hyphenation, but the *-variant will enable it again.