44

Is there a preferred or generally accepted idiom for naming user defined macros? I notice that in the change from Tufte 3.5.0 to 3.5.2, for example, the names of the debugging macros have change, for example from

\TufteDebugInfoNL

to

\@tufte@debug@info@noline

Does this correspond to some agreed to practice?

1
  • 7
    Don't think there is agreed standard, but using the prefix @tufte (but just as good as Tufte) is a good idea to help avoid name collisions, and the use of @ signs makes it even less likely to have name collisions as that requires special handling in regular code (i.e., \makeatletter ... \makeatother). Commented Mar 16, 2012 at 0:39

1 Answer 1

52

LaTeX does try to encourage a naming scheme

Document level commands (\section) lowercase.

Package interface commands (\DeclareTextCommandDefault) CamelCase.

Package or kernel internal commands (\@text@composite@) lower@case@with@.

Expl3 programming layer commands (\cs_new:NN) module_name_words:argspec.

TeX primitives (\expandafter) lowercase.

Mostly this convention is not enforced, and of course one might notice that the top and bottom layer using the same convention makes enforcing anything difficult. LaTeX3 addresses this by renaming all the commands at the bottom layer.

So the command you mention has changed from using a "package interface name" to an "internal name" but whether that is appropriate in this case I couldn't judge, not knowing that class.

8
  • 2
    How does that work out, to just decide that all commands on the bottom layer are to be rewritten? It feels like that means a lot of rewriting of packages and classes. Commented Jun 15, 2012 at 9:26
  • I think "renaming" in this case means defining aliases.
    – marczellm
    Commented Sep 6, 2013 at 17:01
  • @marczellm defining aliases and undefining the original names Commented Nov 11, 2013 at 22:21
  • 1
    @DavidCarlisle Can you undefine a primitive?
    – marczellm
    Commented Nov 11, 2013 at 22:23
  • 6
    @marczellm \let\def\undefined Commented Nov 11, 2013 at 22:27

You must log in to answer this question.

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