15

Is there a reason to use the style like:

\def\xx{foo}
\let\yy = \xx

instead of:

\def \xx{foo}
\let \yy = \xx

I'm new to TeX, but everyone seems to prefer the former, while I think the latter looks more natural and readable.

Alice
  • 153
  • 2
    In earlier times disk space was limited, so omitting the white space character reduced the size of files. After reading some TeX files it's quite usual not missing the white space ;-) –  Dec 07 '15 at 18:27
  • 1
  • @ChristianHupfer Wow, that was really unexpected! But seriously, my eyes hurt when I see the code full of control sequences and no spaces(I was trying to read Appendix B of The TeXbook before posting this question). – Alice Dec 07 '15 at 18:42
  • 1
    @Alice: Nowadays, it's a matter of personal style only and as such 'opinion-based' –  Dec 07 '15 at 19:11
  • 1
    @Alice you can use all the space you need within your code for improve the readability of your code. It's a personal choice (as Christian said). I use also indentation in nested environments (meanly with large lists with many levels) , it's useful for me. But be careful and don't add space between the LaTeX commands and its arguments or options for avoid errors. – Aradnix Dec 07 '15 at 20:01
  • @Alice As others said, de gustibus non est disputandum. Unlike you, I prefer \def\xx{foo} because are related control sequences that I regard as one "order", whereas I do not like join unrelated commands as \thispagestyle{empty}\color{red}\small (but here I prefer line breaks instead of spaces) although may be is not so bad format when the lines of code are distracting and you want to focus only in the contents, not in the surrounding code. – Fran Dec 09 '15 at 12:56

1 Answers1

12

TeX allows both styles; you can type

\def\xx{foo}
\def\xx {foo}
\def \xx {foo}
\def \xx{foo}

\let\yy=\xx
\let\yy =\xx
\let\yy = \xx
\let\yy= \xx

But also

\let\yy\xx

In the case of \def\xx, you take advantage from the fact that spaces after control words are ignored during tokenization. However,

\def\?{foo}
\def\? {foo}

would be different, because spaces are not ignored after control symbols.

For \let is the same, plus the fact that TeX allows <one optional space> after the equals sign, which is itself optional. Stick to your own style, provided it's syntactically sound.

It's a question of habits, mostly. My eyes bleed when I see dramatic indentation in C programming style.

egreg
  • 1,121,712