ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to create a breakable text box inside math equation?
@ 2011-05-06 14:50 Mojca Miklavec
  2011-05-06 20:33 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Mojca Miklavec @ 2011-05-06 14:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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?

Thanks a lot,
    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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to create a breakable text box inside math equation?
  2011-05-06 14:50 How to create a breakable text box inside math equation? Mojca Miklavec
@ 2011-05-06 20:33 ` Wolfgang Schuster
  2011-05-10 17:03   ` Mojca Miklavec
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2011-05-06 20:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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.

Wolfgang

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to create a breakable text box inside math equation?
  2011-05-06 20:33 ` Wolfgang Schuster
@ 2011-05-10 17:03   ` Mojca Miklavec
  0 siblings, 0 replies; 3+ messages in thread
From: Mojca Miklavec @ 2011-05-10 17:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-10 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 14:50 How to create a breakable text box inside math equation? Mojca Miklavec
2011-05-06 20:33 ` Wolfgang Schuster
2011-05-10 17:03   ` Mojca Miklavec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).