I would like to create my own LaTeX-derivative markup language. (I asked similar questions before, but this is more limited.) Advice would be useful.

First Question:

I believe there are three main categories of macros between the begin-document and end-document (which I will call the "main document"):

  1. markup (e.g., \textit, \begin{quote})

  2. characters (e.g., \kappa, \Bbb{A})

  3. programming (e.g., \newcommand, \let, \newtheorem).

Is this classification reasonable, or am I omitting a logical class of macros?

I believe everything that can be typeset in LaTeX can still be typeset if I removed #3 from the main document and banned it into the preamble. This means that once my preamble is read, the set of allowed macro names will be fixed, and I just have true markup in my document. Another program could then, in principle, interpret markup (and interpret it differently) without having to be itself TeX.

Second Question:

Is there a long-cut to { } environments? This is when used by itself, not when used to delineate arguments of macros. I mean hello {\it there} as opposed to hello \textit{there}. I am wondering if I can "ban" the plain environment use of the parens in my document, and rely on styling instead. In rare cases where needed, I would then say \begin{env} ... \end{env}. But I have not run into such a situation.

Third question:

Is it possible to change catcodes in the main document, but as soon as LaTeX expands (enters = runs) a macro, the standard catcode definitions hold again? (I.e., so that I can still run all macros that were defined in packages without me having to make changes).

If this is the case, then I could define my own LaTeX dialect. My documents would have the power of standard LaTeX in the preamble, and then

   modified catcodes, outside markup

where the newdocument would be my own version. as for me, I would want

  • | becomes my cell separator in tabulars

  • & become the entity operator, just as in html, i.e., κ and &hashmark;

  • \\ be replaced with something like \nl

  • $ be freed up (i.e., no longer a catcode). my users would have to use \m{...} for math expressions.

  • % be freed up (i.e., no longer be a special catcode). 15% is now what it should be.

Less important:

  • # become the remark operator. without programming, no longer needed otherwise

  • \# be banned in exchange for &hashmark;

Now, processing the input text is easy with Lua or Perl or..., but I would like the documents to remain portable, so this would have to be a standard LaTeX package written in TeX. (If this is easy, I will want to hire someone to implement this. If this is hard, then it's a no go.)


  • 1
    Modest changes? ;-) You can ban \it, just remove its definition; but you can't really ban users to type {\itshape world} if they want. You can't also avoid them using \newcommand mid document: undefining it would break umpteen packages.
    – egreg
    Feb 12 '14 at 17:11
  • 1
    Everything you describe is pretty straightforward. For an example of what can be done, the xmltex package lets you insert xml into a TeX file and typeset the <div>...</div> and other things correctly. Feb 12 '14 at 17:13

The answer to question 3 is yes. You can see this e.g. for @: its catcode in a document is other but \section has no problem to call the internal \@startsection.

You can also easily test it:


%normal catcodes:


%changed catcodes:

  • thank you ulrike. \textit{$a_b$} also works appropriately.
    – ivo Welch
    Feb 15 '14 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.