12

The scenario is that I'm writing a book and it looks like I'm going to need to do some munging as the document class Memoir has some wonderful features but Octavio has the presentation.

Now, one of the things that really bugs me with LaTeX is that they use a global namespace, which means they interact with each other in unpredictable ways. I can't predict easily what a hack-and-splice job will do. As for finding and fixing problems... well..

LaTeX 2e has dozens of variants these days and there are an endless number of preprocessors to support them. If just one supports namespaces then I can munge with safety. I don't know of any, but that doesn't mean they're not there. Anyone know of anything that might help?

Jonathan
  • 121
  • 8
    I'm not sure what you mean by 'variants' or 'preprocessors' here. There is only one LaTeX2e format, and in any case the flat namespace is a consequence of TeX, not LaTeX. – Joseph Wright Nov 23 '11 at 10:43
  • AFAIK exTeX supports namespaces. But I've never used it. AFAIK it's a TeX engine written in Java. – Schweinebacke Nov 23 '11 at 11:09
  • 1
    I don't really get the idea what you want to achieve. But wouldn't it be enough to prefix your macros with a something like MyPackage:Index:DirtyHack? – Marco Nov 23 '11 at 11:15
  • 1
    @Schweinebacke: exTeX is the project of writing a TeX engine in Java. I doubt that anything usable exists today. – Martin Schröder Nov 23 '11 at 17:58
  • @Martin: But the development state shows a system, that is already able to make DVI, PS and SVG and maybe PDF. Neverless you are right, that it is not TeX-complete, because some primitives like \outer are currently not implemented. – Schweinebacke Nov 24 '11 at 07:29
  • Many of memoir's features also exist as independent packages (the documentation is usually pretty clear about this). memoir.cls (2011/03/06 v3.6j) lists the following: abstract, appendix, array, booktabs, ccaption, chngcntr, chngpage, dcolumn, delarray, enumerate, epigraph, framed, ifmtarg, ifpdf , index, makeidx, moreverb, needspace, newfile, nextpage, parskip, patchcmd, setspace, shortvrb, showidx, tabularx, titleref , titling, tocbibind, tocloft, verbatim, verse. – jon Nov 24 '11 at 18:01
  • @Marco That is basic namespace support, but with more advanced namespace support, the namespace could be decoupled from the prefix. For a package mylongpackagename, you could write \begin{inNamespace}[mylongpackagename] … 1000 lines of codes … \end{inNamespace}. All newly defined commands in this block would automatically be in the mylongpackagename namespace, and all referenced command would reference the mylongpackagename versions. Later, you might add (and change) a namespace prefix. For example \setnsprefix{mlp}[mylongpackagename]. [Comment box to small to add more info. :-(] – Karl Ove Hufthammer Nov 26 '11 at 11:39
  • @KarlOveHufthammer Since I assume that all defs, counters, boxes, etc. should obey the namespace (what about gdefs?), I'm afraid there's no working namespace solution that fits your needs. Otherwise it probably would have alredy been used in many packages. – Marco Nov 26 '11 at 12:08
  • @KarlOveHufthammer Could you edit the question? As it stands, it is extremely unclear as it (I guess) assumes a background in whatever OP's specialisation is, which lots of readers here won't have. – cfr Dec 21 '17 at 00:24

1 Answers1

10

The answer is no. Apart from the experimental ExTeX program, none of the *TeX engines support namespaces on the TeX side (LuaTeX supports them on the Lua side, but this is not what you're looking for).

Many packages have been written without the need of namespaces and the system is pretty stable; in some occasions a clash can show up, but usually this happens with badly written packages (I found one where the author uses \value as an internal command: ouch!).

Of course, packages that try to redefine the same structure in different ways will be incompatible with each other, but namespaces would not solve such an issue.

Prefix your macros with a consistent naming scheme (e.g., jonathan@). The chance that a package uses the same prefix is small; in such a case change your macro prefix.

Dave Jarvis
  • 11,809
egreg
  • 1,121,712