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
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this community\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}
\dimen52
, since this would be hard to remember and could even change if for example someone would use a different format.
=
when dealing with dimensions. Also, \setlength{...}{..}
should work as expected.
=
should be avoided (a matter of personal taste, not a matter of correct or incorrect).
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
\arraycolsep
is the symbolic name of a dimen register, whereas\arraystretch
is a macro.