In the code of endnotes.sty there is a command \meaning that is used in the following definition

     \if@enotesopen \else \@openenotes \fi

If I remove it, it doesn't work anymore (I get the funny error Undefined control sequence. \GenericError). What is the use of \meaning ?

  • 12
    \meaning\meaning is the meaning of \meaning.
    – Manuel
    Nov 9, 2016 at 10:54
  • 1
    The endnote package documentation says "The stuff with \next and \meaning is a trick from the TeXbook, 382, there intended for setting verbatim text, but here used to avoid macro expansion when the footnote text is written." Nov 9, 2016 at 14:21

2 Answers 2

~ $ tex
This is TeX, Version 3.14159265 (TeX Live 2016) (preloaded format=tex)

*\def\test#1{This is a test #1 macro}

> \test=macro:
#1->This is a test #1 macro.
<*> \show\test

\show gives the meaning (definition) of a macro (or a primitive) in the log file and the terminal. \meaning shows the same but puts it in the document instead. In the example above it is written to the notes file.


If you process the document



x\endnote{Recall that $\sqrt{2}$ is irrational}


you'll get a file with extension .ent containing

\@doanenote {1}

This is a consequence of the definition

     \if@enotesopen \else \@openenotes \fi

and of


which make the two control sequences into unexpandable tokens.

The \meaning primitive takes as argument a single token and expands to a string representation of the token: all characters will have category code 12, except for space tokens that are normalized to character code 32 (space) with category code 10. If the token is a macro (that is, it has been defined with \def, \edef, \gdef or \xdef), the representation will be of the form

macro:〈parameter text〉->〈replacement text〉

Thus, in the endnotes case above, \meaning\next will expand to

macro:->Recall that $\sqrt {2}$ is irrational

because the parameter text is empty. By rule, each control word in the string representation will be followed by a space.

The macro \@endnotetext does three \write operations. In the first, \@doanote {1} is written out, because \@doanote is not expandable so it is written out as is (with a trailing space), whereas \@theenmark will be expanded. Also { and } are unexpandable, so we get the first line in the example.

Then the expansion of \meaning\next is written, under the setting \newlinechar='40 which means that spaces (character code decimal 32, octal '40) will be transformed into newline characters. I guess this is done for avoiding overlong lines, in case of long endnotes.

Finally \@endanenote is written (on a new line).

When the .ent file is read in by the \theendnotes command, \@doanenote is given a new meaning; basically it reads until > is found, emits \begingroup, sets the mark to the tokens in braces and starts typesetting the note text; \@endanenote is redefined to issue \par\endgroup.

What does \meaning return in other cases? Here are a few examples; I use plain TeX, but it would be the same in all flavors of TeX.

\let\foo=0 % like in endnote.sty
\def\next{Recall that $\sqrt{2}$ is irrational}
\def\macro#1{Something with #1}

\tt % typewriter type


\meaning a

\meaning 0





\meaning ~


\meaning\pageno % plain tex


enter image description here

A control sequence \let to a character will display the same as if the character was used. A control sequence defined with \chardef (like \&) gives \char" followed by the hexadecimal number of the character; similarly for \mathchardef (like \alpha).

The macros \next and \macro show the difference when there is a parameter text; finally, primitives represent themselves (like \relax). There are a few other cases, I showed \pageno that's defined with \countdef.

  • Thanks for these details. Is there a macro that would output \next in the same way as \meaning without the macro:-> string ?
    – Tom-Tom
    Nov 9, 2016 at 12:35
  • 3
    @Tom-Tom In LaTeX you do \expandafter\strip@prefix\meaning\next
    – egreg
    Nov 9, 2016 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.