# Why is \textendash invalid in math mode?

When editing the following document with Overleaf

\documentclass[a4paper, 12pt,fleqn]{article}
\usepackage{amsmath}
\usepackage{breqn}
\usepackage[utf8]{inputenc}
\usepackage{indentfirst}

\title{Exercice sur les équations}

\begin{document}

\maketitle

\begin{align*}
12 + x &= 17 \\
12 \boxed{- 12} + x &= 17 \boxed{- 12} \\
x &= 5
\end{align*}

\begin{align*}
3x – 2 &= 17 \\
3x - 2 \boxed{+ 2} &= 17 \boxed{+ 2} \\
3x &= 19
\end{align*}

\end{document}


I get the expected output

but there is a warning (at least I think this is a warning due to the yellow triangle)

Is this something serious?

(I apologize if this is obvious, I am back to LaTeX after 20 years trying to help my children with the formatting of their homework after seeing with disgust what they were about to send to the teacher (we are in France, confined at home))

• You shouldn't use – (U+2013) for the minus sign, but a simple hyphen. – egreg Mar 28 '20 at 18:26
• The problem is the first line of the second align. There the minus is actually a endash: 3x – 2 &= 17 change this to 3x - 2 &= 17  – Ulrike Fischer Mar 28 '20 at 18:27
• @UlrikeFischer: thank you. This is a copy/paste from the horrendous WordPad text my son was working on and I did not realize that hyphens are not hyphens. – WoJ Mar 28 '20 at 18:31
• @egreg: thank you - please see my comment to Ulrike – WoJ Mar 28 '20 at 18:32

The problem is that a character U+2013 (en-dash) is used instead of a minus sign U+2212 is used (or just a hyphen). This happens when people doesn't know the difference.

I also propose some enhancements to your code, adding \: in appropriate places to emulate the spacing that TeX would insert if \boxed were not here.

\documentclass[a4paper, 12pt,fleqn]{article}
\usepackage{amsmath}
%\usepackage{breqn}
%\usepackage[utf8]{inputenc}
\usepackage{indentfirst}

\title{Exercice sur les équations}

\begin{document}

\maketitle

\begin{align*}
12 + x &= 17 \\
12\: \boxed{-\:12} + x &= 17\: \boxed{-12} \\
x &= 5
\end{align*}

\begin{align*}
3x - 2 &= 17 \\
3x - 2\: \boxed{+\:2} &= 17\:\boxed{+\:2} \\
3x &= 19
\end{align*}

\end{document}


• I should also have noticed that the typesetting of "3x -2 = 17" was off. – WoJ Mar 28 '20 at 19:48
• What if I insist on using the character U+2013 (en-dash) in a maths formula? – Viesturs Jul 8 '20 at 13:57
• @Viesturs For what purpose? – egreg Jul 8 '20 at 14:53
• As a special symbol – Viesturs Jul 8 '20 at 16:13
• @Viesturs How are your readers supposed to catch the difference with a minus sign? Anyway, \text{\textendash} will work, if you deliberately want to be ambiguous. ;-) – egreg Jul 8 '20 at 17:07