Discretionary break (source code)

= Discretionary break

A \b[discretionary break] describes an optional <line breaking> choice whose printed material may depend on whether the break is selected. In <TeX>, `\discretionary{pre}{post}{none}` supplies material before a chosen break, after it, or in the unbroken case.<TeX source code by Donald E. Knuth>[disc_node: pre_break, post_break and replacement material]{ref}

For a purely mechanical example, `ab\discretionary{-}{X}{Y}cd` can produce `abYcd` without the break, or `ab-` followed on the next line by `Xcd` when it is selected. The arbitrary strings make all three branches visible. A common <hyphenation> case simply inserts a hyphen before the break and supplies no material afterward.

Each alternative has its own geometry. A <typesetting box> used only in the pre-break branch must contribute its width when that branch is tested. The <natural line width>, <typesetting glue> and <typesetting penalty> calculation must therefore use the selected representation. Treating the choice merely as an invisible marker could miss the width of the inserted hyphen.