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?

2 Answers 2


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

  • 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, 2012 at 8:40
  • 1
    @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? Apr 7, 2012 at 9:07
  • 2
    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, 2012 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).

You must log in to answer this question.

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