Skip to main content

The PreTeXt Guide

Subsection 4.2.4 Renaming Blocks

A common desire of authors new to PreTeXt is a new block. Authors extending PreTeXt to add a new one is not supported, and it is not even straightforward for a PreTeXt developer to provide comprehensive support for a new block. One of the reasons for multiple versions of blocks, with common behaviors, is that you can appropriate one for use with your project and give it a new name. So for example, a biology textbook might want to use <activity> for a laboratory, but rename it to “Laboratory”. Of course, this means you will forego having any “Activity” in your book. (But if you are the first to write a biology textbook in PreTeXt perhaps you should talk to us about a real <laboratory> element that behaves well for all the physical and biological sciences!) Here is the procedure:
  1. Choose a block from List 4.2.2.2 that has behavior similar to your intended use, and which you do not forsee using as-is in your project.
  2. In the <docinfo> section use a <rename> element. The content should be the new name (“Laboratory” above), while the @element attribute should be the name of the element renamed (activity above).
  3. The @xml:lang attribute should be used to specify a value of the code for use with documents authored in languages other than US English. If absent, the default vslue en-US is used. Multiple <rename> elements for the same element, in different languages, is supported.
So, continuing and extending our example, an author would use
<rename @element="activity" xml:lang="fr-FR">Laboratoire</rename>
The most popular block to rename is <exercise>. We have exercises inside <exercises> divisions, which we call divisional exercises, and exercises inside divisions, which we call inline exercises. It is possible to have one of each that have identical numbers. So in cross-references the former is an “Exercise”, while the latter is a “Checkpoint”. If you only have inline exercises, you might prefer that they be called Exercise rather than Checkpoint. For the @element attribute of the <rename> element, use a pseudo-element, in this case inlineexercise. Other pseudo-elements which can be used to distinguish the various types of exercises are: divisionexercise, worksheetexercise, and readingquestion.
Choose the element you rename carefully, trying to match it to the purpose of your content. It can be useful for other purposes, such as automatic lists (Section 4.27), and you may decide later to use other properties of the element you have chosen.