16

I have a presentation with the color for math changed to blue:

\setbeamercolor{math text}{fg=black!15!blue}

Everything looks nice, until I want to recolor part of an equation:

\begin{align*}
   x\ y\ z &: A  \color{red}\longleftarrow \text{Assumptions}\\
   \hline
   x &\in \color{red}\underbrace{[x,y,z]}_{\text{Goal}}
\end{align*}

Then it just goes bananas: half of the left arrow is printed in blue, and the brace is totally printed in blue.

Any help will be appreciated.

The entire code:

\documentclass{beamer}
\setbeamercolor{math text}{fg=black!15!blue}

\begin{document}
\begin{frame}
   \begin{align*}
      x\ y\ z &: A  \color{red}\longleftarrow \text{Assumptions}\\
      \hline
      x &\in \color{red}\underbrace{[x,y,z]}_{\text{Goal}}
   \end{align*}
\end{frame}
\end{document}
  • Interesting question. Workaround before the proper solution is found: \mathrel{\text{\color{red}$\longleftarrow$}} and \text{\color{red}$\underbrace{[x,y,z]}_{\text{Goal}}$} – yo' Mar 20 '15 at 16:05
  • Thanks yo', David, and Joseph. I like David's version better, but thanks Joseph for the nice explanation! – Beta Mar 21 '15 at 17:04
10

enter image description here

\documentclass{beamer}
\setbeamercolor{math text}{fg=black!15!blue}

\newcommand\beamermathcolor[1]{\color{#1}\setbeamercolor{math text}{fg=#1}}
\begin{document}
\begin{frame}
   \begin{align*}
      x\ y\ z &: A  \beamermathcolor{red}\longleftarrow \text{Assumptions}\\
      \hline
      x &\in \beamermathcolor{red}\underbrace{[x,y,z]}_{\text{Goal}}
   \end{align*}
\end{frame}
\end{document}
9

As an alternative to David's answer, you could reset \everymath here

\documentclass{beamer}
\setbeamercolor{math text}{fg=black!15!blue}

\begin{document}
\makeatletter
\begin{frame}
   \begin{align*}
     \global\everymath{}
      x\ y\ z &: A \color{red}\longleftarrow \text{Assumptions}\\
      \hline
      x &\in \color{red}\underbrace{[x,y,z]}_{\text{Goal}}
   \end{align*}
  \global\everymath{\beamer@setmathcolor}
\end{frame}
\makeatother
\end{document}

The oddness happens becuase the math color is applied via \everymath, and if you trace through the code some bits of the 'text' use math mode. For example \longleftarrow is made up of various parts, some in math mode and some not.

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.