1

When referring to a person who is still alive I give the birth year followed by an en dash all in parentheses, as in Jim Foo (1977--). At times this results in a line break between the en dash and the right parentghesis. Is there any way to prevent this so that Jim Foo (1977--) is all on the same line?

  • 2
    The easiest approach is probably to pack the whole date expression in a box: \mbox{(1977--)} – barbara beeton Nov 27 '19 at 19:17
  • If you like one of the answers, it would be nice to mark it as correct :) – skyter Dec 2 '19 at 10:46
1

As Barbara already showed, you should put it in a \mbox to prevent the line break.

\mbox works like the content is in a box, that is not breakable.

If you want to make life easier, you could create your own command:

\documentclass[12pt]{article}    
\newcommand{\alive}[2]{{#1} \mbox{({#2}--)}}
\begin{document}
\alive{Jim Foo}{1977}
\end{document}
|improve this answer|||||
  • 1
    If the name is long, boxing name plus date could force the whole thing to a new line, wreaking havoc on the spacing of the paragraph. While it's often possible to squeeze a single parenthesis into an existing line, things often don't go so well when a longer string is made unbreakable. – barbara beeton Nov 28 '19 at 0:20
  • True, edited it :) – skyter Nov 28 '19 at 13:30
1

You can use the \nobreakdash from amsmath.

\documentclass{article}

\usepackage{amsmath}

\textwidth=2.9cm


\begin{document}

\noindent X\dotfill X

Jim Foo (1977\nobreakdash--)

\end{document}
|improve this answer|||||
  • It seems that \nobreakdashes is in the basic LaTeX format. See comments following @DavidCarlisle's answer. – barbara beeton Nov 28 '19 at 17:34
1

enter image description here

Apart from boxing the whole date range, some other possibilities that may be more or perhaps less convenient, depending on the authoring requirements.

\documentclass{article}

\textwidth=2.9cm
\begin{document}

\noindent X\dotfill X

Jim Foo (1977--)


Jim Foo \mbox{(1977--)}

Jim Foo (1977\mbox{--})

Jim Foo (1977\nobreakdashes--)

\exhyphenpenalty=10000 % global affecting - and --- as well as --
Jim Foo (1977--)


\end{document}
|improve this answer|||||
  • Not quite exhaustive ... you didn't get the \nobreakdash. – barbara beeton Nov 28 '19 at 16:52
  • @barbarabeeton \nobreakdashes with an s I'd forgotten about that, will add, thanks – David Carlisle Nov 28 '19 at 17:05
  • @barbarabeeton added – David Carlisle Nov 28 '19 at 17:08
  • But I don't remember a plural? Did you change something? – barbara beeton Nov 28 '19 at 17:15
  • 1
    @barbarabeeton I didn't remember either but the plural is in the format since 2004, borrowed from amsmath: % \begin{macro}{\nobreakdashes} % \changes{v1.3}{2004/02/04}{(Macro added} % \changes{v1.3a}{2004/02/15}{(Added spacefactor setting} % This idea is borrowed from the \textsf{amsmath} package but % here we define a robust command. – David Carlisle Nov 28 '19 at 17:18

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.