[Tex/LaTex] Error: Command \ invalid in math mode

macrosmath-mode

I am getting the following error:

Command \  invalid in math mode.

Why? Compilation ends but no PDF is created because of those errors.
This seems to be the problematic piece of code but I don't understand the error I'm getting:

\begin{equation}\label{eq:e211}
I_C = C \dfrac{dv_c}{dt} \xRightarrow{Em regime estacionário} I=I_C=C.0=0
\end{equation}

Best Answer

Please always post complete documents that show the error, and also show the exact error generated by TeX (the format you showed is not a tex error).

\documentclass{article}

\usepackage{amsmath}

\usepackage[utf8]{inputenc}

\begin{document}

\begin{equation}\label{eq:e211}
I_C = C \dfrac{dv_c}{dt} \xRightarrow{Em regime estacionário} I=I_C=C.0=0
\end{equation}

\end{document}

Produces

! Undefined control sequence.
l.10 I_C = C \dfrac{dv_c}{dt} \xRightarrow

If I change that to \Rightarrow I get

LaTeX Warning: Command \' invalid in math mode on input line 10.

! Please use \mathaccent for accents in math mode.

Which is I assume, the error you got.

Here you get a LaTeX warning (not an error) about \'{a} but then immediately get a lower level TeX error about the same issue. (Even though the text is entered as á inputenc converts this to traditional TeX markup of \'{a} as the rest of the system is not unicode-aware.

So in fact my initial comment on the question is the source of the error. Even without the error over á you should never use the math italic font for natural language words or multi-letter identifiers, it is designed to make adjacent letters not look like a word, but rather as a product of separate 1-letter identifiers.

This runs without error

\documentclass{article}

\usepackage{amsmath}

\usepackage[utf8]{inputenc}

\begin{document}

\begin{equation}\label{eq:e211}
I_C = C \dfrac{dv_c}{dt} \Rightarrow \text{Em regime estacionário}
\qquad I=I_C=C.0=0
\end{equation}

\end{document}

enter image description here

Related Question