3

I use a macro which just wraps its argument in a pair of delimiters (brackets). It interferes with the way LaTeX would normally wrap an inline math expression. The following illustrates:

\documentclass{article}

\newcommand{\collapse}[1]{\{{#1}\}}
\newcommand{\apply}[2]{#1[#2]}

\begin{document}
Here's a regular paragraph to indicate the point at which text would
normally wrap.

word word word word word word word word word word word word $\collapse{\apply{(T + T')}{D + D'}} > C$,
\end{document}

I don't want the {(T + T )[D + D ]} > C to run off the edge of the page but rather to wrap onto the next line. If I inline the 'collapse' macro, then indeed it wraps as one would expect.

Is this easy to achieve whilst still retaining my 'collapse' macro? I have tried /allowbreak, but with no success.

This is probably relevant: Line break in macro

Roly
  • 4,221
  • 4
  • 26
  • 56

1 Answers1

4

Remove the grouping in your definition of \collapse. {...} is not neutral in math mode, it says the enclosed expression must not be broken over lines.

Sample output

\documentclass{article}

\newcommand{\collapse}[1]{\{ #1 \}}
\newcommand{\apply}[2]{#1[#2]}

\begin{document}
Here's a regular paragraph to indicate the point at which text would
normally wrap.

word word word word word word word word word word word word $\collapse{\apply{(T + T')}{D + D'}} > C$,
\end{document}
Andrew Swann
  • 95,762