# What is \@gtempa used for?

\@gtempa is used in a number of intermediate definitions, but I'm having difficulty finding how it is intended to be used (at least according to convention). I first ran across in this question: Xelatex math weirdness - misaligned \not.

I recognise the use of the @ as suggesting a protected internal token value, and in some cases it seems like it's just used to store a temporary value (which makes me think that is where the "temp" part of its name comes from… but that's just a hunch).

However, I don't know if that's in general how it is used, or if it does have some other purpose, or if there is convention at all.

It's a global temporary macro a (followed by b, c etc as distinct from \@tempa which is a macro for local definitions.

The naming convention comes from LaTeX2.09 which used these all over the place however by 1993 when we did latex2e far too many packages (style files) were using \@tempa so we renamed all the internal uses in the format to \reserved@a etc

compare latex2.09

\def\hline{\noalign{\ifnum0=}\fi\hrule \@height \arrayrulewidth \futurelet
\@tempa\@xhline}


and latex 2e

\def\hline{%
\noalign{\ifnum0=}\fi\hrule \@height \arrayrulewidth \futurelet
\reserved@a\@xhline}


One of the early latex2e announcements explained to package writers they could use \@temp... for whatever local use they wanted but should not use \reserved@... for uses outside the format.

However global use is used more rarely so the uses of \@gtempa got left as they were (although most were eliminated altogether)

compare 2.09

\def\@cline[#1-#2]{\noalign{\global\@cla#1\relax
\ifnum\@cla>\z@\global\let\@gtempa\@clinea\else
\global\let\@gtempa\@clineb\fi


with 2e

\def\@cline#1-#2\@nil{%
\omit
\@multicnt#1%
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\cr
\noalign{\vskip-\arrayrulewidth}}


so it's just a conventional name often used by packages for global definitions (\gdef, \global\let) it isn't used much of course as being used with local definitions means that if any other package code could run between your code defining it and using it, it may have been over-written for a completely differemt purpose.

\@gtempa is a temporary scratch command, meant for global purposes (often used in conjunction with \xdef), but can be overwritten easily. It's just used for temporary storage globally and throw away after that. The prefix g indicates that it is designed for global
purposes.

However \@gtempa can mean a global temporary dim register as well.

It's quite useful, this way there's no need to use another command sequence to be defined and 'consuming' the number of registers for command names

The LaTeX core is full of those \@gtempa usages and dates back to the time when there wasn't plenty of registers, i.e. the times before eTeX appeared on the stage.

In a local sense there is a bunch of similar scratch registers, such as \@tempskipa, \@tempcnta,\@tempboxa.

The \@.. prefix is meant to keep the macro internal, i.e. it can not be accidentally accessed without using \makeatletter...\makeatother

In expl3 the \g_tmpa_<foo> 'variables' have the same meaning as \@gtempa, where foo is something like clist or seq or tl etc.

• Is the global use what the g refers to? if one were to have a local command would convention suggest \@tempa instead? – mpacer May 11 '16 at 18:34
• \@tempa would be possible, yes. I'll update my answer – user31729 May 11 '16 at 18:36
• I know this is just a naming convention so it doesn't actually matter, but is the a supposed to be understood as an index such that \@gtempb, \@gtempc… would be a good additional examples of conventional global temporary registers? In the expl3 case, this question would be modified to ask about \g_tmpa_<foo>, \g_tmpb_<foo>, … (I think). Part of the reason I'm asking is to test whether I'm understanding all of the parts of the convention and how they are used together. – mpacer May 11 '16 at 19:15