[OS X TeX] colorbox

Bruno Voisin bvoisin at me.com
Wed Jul 30 18:59:31 CEST 2008


Le 30 juil. 08 à 18:04, Peter Dyballa a écrit :

> 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.
>
> [...]

The following may have already been suggested, as I didn't follow this  
thread closely, but you can also simply use the declarative form  
\color{[...]} of color change (works indifferently in text or math),  
together with the fact that LaTeX maintains a color stack, as in:

\documentclass{minimal}
\usepackage{color,amsmath}

\setlength{\parindent}{0pt}
\setlength{\parskip}{\bigskipamount}

\begin{document}

Black fraction line:
$\dfrac{a}{b}$.

Yellow fraction line:
$\color{yellow}\dfrac{\color{black}a}{\color{black}b}$.

Clunky:
\colorbox{yellow}{\parbox[l][-2mm][t]{6.5mm}{\vspace{-4mm}$\dfrac{222} 
{333}$}}.

Non-clunky:
$\color{yellow}\dfrac{\color{black}222}{\color{black}333}$.

\end{document}

Just a request: if that kind of thing is meant for slide shows, please  
don't use yellow, impossible to see from more than a couple of meters  
away from the projection screen but unfortunately popular in  
Powerpoint presentations.

Bruno Voisin


More information about the macostex-archives mailing list