# What's the difference between -- and \textendash?

It looks like -- and \textendash have different line-breaking behaviour in LaTeX. I'd assumed that they would just insert an en dash character, and then act the same, but it looks like they don't from this example:

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

I'm going to write a really, really, really long numerical range: 10000000\textendash 20000000 which should overflow the justification box, which you can see from my continued typing below the above line.

I'm going to write a really, really, really long numerical range: 10000000--20000000 which should overflow the justification box, which you can see from my continued typing below the above line.

% This paragraph uses an en dash character directly
I'm going to write a really, really, really long numerical range: 10000000–20000000 which should overflow the justification box, which you can see from my continued typing below the above line.

\end{document}


Why is this the case, and are there any other differences I should be looking out for?

Note that inserting an en dash directly (the last paragraph) also seems to act like \textendash, which makes me wonder if -- is truly an en dash?

• -- are two hyphens, which are later on converted as a ligature into the en-dash glyph used by \textendash. In pdflatex this happens after it has decided that hyphenation is allowed after a hyphen. In lualatex the behaviour is different. Jun 17, 2021 at 9:49
• @UlrikeFischer aha! That's good to know — if you post as an answer, I'd be happy to accept.
– Alec
Jun 17, 2021 at 9:50
• Another difference is that -- is easier to type, easier to read for humans but also exportable asis with the traditional copy & paste method to LibreOffice and rmarkdown, (relevant if collaborators are not LaTeX fans, for instance).
– Fran
Jul 9, 2021 at 7:40

With --, there is a feasible break points, because the ligature ends with the default hyphen character. (Pedantic note: this happens only if the \hyphenchar parameter for the current font is the hyphen.)
On the other hand, \textendash is essentially equivalent to \char21 and since this has nothing to do with the hyphen character, no break point is present after it. The same happens if you type – U+2013, because in pdflatex this is converted to \textendash.
• So, -- is the advised thing to type? Jun 17, 2021 at 14:42