I understand:


are just necessary for redefining macros or something.


just takes the current macro input@path and clears it.


I do not fully understand what this does.


Nor this. Does it tell the input path that these are all directories which may be invoked directly?


You provide several interpretations of what various commands do.

\makeatletter and \makeatother are just necessary for redefining macros or something.

Not quite. By default, the character @ is not allowed to occur in the name of a TeX or LaTeX macro; instead, valid multi-character macro names must consist of uppercase and lowercase letters exclusively or, more precisely, of characters with category code "letter". (By default, the only characters with catcode "letter" are, you guessed, uppercase and lowercase letters.) The instruction \makeatletter changes the catcode of @ from "other" to "letter", making it syntactically legal to use the @ character in multi-character macro names.

Why go through these steps? For by-now mostly historic reasons, LaTeX-internal commands often (but not exclusively) use one or more @ characters; this presumably makes it much less likely that "ordinary" users execute them by accident. \makeatletter lets you get over this (admittedly not very high) hurdle, and \makeatother restores the default catcode of @.

\providecommand just takes the current macro \input@path and clears it.

No! (You may be thinking of \renewcommand{<some existing command>}{}.) \providecommand acts like \newcommand if the first argument isn't already a valid macro name, and it does nothing if a macro by that name already exists. The purpose of


is to make sure that the next instruction, viz., \g@addto@macro\input@path{{./level1//}{./level1/level2//}{./level2//}}, doesn't crash and burn in case a macro with the name \input@path hasn't been defined already.

Finally, let's turn to


The macro \g@addto@macro -- note the presence of two [2!] @ characters -- is a low-level LaTeX kernel command which takes two arguments: The first is the name of an existing macro (here: \input@path); the second is some additional material to be appended to the macro named in the first argument.

Let's assume that the macro \input@path is either blank (because it was created by the preceding \providecommand instruction) or contains a syntactically valid path. The \g@addto@macro instruction appends


to that macro.

Not knowing where you obtained this code snippet from or what it is supposed to do, I'm afraid I can't add anything more in terms of explanation or interpretation.

  • 4
    Very good explanation. – Sveinung Aug 25 '19 at 20:41
  • @Sveinung - Many thanks for the compliment -- and for the typo fixes! – Mico Aug 25 '19 at 21:25

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.