Tralics, a LaTeX to XML translator; Part I

French title: Tralics, un traducteur de LaTeX vers XML; Partie I

Author: José Grimm(note: )

Location: Sophia Antipolis – Méditerranée

Inria Research Theme: THnum

Inria Research Report Number: 309

Revision: 3

Team: Apics

Date: September 2005

Revised Date: April 2008

Keywords: Latex, XML, HTML, MathML, Perl, PostScript, Pdf.

French keywords: Latex, XML, HTML, MathML, Perl, PostScript, Pdf.

Abstract

In this paper we describe Tralics, a LaTeX to XML translator. A previous version of the software (written in Perl) was used to obtain the Pdf version of Inria´s “Rapport d´Activité” for year 2001. The current version of the software (written in C++) is used for both the HTML and Pdf version since year 2002: the XML generated by Tralics is conforming to a local DTD, similar to the TEI; it is converted to Pdf via pdfTeX and the xmltex package, and the HTML via a xslt processor.

We explain here the philosophy of the software, its usage, its limitations, and how to customize it. All commands defined by Tralics are explained in this document, for most of them, we give an example of use. The index lists all commmands, environments, and options.

Version 2 of this document holds additions for Tralics 2.9. Version 3 of this document holds additions for Tralics 2.12.

French Abstract

Dans cet article nous décrivons le logiciel Tralics, un traducteur de LaTeX vers XML. Une version antérieure de ce logiciel, écrite en Perl, a été utilisée pour générer la version Pdf du Rapport d´activité de l´Inria en 2001. La version actuelle du logiciel, écrite en C++, a été utilisée pour obtenir à la fois le HTML et le Pdf depuis 2002 : nous avons utilisé une DTD locale, similaire à la TEI, et pdfTeX plus xmltex pour obtenir le Pdf.

Nous expliquons ici la philosophie de Tralics, son usage, ses limitations, et comment paramétrer le logiciel. Toutes les commandes définies par Tralics, sont expliquées, pour la plupart d´entre elles on donne un exemple d´utilisation. Un index regroupe l´ensemble des commmandes, environnements et options.

La version 2 de ce document contient des mises à jour pour Tralics 2.9. La version 3 de ce document contient des mises à jour pour Tralics 2.12.


1. Introduction

2. Expansion

3. Mathematics

4. Translating a bibliography

5. Other commands

6. Running Tralics

Bibliography

[1] David Carlisle, Michel Goossens, Sebastian Rahtz. De XML à PDF avec xmltex et PassiveTeX. in « Cahiers Gutenberg », number 35-36, pages 79-114, 2000.

[2] Michel Goossens, Frank Mittelbach, Alexander Samarin. The LaTeX companion. Addison Wesley, 1993.

[3] José Grimm. Outils pour la manipulation du rapport d´activité. Technical report, number RT-0265, Inria, 2002, http://www.inria.fr/rrrt/rt-0265.html

[4] Donald E. Knuth. The TeXbook. Addison Wesley, 1984.

[5] Philippe Louarn. Une expérience d´utilisation de LaTeX : le Rapport d´activité de l´INRIA. in « Cahiers Gutenberg », number 0, apr, 1988, pages 17-24.

[6] Frank Mittelbach, Michel Goossens, Johannes Braams, David Carlisle, Chris Rowley. The LaTeX companion, second edition. Addison Wesley, 2004.

[7] The Unicode Consortium. The Unicode Standard, version 4.0. Addison Wesley, 2003.

[8] W3C. Extensible Markup Language (XML) 1.1. http://www.w3.org/TR/xml11/, 2004.

[9] W3C. Extensible Markup Language (XML) 1.0 (Third Edition). http://www.w3.org/TR/REC-xml/, 1998, Third edition published in 2004.

Table of Contents


1. Introduction
     1.1. A short history of the Raweb
     1.2. Birth of Tralics
     1.3. Main objectives
     1.4. Notes on the distribution
     1.5. An example
     1.6. Some remarks on the Translation
     1.7. Category codes and characters
     1.8. Considerations about mathematics
     1.9. Some subtleties of TeX
     1.10. Language options
2. Expansion
     2.1. Defining new commands
     2.2. Defining commands in LaTeX
     2.3. Some small examples
     2.4. Variables in TeX
     2.5. All the variables
     2.6. Using the variables
     2.7. Counters
     2.8. Fonts
     2.9. Spaces
     2.10. Conditional expansion
          2.10.1. Constructing commands dynamically
          2.10.2. Iterating over lists
          2.10.3. Mapping a command
          2.10.4. Creating a list via pattern matching
          2.10.5. A variant of the previous problem
          2.10.6. Loops
     2.11. Conditionals in TeX
          2.11.1. Syntax of the conditionals
          2.11.2. Examples of conditional commands
          2.11.3. Testing the next token
          2.11.4. Reading a space
          2.11.5. Variants of the Map problem
          2.11.6. More examples
          2.11.7. Producing N asterisks in a row
     2.12. A nontrivial command \verb
     2.13. Expandable tokens
3. Mathematics
     3.1. Introduction
     3.2. The basic objects
     3.3. Parsing a math formula
     3.4. Translation of arrays
     3.5. Trivial math
     3.6. Conversion to XML
     3.7. Final math mode hacks
     3.8. Extensions
4. Translating a bibliography
     4.1. Introduction
     4.2. Citing a document
     4.3. Using Tralics instead of BibTeX
     4.4. The format of a name
     4.5. Commands for the bbl
     4.6. Other commands
5. Other commands
     5.1. Character encoding
     5.2. New encoding scheme
     5.3. Changing the input encoding
     5.4. Characters and Accents
     5.5. Verbatim material
     5.6. Case change
     5.7. Simple commands
     5.8. The fp package
          5.8.1. Introduction
          5.8.2. The list of all commands
          5.8.3. Alternate syntax
     5.9. Action before translation
     5.10. Classes and packages
     5.11. Expandable commands
     5.12. Other expandable commands
     5.13. Other non-expandable commands
     5.14. Special commands
     5.15. Trees
     5.16. Linguistic macros
     5.17. Special parsing rules
6. Running Tralics
     6.1. Introduction
     6.2. The command line arguments
     6.3. Configuration files
          6.3.1. The standard configuration file
          6.3.2. The old configuration file
          6.3.3. The ra.tcf file
          6.3.4. The RR.tcf file
          6.3.5. The RR.plt file
          6.3.6. Sample files
     6.4. The action before translation
          6.4.1. Files and Paths
          6.4.2. Finding the configuration
          6.4.3. Old behaviour
          6.4.4. Preparing the translation
     6.5. Translating the Raweb
     6.6. Tracing commands
     6.7. Pictures and friends
     6.8. The title page
     6.9. Array and Tables
          6.9.1. The tabular environment
          6.9.2. Interpreting the preamble
          6.9.3. New column types
          6.9.4. Another example
     6.10. Actions declared in the configuration file
     6.11. Trace of titlepage
     6.12. Extensions
     6.13. Bootstrap code
     6.14. Standard packages
     6.15. Images
     6.16. The puzzle
Bibliography
Index