I have a near philosophical question now. I am not a LaTeX programmer, but a LaTeX end user (writer). I have a collection of LaTeX style files used for a pretty fancy book written in LaTeX. My style files sometimes depend on macros in my other style files, and are exporting macros. I sometimes want to test them out by themselves in a minimal example, too.

Right now, my plan is to reorganize my style files as follows:

At the top of each style file, say a question.sty file, I first put the required imports


%% imports
\usepackage{xcolor} %% standard TL

\ProvideDocumentEnvironment{ threecolumn }%% my own macro hack facility, from elsewhere
  { \begin{center}\color{red} begin threecolumn \end{center} }
  { \begin{center}\color{red} end threecolumn \end{center} }

Having a stub will allow me to test out this stylefile in a simple tex file by itself, even though in its fancier forms it will use the threecolumn environment from elsewhere. Then, this would be followed by what this style file actually provides for quick reference without delving into the implementation details.

%% exports
\ProvideDocumentCommand{\question}{ O{red} m }{}

(edit --- david carlisel suggested rightly that the above should probably better be a \NewDocumentCommand)

This will be followed by longer documentation, a changelog, etc. Sort of like a 'pod' (perl).

%%% question.sty
%%% this provides a nicely formatted question macro,
%%% with one argument blah blah blah

Finally, I have the actual implementation, typically messy and cobbled together magic from lots of help that I have received on tex.stackexchange over the years (half of which I do not understand, all of which I highly appreciate).

\RenewDocumentCommand{\question}{ O{red}m }{
         \textcolor{#1.} #2

Any other macros than \question should probably have a '@' in them, and require \makeatletter.

  1. Is this a good plan?
  2. Is this reinventing the wheel or ignoring useful existing latex style facilities for end-users/writers like myself?
  • your onecolumn definition will do nothing as \onecolumn is already defined. Apr 18, 2022 at 8:55
  • bad example of mine. will fix to call it \threecolumn...
    – ivo Welch
    Apr 18, 2022 at 18:20

1 Answer 1


I see no advantage in having the \ProvideDocumenCommand it just makes things slower and is of dubious documentation value. It also completely masks package clashes with your package and existing code from other packages.

If your package intends to define a new \question command, then if you do the natural form

\NewDocumentCommand{\question}{ O{red}m }{% don't forget %
         \textcolor{#1.} #2%

Then if you accidentally have loaded some other code into the document that has already defined this, you get an error and can adjust the package loading.

However your \Provide.. \Renew... combination will always silently over-ride the existing definition with no warning. It's like using \def and negates all the checking done by LaTeX's \New... definition forms

  • I like the idea of having an easy reference to all exported commands at the top, but I think you rightly point out that this should probably be a \NewDocumentCommand. thanks. come to think of it, how do I then deal with multiple inclusions of the same sty file, aka C's ifndef header.hh?
    – ivo Welch
    Apr 18, 2022 at 18:20

You must log in to answer this question.

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