[Tex/LaTex] Defining custom commands is bad style

best practicesmacrossourcecode

I recently received this in a e-mail from my professor

Good LaTeX style would preclude creating any of your own commands, counters, etc. (Most journals would reject submissions with user-defined commands.)

I have two questions:

  1. Is this in fact true (both parts)?
  2. Given that I am required to conform to a specific format and there is a lot of repetition (for example, I often have to use \qquad\textnormal) is there a way to define a command, and then when I run it produce a file that expands all of those macros?

Note: My understanding is that the standard way of doing this is to have the journal (or professor in this case) create a package that includes all of the things that are required to conform to the style that they want, but he does not seem to want to do that.

Best Answer

Sorry, no, that is not true. Most journals do accept reasonable shortcuts:

\newcommand*\NN{\mathbb{N}} % natural numbers
\newcommand*\AAA{\mathcal{A}} % automaton
\newcommand*\WWW{\mathring{W}^2_1} % Sobolev space 2,1,o
\newcommand*\defined[1]{\emph{#1}} % used for defining new terms
\DeclarePairedDelimiter\abs{\lvert}{\rvert} % proper absolute value
...

However, the will likely not accept stupid definitions, such as:

\newcommand\pf{\begin{proof}} % don't hide a structure behind some ridiculous macros
\newcommand\pfe{\end{proof}}
\newcommand\eqa{\begin{eqnarray}} % twice bad, once for the shorthand ...
\newcommand\eqae{\end{eqnarray}} % ... and second time for using `eqnarray`
\newcommand\eqn{\begin{equation}}
\newcommand\eqne{\end{equation}}
\renewcommand\em{\sc} % not speaking about the fact that the ...
\renewcommand\bf{\it} % ... two-letter font macros are depricated
\newcommand\SPACE{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\newcommand\Hs{Hilbert space\xspace} % no text replacement shorthands like this please!
\def\A{{\cal A}} % this is bad in 3 ways -- can you guess what are they?
...

Nevertheless, please:

  1. Define everything only once (no \NN and \Naturals doing the same stuff).
  2. Define only things you really use (no 100 lines of definitions with only 5 of them being used).
  3. Do not re-define stuff that already exists.
  4. Use proper LaTeX's \newcommand instead of just \def.
  5. Place everything in the preamble.
  6. Include short comments to each \newcommand, like I did above. Especially if you do any dirty stuff. However:
  7. Do not do any dirty stuff.

(Speaking as a typesetting editor of a journal, and as an author of numerous publications where I use definitions like the good ones above.)

Related Question