Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

From @cgnieder's very helpful xtemplate article:

Basically there are four commands that are important for the definition of the structures:

\DeclareObjectType
    {⟨object⟩}
    {⟨number of args⟩}

\DeclareTemplateInterface
    {⟨object⟩}
    {⟨template⟩}
    {⟨number of args⟩}
    {⟨interface⟩}

\DeclareTemplateCode
    {⟨object⟩}
    {⟨template⟩}
    {⟨number of args⟩}
    {⟨parameter⟩}
    {⟨code⟩}

\DeclareInstance
    {⟨object⟩}
    {⟨instance⟩}
    {⟨template⟩}
    {⟨parameter⟩}

Why is there a distinction between the number of arguments for each of \DeclareObjectType, \DeclareTemplateInterface, and \DeclareTemplateCode

share|improve this question

1 Answer 1

up vote 9 down vote accepted

As the linked article explains, the xtemplate package is an experimental approach to formalising a separation between design and structure for LaTeX. (It's not the only approach that has been explored, and there are some important open questions!) On of the things that the template approach is meant to do is make the ideas self-documenting. Thus for example the way an interface is declared can be read without having to look at some separate documentation and should give a reasonable idea of the nature of the keys in use.

In the case of the number of arguments that an object/template takes, the requirement to repeat the number of arguments an object type takes when creating a template is essentially to do with that idea of 'clarity'. The idea is that you can immediately see that things are consistent and can also see on for example reading a template implementation (code part) how many arguments to expect.

At a technical level, it would be quite possible to simply look up how many arguments an object type requires and use that value directly in the template parts of the code (\DeclareTemplateInterface doesn't actually need this: only \DeclareTemplateCode has internals which require a declaration of the number of arguments).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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