3

I want to color an exponent differently than its base. I'm trying to do it as shown below, which displays correctly in the editor I'm using, but my screenreader will not read it.

The problem is something to do with how I am bracketing for the color of the exponent. Perhaps it's not possible to set it separately like I'm trying to do? Is there something wrong in the way I've bracketed for the color of the exponent? Or is this a MathJax issue, with the engine not being able to interpret a colored exponent?

 \textcolor{darkred}{3}\textcolor{blue}{^{4}} =\textcolor{darkred}{3\cdot 3\cdot 3\cdot 3}=81
1

2 Answers 2

3

You asked,

Is there something wrong in the way I've bracketed for the color of the exponent?

You should replace

\textcolor{blue}{^{4}}

with

^{\textcolor{blue}{4}}

enter image description here

\documentclass{article}
\usepackage{xcolor} 
\begin{document}
$\textcolor{red}{3}^{\textcolor{blue}{4}} 
=\textcolor{red}{3\cdot 3\cdot 3\cdot 3}
=81$
\end{document}
0
2

I'm not entirely certain what you mean regarding your screenreader issue, but unless you have some compelling reason not to, you ought typeset this in math mode. I suspect that this might also resolve that issue.

xcolor can work in math mode and can be conveniently used as shown in a similar answer, from which the below is adapted. Note that unlike back then, as pointed out by David Carlisle, \mathcolor is now built into xcolor.

\documentclass{article}

\usepackage{xcolor}


\begin{document}

   \[
      \mathcolor{red}{3}^{\mathcolor{blue}{4}} \mathcolor{black}{=} \color{red}{3 \cdot 3 \cdot 3 \cdot 3} \mathcolor{black}{= 81}
   \]

\end{document}

This produces:

A screenshot of the (pdflatex) compiled output of the above LaTeX code.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.