What would be the easiest way to create a fraction whose bar can be coloured as desired? I know one can use the \genfrac{left-delim}{right-delim}{thickness}{mathstyle}{numerator}{denominator}
command but I can't seem to get. The following is a MWE (not so much if you can see):
\documentclass[letterpaper]{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\begin{document}
$\genfrac{}{}{0.4pt}{}{a}{b}$
\end{document}
UPDATE
Applying Herbert's solution below yields something weird. See below:
\documentclass[letterpaper]{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\def\Frac#1#2{ #1 \color{red}\above 0.4pt \normalcolor #2}
\begin{document}
$ \Frac{n+1}{n-1} $$\displaystyle \Frac{n+1}{n-1} $
\end{document}
Note the denominator of the second is of the same size as the first fraction.
Best Answer
Thanks to @Herbert, I was able to tap into the
amsmath
package documentation and come up with a modified version of the\frac
command definition. The documentation has the following:Hence the warning that LaTeX shouts out in @Herberts answer. The documentation continues by saying that
and defines
\frac
asThis where I modified the definition of
\frac
slightly to come up with the command\cbfrac
which stands forcolored bar fraction
just for my own reference. See the definition below:Here is MWE illustrating how it works:
Commenting the command
\Frac
removes the warning.