7

I've noticed that when you set length, you can not only write \setlength{X}{3.14cm} but \setlength{X}{=3.14cm} as well. It looks like there is not any difference between those notations but I'd like to know why there is a possibility to use notation with "=" sign.

3
  • You could as well type \setlength{\X}{\@firstoftwo{3.14}{Hey! It's pi}cm} if in a \makeatletter context, but this doesn't mean you should. ;-)
    – egreg
    Commented Oct 23, 2016 at 19:30
  • 1
    how did you notice that?????? (without starting from the implementation and just inferring that the = would drop through by accident? )Surely no documentation suggests that does it? Commented Oct 23, 2016 at 22:53
  • @DavidCarlisle I knew \setlength{X}{Y} expands to {X Y\relax} (I've read it in documentation) and then when experimenting with those notations I discovered the possibility of using =. Commented Oct 24, 2016 at 9:22

1 Answer 1

6

\setlength is a LaTeX macro which is defined as:

\def\setlength#1#2{#1 #2\relax}

So \setlength{\mylength}{1cm} expands to \mylength 1cm.

The equals sign in assignments is optional, in TeX so:

\mylength 1cm

is equivalent to

 \mylength=1cm 
2
  • Thank you very much. Could you please give me the source of this information? I've searched for assignments syntax in TeX but I didn't found anything helpful. Commented Oct 23, 2016 at 19:23
  • 1
    @BartłomiejSługocki Other than the TeX Book itself, (which is not freely available), the best free source for TeX itself is Victor Eijkhout's TeX by Topic which you can find using texdoc in your distribution. For the source documentation of the LaTeX kernel, you can look at source2e, also available as part of your distribution via texdoc.
    – Alan Munn
    Commented Oct 23, 2016 at 19:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .