6

Replacing the equality symbol with a space below or omitting the symbol at all

\documentclass{article}
\pagestyle{empty}
\usepackage{lipsum}
\begin{document}
\interlinepenalty=10000
% or \interlinepenalty 10000 or \interlinepenalty10000
\lipsum[1-6]
\end{document}

does not change the result: the page breaks inside paragraphs are prohibited in any case. Why the three syntax options? What's the difference?

  1. Is there a situation in which only = works?

  2. Is there a situation in which only the space works?

  3. Is there a situation in which only the juxtaposition works?

  • 1
    The alternatives are all permitted and supported by TeX itself; the difference is cosmetic. This is a design decision by TeX's creator, and I don't know that the reasoning has been stated. What is important though is that the numeric (or in some similar situations dimension) value must be cleanly terminated. In the case of a single numeric, a space is sufficient; \relax also suffices. and is better if a dimension is involved. If a control sequence ("command") follows with no space, TeX will keep on, looking for something that might resolve to a numeric value. – barbara beeton Apr 29 '20 at 17:16
  • 1
    For more info, see the TeXbook p. 276 (also p. 272 which says \interlinepenalty is an 〈integer parameter〉). – frougon Apr 29 '20 at 17:18
  • 〈simple assignment〉, 〈variable assignment〉, 〈integer variable〉. The 〈equals〉 used in 〈variable assignment〉 is defined on p. 275. Your assignment is a 〈variable assignment〉, which is one of the possible forms of a 〈simple assignment〉. The production rules for 〈variable assignment〉 and 〈equals〉 answer your question (except for the space skipped after \interlinepenalty: this happens earlier, at the tokenization stage, and is described on p. 46). – frougon Apr 29 '20 at 18:14
  • 2
    @Just_A_Man -- % is absolutely not a terminator! An % simply says "end this input line right here and (for all practical purposes) attach the start of the next line to what has just been ended. In fact, % is quite dangerous when it immediately follows a numeric value or dimension. A numeric value followed by a space followed by % is okay (the space terminates the numeric value). The situation is more complicated when a line ending with a dimension is terminated by a %, but that's a different question. – barbara beeton Apr 29 '20 at 18:26
  • 1
    @Just_A_Man --- "1010 text", exactly. (An extended disquisition on % is at What is the use of percent signs (%) at the end of lines?.) – barbara beeton Apr 29 '20 at 18:36

3 Answers3

10

There is no difference. The syntax for a primitive tex assignments allows an option = (and optional space)

Note that

 \interlinepenalty 10000 or \interlinepenalty10000

are the same for a different reason, the space after a command name is never tokenized at all it just terminates the command so these make the same tokens.

Conversely

\interlinepenalty= 10000 

the space after = is tokenized but is ignored as the assignment absorbs optional equals optionally followed by a space.

David Carlisle
  • 757,742
  • 2
    Nice explication of the three options. But you don't say why DEK designed TeX this way. (Maybe, like me, you can't think of anyplace he may have answered that question.) – barbara beeton Apr 29 '20 at 17:29
  • @barbarabeeton can't look into his head but it's easier to see with \let as \let\foo= allows you to terminate the \foo token without gobbling a space. – David Carlisle Apr 29 '20 at 17:34
  • Trying to be clear: regarding the last sentence of the answer, my reading of the TeXbook pp. 269 and 275 tells me that the space token following the = is absorbed not because it is preceded by =, but because TeX reads a 〈number〉 after the = sign in this case, and 〈number〉 starts with 〈optional signs〉 which starts with 〈optional spaces〉 (what I really mean is that 〈equals〉 does not, in itself, absorb any space token after the = sign). – frougon Apr 29 '20 at 17:45
  • @frougon yes (but I chose in this answer to aim for a top level description in English rather than reference the formal grammar) – David Carlisle Apr 29 '20 at 19:01
7

David C. explained that there is no differences between these three alternatives because of TeX syntax rules (the optional =) or because of the toknizer outputs the same result in case 2 and 3. But you have asked why? The reason is: The optional = is used because this is more understandable by humans. In old days (when TeX was born) each byte was counted. So: the = was not used in the macro bodies because these token strings must be saved into the memory. But this optional = was used outside macro bodies. Today, there is no such memory limitations, the usage of = is recommended.

Your second question: is there any case when = cannot be used. Yes. If the syntax context is not assignment. For example \penalty 10000. The primitive command \penalty is not primitive register, so this is not assignment but this is command to do something in vertical or horizontal list. You cannot use = here.

My last comment: the optional = may have optional space around it (one space left and one right of the =. So, \interlinepenalty= 10000 is also possible. And

\interlinepanalty       =     10000

is also possible, because there is no space before = and only one space after the = character because the tokenizer converts this to \interlinepenalty= 10000.

wipet
  • 74,238
  • @Just_A_Man The big memory wasting issue related to TeX today is derived from Knuth's decision that hyphenation patterns are not possible load on demand when document is processed. Thus: there are plenty .fmt files generated in the TeX distribution, each of them includes all hyphenation paterns of all languages because: maybe sometimes a document will need this special language... Only LuaTeX overcomes this limitation and enables to load the hyphenation patterns on demand. – wipet Apr 29 '20 at 20:00
  • @wipet The = is not optional to save memory, but to reduce the number of \expandafter that are needed in things like \expandafter\interlinepenalty\csname whatever\endcsname. – Henri Menke Jul 08 '20 at 05:04
  • @HenriMenke Better example is with \let primitive because your example is not so good: you can write \interpenalty=\csname whatever\endcsname without any \expandafter. Using less \expandafters is only a side effect. When we look at old macros (plain.tex, for example) then we see that all assignments done outside macro bodies are with = and all assignments used in macro bodies (where TeX must save it to its memory) are without =. – wipet Jul 08 '20 at 06:57
5

Unless I overlooked it within the answers given already, one open question remained: are there cases where the = is required? Yes, for example if you want to do

\let\foo $      % fine
\let\bar =      % incomplete
\let\baz !

In the above \bar will be let to \let and not to an equal sign, so you would need

\let\bar = =

(with or without the spaces). Even more tricky: \let something to a "space" token (exercise for the reader).