# What is the difference between assigning and \def

What is the syntax difference between these two assignments (basically)

\arraycolsep=1mm
\def\arraystretch{0.7}


What are the fundamental differences of the command \arraycolsep and \arraystretch because one cannot do

\arraystretch=2

• \arraycolsep is the symbolic name of a dimen register, whereas \arraystretch is a macro. Nov 30, 2015 at 17:50

\arraycolsep is a dimension register, i.e. holding 'lengths' and can be assigned with =

The symbolic name is used instead of remembering \dim... register names.

\arraystretch is a macro, which must be redefined and can hold any value, but it would be rejected at the point of expansion. You can't say \arraystretch=... however. The = syntax is restricted to TeX registers.

You can show the difference between 'apparently' similar LaTeX entities with the \meaning command:

\documentclass{book}

\begin{document}
\arraycolsep=1mm
\def\arraystretch{0.7}

\meaning\arraycolsep

\meaning\arraystretch
\end{document}

• huch, never heard of meaning :-) Nov 30, 2015 at 17:52
• ok so the second is macro and the first a dimension? (for my \dimen52) Nov 30, 2015 at 17:53
• @Gabriel: Yes, it's a short name for \dimen52, since this would be hard to remember and could even change if for example someone would use a different format.
– user31729
Nov 30, 2015 at 17:54
• You can also drop = when dealing with dimensions. Also, \setlength{...}{..} should work as expected.
– Werner
Nov 30, 2015 at 19:01
• @Werner: That's true of course. In conjunction with a dim register wrapper = should be avoided (a matter of personal taste, not a matter of correct or incorrect).
– user31729
Nov 30, 2015 at 19:04

TeX has no data type for decimal numbers. It can only use them in connection with lengths, but they actually represent an integer in (implicit) unit sp (where 1pt=65536sp).

One could think to store \arraystretch or \baselinestretch as dimensions, but this would cause difficulties when they are to be used: when, for instance, \fontsize{10}{12}\selecfont is performed, LaTeX does something like

\dimen@=12pt
\baselineskip=\baselinestretch\dimen@


and if \baselinestretch were stored as a dimension register, the setting would be very awkward; moreover a macro like \setdecimal should be defined to emulate the new data type.

Actually there would be no difficulty in doing

\newcommand{\setdecimal}[2]{\def#1{#2}}


(maybe with some error checking) so one could say

\setdecimal{\baselinestretch}{1.2}


similarly to \setlength. There would be a slight gain in the user interface, but one has to remember that computers were very short in memory when LaTeX2e was issued in 1995 (not very long ago, in absolute terms, ages in terms of computing power).

Note that \arraystretch is very much alike \baselinestretch, they just act at different times.

Conversely, \arraycolsep is the symbolic name of a dimension register, that holds a (rigid) length, so its value should be set with

\setlength{\arraycolsep}{1mm}


that internally translates to

\arraycolsep=1mm\relax