I want to put pdflatex to not put a hyphen in a word went it comes to the end of the line.

I tried to put a \- in the beginning or the end of that word but it doesn't work.

For example if I put:This is a very long sentence that needs two lines with thatshouldnot\- be hyphened I will get:

This is a very long sentence that needs two lines with thatshouldnot-
be hyphened

and if I do it this way: This is a very long sentence that needs two lines with \-thatshouldnot be hyphened I will get:

This is a very long sentence that needs two lines with -
thatshouldnot be hyphened

I want 'thatshouldnot' to stay in one word and with no hyphen in the beginning or the end of the word.

  • 2
    Do you want to suppress hyphenation of (a) all words everywhere, (b) all words of that paragraph, (c) all occurences of thatshouldnot, or (d) only this one word thatshouldnot ? – boycott.se - yo' Aug 17 '12 at 14:30
  • @tohecz (c) all occurences of thatshouldnot – MSIS Aug 17 '12 at 15:28
  • Is this similar to my question? tex.stackexchange.com/questions/100010/… – Jörg Apr 19 '13 at 13:01
  • @Jörg Yes, it is. – Aalok Apr 29 at 8:59
up vote 116 down vote accepted

if this word appears more than once in your document, and you never want it to be hyphenated, you can suppress hyphenation everywhere by putting this line in the preamble:

\hyphenation{thatshouldnot}

if it only occurs once, then david's answer using \mbox suffices.

  • 2
    that already contains a hyphen. the only practical way to suppress a break in that case is to box it. there is a "less practical" way, and that is to set \exhyphenpenalty=10000; since this will suppress breaks after all explicit hyphens, it has to be buried in a group along with the string on which it is supposed to act. – barbara beeton May 17 '16 at 15:41
  • 3
    @Valerio -- to handle this in the preamble, you will have to make a command: \newcommand{\KPLUS}{\mbox{K-PLUS}}. it would be better, usually, to deal with it in the main text: if we consider \mbox{K-PLUS} then ... – barbara beeton May 17 '16 at 16:25
  • 1
    thanks! i've put \newcommand{\KPLUS}{\mbox{K-PLUS}\ } otherwise there is no space afterwards – Valerio May 17 '16 at 19:00
  • 1
    @Valerio -- that will always put a space after "K-PLUS", even if it is followed by a period or comma. the xspace package is meant for use in such situations (although it's overkill, and not recommended by some high-profile users); look for information by searching in this site. – barbara beeton May 17 '16 at 19:24
  • 1
    @CiprianTomoiagă -- no, anything in an \mbox is by definition unsplittable. if you did this: \newcommand{\KPLUS}{K-PLUS} without the box, it would be splittable. the \mbox needs to be applied just at the point where a break at a hyphen is not wanted. – barbara beeton Feb 25 at 14:51

Put it in a box:

\mbox{thatshouldnot}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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