1

I consider myself a moderately proficient LaTeX user. Occasionally, I want to do something that is similar enough to an implementation found in a package that duplicating it seems pointless, but distinct enough that the package options do not necessarily allow me to easily achieve it. Under these circumstances, I often end up creating a local implementation of some \Package@PrivateCommand that is subtly modified, and using it in my document(s).

However, I have frequently found that packages which provide environments have a richer structure than those which do not. I know that one can readily define a new environment with LaTeX (i.e. that the \newenvironment command exists), but for some reason, packages which provide environments don't seem to do this directly. For example, the multicols package doesn't feature a single \newenvironment in its source at all -- instead, it's a complex mixture of things like \def\prepare@multicols and various macros that appear to be run before an environment, as well as after it. As one would expect, this makes changing things a lot more interesting for an ignorant person like me :-).

Correspondingly, I strongly suspect that \begin{environment}{Argument} ``Some content goes here'' \end{environment} is just syntactic sugar for something like what the TeX equivalent would be, namely:

\EnvironmentPreHook
\argumentMacro{Argument}
``Some content goes here''
\EnvironmentPostHook

Am I correct? How are environments parsed? Are there any circumstances where this can cause real problems? Is this related to, for example, why \centering can do the same job (in a given scope) as begin{center} ... \end{center}?

I've had a quick look through the documentation I can find, and a detailed explanation (ideally along the lines of What is a macro, really?) is missing.

Landak
  • 373

0 Answers0