Quantcast
Channel: Active questions tagged mathtools - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 122

How create a NewDocumentCommand with ^or _?, {}^{} instead of {}{}

$
0
0

How to create a new command with ^ or _ instead of [][][]{}{}? to be coherent/analogous with \overbracket{}^{}

Creating a new command for give color to \overbracket (mathtools package), I would like to write $\coverbracket[cyan]{x^2-2x+1}^{(x-1)^2}$ instead of $\coverbracket[cyan]{x^2-2x+1}{(x-1)^2}$

enter image description here

How could you code that?

\documentclass[14pt]{article}\usepackage{mathtools}\usepackage{xcolor}\NewDocumentCommand{\coverbracket}{o O{2pt} O{0.7ex} m m}{    \IfNoValueTF{#1}    {\overbracket[#2][#3]{#4}^{#5}}    {{\color{#1}\overbracket[#2][#3]{{\normalcolor{#4}}}^{#5}}}}\begin{document}Hello, $\overbracket{x^2-2x+1}^{(x-1)^2}$with color... $\coverbracket[cyan]{x^2-2x+1}{(x-1)^2}$\end{document}

P.D.- It´s a pity that many usefull packages have no color option. Example: mathtools, ulem, ...


Viewing all articles
Browse latest Browse all 122

Trending Articles