1

On page 5 of the book The TeXbook, there is

If your keyboard does not contain a left-quote symbol, you can type \lq, followed by a space if the next character is a letter, or followed by a \ if the next character is a space. Similarly, \rq yields a right-quote character. Is that clear?

\lq\lq I understand.\rq\rq\ (the last character is a space)

enter image description here

There are two things confusing me:

  1. Why add a space at the end of the text?
  2. What is the difference between and \ , that is space vs \space
egreg
  • 1,121,712
Y. zeng
  • 1,885
  • Explicit spaces are gobbled after control sequences. If you just typed ...\rq\rq (... then the parenthesis would be attached to the right-quote. – campa Oct 26 '23 at 13:31
  • @campa But in the book, there is nothing after the \. – Y. zeng Oct 26 '23 at 13:33
  • There is a space. – campa Oct 26 '23 at 13:33
  • @campa Okay. Now I know that if there isn't \, the space will no longer exist there. But is there a difference between space and \space? – Y. zeng Oct 26 '23 at 13:35
  • To address your second question: Do you understand the difference between \lq\lq I understand and \lq\lq\ I understand? – Mico Oct 26 '23 at 13:36
  • @Mico No, I guess there is difference but I don't know. – Y. zeng Oct 26 '23 at 13:36
  • 1
    That's explained on page 8 :-) Keep reading! – campa Oct 26 '23 at 13:37
  • @campa I will learn that tomorrow. I hope I can understand it tomorrow. – Y. zeng Oct 26 '23 at 13:38
  • In the former case, there will be no whitespace between the quotation characters and the word "I". In the latter case, there will be a space, because "\" tells TeX to, well, insert a space. – Mico Oct 26 '23 at 13:39
  • @Mico The former case and the latter case are all refer to the last character in \lq\lq I understand.\rq\rq\, so there are always a whitespace between the quotation characters and the word "I". – Y. zeng Oct 27 '23 at 10:43
  • @Y.zeng - No! There will be whitespace between the opening quotes (generated by \lq\lq) and the word "I" only if you change \lq\lq I understand to either \lq\lq\ I understand or \lq\lq\space I understand. – Mico Oct 27 '23 at 11:30
  • @Mico Yes. I was confused before. What is the latter case? I have one case in the question. – Y. zeng Oct 27 '23 at 11:36

1 Answers1

3

When converting the input into tokens (which is what TeX really works with) TeX will ignore spaces following a control word, that is, a control sequence starting with a backslash followed by letters, see Space after LaTeX commands

If you input

\rq\rq (the last character is a space)

there will be no space between the closing double quote and the parenthesis when you look at the printout.

You can obviate the problem in two ways

\rq\rq\ (the last character is a space)
\rq\rq{} (the last character is a space)

They have pros and cons. Look at the difference between

Donald said \lq\lq Good-bye.\rq\rq\ After that he left.

Donald said \lq\lq Good-bye.\rq\rq{} After that he left.

enter image description here

Do you see what happens? In the first case, the period is not considered as sentence ending, as it should. This is because \ (backslash space) resets the space factor to 1000, besides inserting a space. In the second case this doesn't happen, because {} doesn't influence the space factor.

Of course the input

Donald said ``Good-bye.'' After that he left.

doesn't suffer from the problem.

What's the difference between an explicit space (that survives tokenization) and \space? That the latter is a macro expanding to an explicit space. So you might do

Donald said \lq\lq Good-bye.\rq\rq\space After that he left.

and you'd get the same as with {}.

Note. Answers at the linked post about spaces after commands suggest \xspace: don't use it (besides, it isn't available in plain TeX).

egreg
  • 1,121,712
  • Thanks. There are some question confusing me:
    1. Why \ will reset space factor but \space won't?
    2. If the space factor to 1000 is not the sentence ending, what number is the sentence endning?
    3. How did you know the 1000 and what is its meaning?
    – Y. zeng Oct 27 '23 at 10:52
  • 1
    @Y.zeng Backslash-space resets the space factor to 1000 because Knuth so decided; on the other hand, \space is (mostly) equivalent to typing a space, so no reset of the space factor happens. You should read more about the space factor in TeX by Topic or the TeXbook: it's well explained. – egreg Oct 27 '23 at 12:04
  • Okay. I am reading that book very slowly to understand it. – Y. zeng Oct 27 '23 at 12:26