# transforming character into rule in LaTeX

Daniel Molina lluvia at autistici.org
Tue Sep 8 17:37:25 CEST 2020

Dear all,

My original problem is to substitute any subformula with a rule of a
specific color. The problem I am facing is that techniques such as
creating a box as

\setbox\mybox=\hbox{$\m at th #1{#2}$}

and getting its dimensions do not work for cramped subformulas. I know
about \cramped in mathtools, but I do not know in advance when a cramped
subformula will be cramped since equations are arbitrary.

As a solution I thought in using a fake font which is equivalent to the
current one but with the full box filled with ink. It would be something
like transforming a character into a rule. I do not know how to do that.

Ideas?

Best regards,

Daniel

PS: This is what I coded until know, which works well except for cramped
subformulas (and the fact that subformulas are still printed over the
color box)

\def\mycolorphant#1#2{

\mathpalette\myauxcol at rphant{{#1}{#2}}

}

\def\myauxcol at rphant#1#2{

\mycol at rphant#1#2

}

\def\mycol at rphant#1#2#3{

\setbox\mycpbox=\hbox{$\m at th #1{#3}$}

\begingroup

\color{#2}

\color at block{\wd\mycpbox}{\ht\mycpbox}{\dp\mycpbox}

\endgroup

\box\mycpbox

}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20200908/16744706/attachment.html>