LaTeX forum ⇒ Math & ScienceWhy 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?

Postby yaozhao » Mon Sep 02, 2019 5:02 am

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \[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?

User avatar
Ijon Tichy
Posts: 269
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Mon Sep 02, 2019 8:36 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:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \begin{document}
  3. \[Q_O^D = 75 - 5 P_O + P_C + 2I\]
  4. \end{document}

BTW: Please always post a Infominimal 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

Postby yaozhao » Mon Sep 02, 2019 1:14 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

Postby yaozhao » Mon Sep 02, 2019 1:22 pm

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4. \begin{align*}
  5. Q_O^D &= 75 – 5 P_O + P_C + 2I \\
  6. Q_O^D &= 75 – 5 P_O + 5 + (2\times 10)
  7. \end{align*}
  8. \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?

User avatar
Ijon Tichy
Posts: 269
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Mon Sep 02, 2019 1:31 pm

Depends on the keyboard layout/locale. AFAIK on a German or US keyboard type the - one time without AltGr or similar modifier key.

User avatar
Ijon Tichy
Posts: 269
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Mon Sep 02, 2019 1:35 pm

Please don't open a new thread for the same question. If you have additional information (like a Infominimal 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

Postby yaozhao » Mon Sep 02, 2019 2:28 pm

Not the same question. The problems are different.

User avatar
Ijon Tichy
Posts: 269
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Mon Sep 02, 2019 2:32 pm

No, it's exactly the same. Again, you've used instead of -. With - it works:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4. \begin{align*}
  5. Q_O^D &= 75 - 5 P_O + P_C + 2I \\
  6. Q_O^D &= 75 - 5 P_O + 5 + (2\times 10)
  7. \end{align*}
  8. \end{document}

User avatar
cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Mon Dec 30, 2019 1:31 pm

I have merged both topics as they are essentially the same post.
site moderator & package author


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 0 guests