6

I am writing a book on structured writing and I am trying hard to break the association people have between structured writing and XML by highlighting the many other markup languages that are used to do various kinds of structured writing.

I am attempting to describe each of these languages in terms of their ability to support certain structured writing aids such as extensibility and constraint. By extensibility I mean the ability to add new structures to the language. By constraint I mean the ability to restrict what can go where and specify restricted hierarchical structures. In XML, these things are both performed declaratively by schema languages.

It is clear that Tex and LaTeX are extensible programmatically through macros. I can't find any mention of any declarative approach.

What I have not been able to figure out is whether macros provide any kind of constraint mechanism. So my question is, is there a constraint mechanism in TeX or LaTeX that provide functionality similar to constraints one can impose in an XML schema?

  • 1
    depends how you view it, \alpha has a constraint it has to be used in math mode, and generates an error if not. \\ has to be used mid-line and generates an error if used at the start. figures can not be used nested in other boxes, and generates an error if they are..... But these are all run-time errors there is no syntactic validation phase or declarative grammar as you might find in xml – David Carlisle Sep 7 '16 at 15:12
8

It depends how you view it, \alpha has a constraint it has to be used in math mode, and generates an error if not. \\ has to be used mid-line and generates an error if used at the start. figures can not be used nested in other boxes, and generates an error if they are.....

But these are all run-time errors there is no syntactic validation phase or declarative grammar as you might find in xml.

People looking for a more declarative grammar constraint often end up using an XML pipeline for authoring and validation, and just converting to tex for the print generation.

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.