I have tried everything but I just can't get a proper hyphen inserted into a LaTeX portion.

Here's what I am trying to do:

\textit{ABC:} \href{someLink}{A-B-C}

I just want the two hyphens between A, B & C to be rendered properly.

However, LaTeX introduces a line break after the second hyphen and that is causing a lot of trouble in the document.

Any possible ways to fix this?

  • 1
    \mbox{A-B-C} ? (Overleaf is not involved here, they run a stadard latex installation) Jul 31, 2022 at 0:13
  • @DavidCarlisle hello ! Thanks, this is exactly what i had to do to get the hyphens working ! I appreciate your help Jul 31, 2022 at 12:49
  • I needed to give the comment so @egreg could answer, he needs the points:-) Jul 31, 2022 at 12:51
  • @DavidCarlisle ahaha ! yes, i noticed now ! he's closing in on a million ! this is pleasantly amusing :) Jul 31, 2022 at 12:57

1 Answer 1


As a general TeX rule, explicit hyphens1 can be used as a line break point. The second argument to \href is suitably processed so it can participate to line breaking, which might be necessary if it consists of several words or a rather long word alone (so spaces can be adjusted and hyphenation is tried for justification).

In order to exclude a hyphen from being used as a line break point, hide it in \mbox.


1 To be precise, the character whose character code has the same value as the \hyphenchar parameter for the current font.

  • Perfect ! this worked flawlessly ! Thank you so much ! Accepting this as the correct Answer ! Jul 31, 2022 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .