[tex-eplain] boxed formulas

Oleg Katsitadze olegkat at gmail.com
Tue Sep 12 11:24:05 CEST 2006


On Mon, Sep 11, 2006 at 06:05:42PM +0200, Juan Mari Alberdi wrote:
> I'm trying to frame displayed formulas but I can't fit the width of the
> frame to the width of the formula. The frame is always 'hsize' width.

A displayed formula occupies the whole column width,
therefore you get the wide box.  But you can pass an inline
formula and put \displaystyle in it.  To save typing, you
can define something like this:

  \def\dboxit#1{$$\boxit{\hbox{$\displaystyle #1$}}$$}%

\hbox is needed because the argument of \boxit is typeset in
vertical mode.  Without the \hbox, `$' would switch to
horizontal mode and TeX would start typesetting a paragraph,
therefore the width would again be \hsize.

Use it like this:

  The formula for the sum of the first $n$~terms of an
  arithmetic progression is:
  \dboxit{\sum_{i=1}^n a_i = {n(a_1+a_n)\over2}}

Hope this helps,
Oleg


More information about the tex-eplain mailing list