On Fri, May 6, 2011 at 22:33, Wolfgang Schuster wrote:
>
> Am 06.05.2011 um 16:50 schrieb Mojca Miklavec:
>
>> Hello,
>>
>> This is probably a very trivial question, but I'm not sure how TeX
>> works in that respect. I'm used to use a macro
>>   \def\unit#1{{\rm\ #1}
>> in constructs such as $1\unit{cm^2} \times 2\unit{cm}$. However I
>> figured out that the contents of \unit{} cannot be broken accross
>> lines, most probably because this becomes an hbox.
>>
>> Is there any simple workaround?
>
> \def\unit{\groupedcommand{\rm\ }{}}
>
> or
>
> \def\unit#1{\bgroup\rm\ #1\egroup}
>
> { and } are same as \begingroup and \endgroup in math mode and prevent and a 
> line break of the content.

Wow! Interesting. I never realized that {} prevents breaking in math mode.

However, your solution to replace {} with \bgroup\rm \egroup works,
but only if I replace it in the formula itself. If I change only the
definition, it still won't break (maybe because I use a pair of braces
already in \unit{cm+cm}).

But at least now I know how to solve the problem. I can still use an
explicit \rm instead of using \unit macro.

Another question: how should I signal an allowed break in math mode?
\penalty0 or is there some more sensible option? (\hskip doesn't seem
to have any effect at all.)

Thanks,
    Mojca
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to