Customizing arbitrary tags

Imagine that you want to change the rendering of a given tag, like lemma. As a general rule, TeXmacs provides a set of well-chosen macros which can be customized by the user so as to obtain the desired effect. For instance, as we have seen above, you should use modify one of the macros render-theorem, theorem-name or theorem-sep in order to customize the rendering of lemma and all other theorem-like environments.

However, in some cases, it may not be clear which “well-chosen” macro to customize. If we just wanted to change the presentation of lemmas and not of any other theorem-like environments, then we clearly cannot modify render-theorem, theorem-name or theorem-sep. In other cases, the user may not want to invest his time in completely understanding the macro hierarchy of TeXmacs, and find out about the existence of render-theorem, theorem-name and theorem-sep.

So imagine that you want all lemmas to appear in red. One thing you can always do is copy the original definition of lemmas in a safe place and redefine the lemma macro on top of the original definition:

<document|<assign|orig-lemma|lemma>|<assign|lemma|<macro|body|<with|color|red|<orig-lemma|body>>>>>

Alternatively, if only the text inside the lemma should be rendered in red, then you may do:

<document|<assign|orig-lemma|lemma>|<assign|lemma|<macro|body|<orig-lemma|<with|color|red|body>>>>>

Of course, you have to be careful that the name orig-lemma is not already in use.

Another frequent situation is that you only want to modify the rendering of a tag when it is used inside another one. On the web, the Cascading Style Sheet language (CSS) provides a mechanism for doing this. In TeXmacs, you may simulate this behaviour by redefining macros inside a with. For instance, imagine that we want the inter-paragraph space inside lists inside theorem-like environments to vanish. Then we may use:

< document | < assign | orig-render-theorem | render-theorem > | < assign | render-theorem | < macro | name | body | < with | orig-render-list | render-list | < with | render-list | < macro | x | < with | par-par-sep | 0fn | < orig-render-list | x > > > |

<\orig-render-theorem|

name

|

body

>

> > > > >

On the one hand side, this mechanism is a bit more complex than CSS, where it suffices to respecify the par-par-sep attribute of lists inside theorems. On the other hand, it is also more powerful, since the render-theorem macro applies to all theorem-like environments at once. Furthermore, if the above mechanism is to be used frequently, then real hackers may simplify the notations using further macro magic.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".