TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The command \nolinebreak[4], if placed between two characters, should prevent a line break from appearing in that location. This command does not seem to be defined in ConTeXt. Is there an equivalent for this in ConTeXt, or for plain TeX which is also compatible with ConTeXt?

share|improve this question
up vote 4 down vote accepted

In plain TeX there is \nobreak, equivalent to \penalty 10000. In ConTeXt, it's the same (defined in the file spac-ver.mkiv).

share|improve this answer
This seems to have no effect, if placed after a macro. E.g. \macro{Some text}\nobreak A. How is this done after a macro? – Village Apr 7 '12 at 8:40
@Village: probably doesn't depend on there being a macro: with \def\macro#1{#1} you get the same as Some text\nobreak A. What macro are you testing with? – Bruno Le Floch Apr 7 '12 at 9:07
If you \macro ends with e.g. a skip, you might need to either redefine it, or say e.g. \def\reallynobreak{\unskip\penalty 10000} – mbork Apr 7 '12 at 9:46

The definition of \nolinebreak in LaTeX is, skipping over the details,


The first conditional simply issues an error if \nolinebreak is found in vertical mode. In horizontal mode it stores the last skip (if there isn't one the stored value is zero) and removes it (if present). Then a penalty of 10000 is issued and the skip is reinstated.

Just use a temporary skip register instead of \@tempskipa, for instance \skip8. If you need the full syntax \nolinebreak[<number>] then something more complicated has to be used.

    \penalty\ifcase#1 0 \or 2500 \or 5000 \or 7500 \or \@M\fi % change values at will
    \ifdim\skip8>\z@\hskip\skip8 \fi

The trick is that glue isn't a feasible for line breaking if it follows a penalty. For example, Plain TeX defines ~ as

\def~{\penalty\@M \ }

(where \@M stands for 10000).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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