# Quotes ignored by pdftex

I'm reading the TeXBook by Donald Knuth, exercise 2.1. I have the following input:

Alice said, ‘‘I always use an en-dash instead of a hyphen when specifying page numbers like ‘480--491’ in a bibliog
raphy.’’
\bye


Compiling using pdftex sample.tex gives the following output. The en-dash works but where are the quotes gone?

• I don't know how to edit the question but the last double quotes isn't correct it should be ’’ not ”. It doesn't solve my problem anyway. – Alexis816 Mar 7 at 15:31
• I edited your question for you. There is the "edit" button under the tags. – user156344 Mar 7 at 15:41
• use  and '' not ‘‘ and ’’ (either works in latex, but not in plain, without further definitions) – David Carlisle Mar 7 at 16:13

Instead of the curly quotes ‘‘ and ” use

I always use an en-dash instead of a hyphen when specifying page numbers
like 480--491' in a.''
\bye


• Thank you, it was not obvious at all to me (and it's not the answer given in the book I have, maybe it's an old edition). – Alexis816 Mar 7 at 15:41
• @Alexis816 I did not look in the book, but that's what is in the source code of the book: ctan.org/tex-archive/systems/knuth/dist/tex/texbook.tex – user36296 Mar 7 at 15:46
• @Alexis816 It is the answer in the book, but the book is set in a font in which  and ' look more curly than on this site. – David Carlisle Mar 7 at 16:16

If you look at the source code of the TeXbook, which is available on CTAN, you see

\exercise Explain how to type the following sentence to \TeX: Alice said,
I always use an en-dash instead of a hyphen when specifying page numbers
like 480--491' in a ^{bibliography}.''
\answer |Alice said, I always use an en-dash instead of a hyphen when|\break
|specifying page numbers like 480--491' in a bibliography.''| \
(The wrong answer to this question ends with |'480-49l' in a bibliography."|)


If you compile with pdftex the code

Alice said, I always use an en-dash instead of a hyphen when specifying
page numbers like 480--491' in a bibliography.''
\bye


then copy-paste from the PDF, you get

Alice said, “I always use an en-dash instead of a hyphen when specifying page numbers like ‘480–491’ in a bibliography.”

because PDF readers are smart enough.

However, you should not use ‘‘ and ’’, because the characters in the code snippets in the TeXbook actually stand for

 ''


Remember that TeX is only using seven bit ASCII characters, whereas ‘ and ’ are not in that range in any encoding.

When TeX and The TeXbook were written, computers and software were different in two ways from presently:

1. Each computer / OS had fewer characters (usually at most 256) than the full range of Unicode available today; in particular the curly quotes you entered namely ‘ (U+‎2018 LEFT SINGLE QUOTATION MARK) and ’ (‎U+2019 RIGHT SINGLE QUOTATION MARK) weren't in their character sets,

2. Instead some systems, including the ones Knuth was familiar with, used the positions currently occupied by  (U+0060 GRAVE ACCENT) and ' (U+0027 APOSTROPHE) for characters that used to appear visually symmetric and served the same purpose. This history is well explained in the page ASCII and Unicode quotation marks by Markus Kuhn (scroll down to "The problem") and also in the upquote package.

Correspondingly, the result is that:

1. If you enter non-ASCII characters into TeX, it will misunderstand them and (a serious design flaw IMO) not even complain loudly: you have to look in the .log file. To avoid this happening by accident,

• Put \tracinglostchars=2 at the top of all files (and use an eTeX-derived engine; the pdftex you're using is fine), and/or

• Always look in the .log file whenever TeX says "(see the transcript file for additional information)"

2. When you see what looks like curly quotes in The TeXbook, you should understand it (and type it) as  and ' even though this is clearly wrong according to Unicode and modern fonts -- treat it as a quirk of those fonts.

Bonus: if you just want to use Unicode characters and not bother with the old hacks for achieving things like double quotes and en-dashes using ligatures of ASCII characters, you can use a Unicode engine like XeTeX or LuaTeX. Here's a file that works for the example here; compile with xetex or luatex:

\tracinglostchars=2
% \input luaotfload.sty % Uncomment this line if using LuaTeX
\font\tenrm="[lmroman10-regular]" at 10pt
\rm
Alice said, “I always use an en-dash instead of a hyphen when specifying
page numbers like ‘480–491’ in a bibliography.”
\bye
`

(Of course then you have to actually remember to use an en dash instead of a hyphen, and also when editing the input file be using a font in which you can easily tell the difference.)