## LaTeX forum ⇒ Math & Science ⇒ Why is command \textendash invalid in math mode?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
yaozhao
Posts: 55
Joined: Sat Oct 27, 2018 10:38 pm

### Why is command \textendash invalid in math mode?

$Q_O^D = 75 – 5 P_O + P_C + 2I$

Overleaf gives command \textendash invalid in math mode on input line 34.
(34 is the line of this code in my file)

But it can still give my pdf. Why is this warning? What's the meaning? Should I just ignore it?

Ijon Tichy
Posts: 392
Joined: Mon Dec 24, 2018 10:12 am
The warning message is, because you've used an endash: –, instead of a minus: -, in your equation. You should not ignore the message, but change your equation like here:
\documentclass{article}\begin{document}    $Q_O^D = 75 - 5 P_O + P_C + 2I$\end{document}

BTW: Please always post a minimal working example instead of a code snippet. (Note: Because of the one line code snippet, I've made my own MWE for my first studies and just input the one line instead of copying it with the result, that I had no error or warning. With a real MWE I've never hit on the idea to not copy your code. So one more reason for real MWEs.)

yaozhao
Posts: 55
Joined: Sat Oct 27, 2018 10:38 pm
I see. Yes, after using your code, the warning message disappeared. But how to type minus in my Mac?

yaozhao
Posts: 55
Joined: Sat Oct 27, 2018 10:38 pm
\documentclass{article}\usepackage{amsmath}\begin{document}\begin{align*} Q_O^D &= 75 – 5 P_O + P_C + 2I \\ Q_O^D &= 75 – 5 P_O + 5 + (2\times 10) \end{align*}\end{document}

Overleaf gives command \textendash invalid in math mode on input line 34.
(34 is the line of \end{align*})

But it can still give my pdf. Why is this warning? What's the meaning? Should I just ignore it?

Ijon Tichy
Posts: 392
Joined: Mon Dec 24, 2018 10:12 am
Depends on the keyboard layout/locale. AFAIK on a German or US keyboard type the - one time without AltGr or similar modifier key.

Ijon Tichy
Posts: 392
Joined: Mon Dec 24, 2018 10:12 am
Please don't open a new thread for the same question. If you have additional information (like a minimal working example) add them to the already existing question (or a new posting at the thread of that question).

yaozhao
Posts: 55
Joined: Sat Oct 27, 2018 10:38 pm
Not the same question. The problems are different.

Ijon Tichy
Posts: 392
Joined: Mon Dec 24, 2018 10:12 am
No, it's exactly the same. Again, you've used – instead of -. With - it works:
\documentclass{article}\usepackage{amsmath}\begin{document}\begin{align*} Q_O^D &= 75 - 5 P_O + P_C + 2I \\ Q_O^D &= 75 - 5 P_O + 5 + (2\times 10) \end{align*}\end{document}

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
I have merged both topics as they are essentially the same post.
site moderator & package author