[OS X TeX] colorbox

Peter Dyballa Peter_Dyballa at Web.DE
Wed Jul 30 12:04:07 EDT 2008


Am 30.07.2008 um 14:03 schrieb Alain Schremmer:

> In general, I want to be able to highlight specific spots in  
> mathematical expressions.

If it's just the arguments, an operator, a function name, then it's  
easy: \colorbox{yellow}{<the stuff>}. But when you're going to high- 
light a part a compound like \dfrac{}{}, then I'd use a local re- 
definition, \dfracol{}{}{colour}, to colourise the fraction stroke.  
This way automatically an appropriate area will filled with colour.

\dfrac is defined in amsmath.sty as:

	\newcommand{\dfrac}{\genfrac{}{}{}0}

and \genfrac is there defined as:

	\DeclareRobustCommand{\genfrac}[4]{%
	  \def\@tempa{#1#2}%
	  \edef\@tempb{\@nx\@genfrac\@mathstyle{#4}%
	    \csname @@\ifx @#3 at over\else above\fi
	    \ifx\@tempa\@empty \else withdelims\fi\endcsname}
	  \@tempb{#1#2#3}}

which introduces \@genfrac defined as:

	\def\@genfrac#1#2#3#4#5{{#1{\begingroup#4\endgroup#2#3\relax#5}}}

\genfrac seems to use something like \over or \above, depending on  
the third argument of \dfrac/\genfrac, and this name is changed in  
the presence of a fourth non-zero argument to \overwithdelims or  
\abovewithdelims. These are defined as:

	\renewcommand{\over}{\primfrac{over}}
	\renewcommand{\above}{\primfrac{above}}
	\renewcommand{\overwithdelims}{\primfrac{overwithdelims}}
	\renewcommand{\abovewithdelims}{\primfrac{abovewithdelims}}

So the proper function might be \primfrac, which is:

	\DeclareRobustCommand{\primfrac}[1]{%
	  \PackageWarning{amsmath}{%
	Foreign command \@backslashchar#1;\MessageBreak
	\protect\frac\space or \protect\genfrac\space should be used instead%
	\MessageBreak
	  }
	  \global\@xp\let\csname#1\@xp\endcsname\csname @@#1\endcsname
	  \csname#1\endcsname
	}

*I* can't see how the fraction is constructed. And so I can't tell  
where to insert a \colorbox{colour}{} ... Could be \@tempa and  
\@tempb are doing some work.

--
Greetings

   Pete

Real Time, adj.:
	Here and now, as opposed to fake time, which only occurs there and  
then.






More information about the MacOSX-TeX mailing list