0

I would like to setup a command for adding inline math in text paragraphs. In that command, I want to change some style properties, like change the color of the equation. Fox example:

The value of $x = 2 + 3$ is $x=5$.

I would like to do.

 The value of \Mimath{x = 2 + 3} is \Mimath{x=5}.

I through I could start with something like this:

\newcommand*\Mimath[1]{ $ #1 $ }

But that gives an error in TexStudio:

Undefined control sequence. ...lection of objects whatsoever. A set \Mimath

How can I create that type of command?

Dess
  • 103
  • 1

2 Answers2

1

This works for me, I hope for you too:

\documentclass[12pt]{article}
\usepackage{xcolor}
\newcommand*\Mimath[2][black]{{\color{#1} $ #2 $}\color{black} }

\begin{document} The value of \Mimath[red]{y=x+5}

The value of \Mimath[blue]{y=x+5}

The value of \Mimath[magenta]{y=x+5}

The value of \Mimath{y=x+5} \end{document}

output

miltos
  • 2,605
0

You can use \everymath{\color{blue}}. Here is a minimimal working example:

\documentclass{amsart}
\usepackage{xcolor}

\everymath{\color{blue}} \begin{document}

The value of $x = 2 + 3$ is $x=5$.

[ \int2x,dx=x^2+C ]

\end{document}

that produces:

enter image description here

As the MWE shows, this colours only inline mathematics. If you want to colour displayed equations as well use \everydisplay{\color{blue}}.