-
Notifications
You must be signed in to change notification settings - Fork 97
Description
Hi!
I am considering to use the Template Toolkit to parse LaTeX. I would like to create a system of snippets
similar to the Perl module hierarchy of reusable code. This should help me not repeating paragraphs, sections, or chapters that are similar across several LaTeX documents.
Consider: main.tex
\documentclass[11pt,a4paper]{amsart}
\begin{document}
\title{Testing TTK}
\date{\today}
\maketitle
[[ IMPORT my/math/article/derivation1
intro_sec='Introduction' ]]
From \eqref{eq:my:math:article:derivation1:1} it follows that ...
\bibliographystyle{plain}
\bibliography{myarticles}
\end{document}
and my/math/article/derivation1.tex
\section{[[ intro_sec ]]}
The equation of state is expressed in the form of the Helmholtz energy
as \cite{spa96:eqs}
\begin{align}
\label{eq:1}
\frac{A(\rho, T)}{RT} = \phi(\delta, \tau) =
\phi^o(\delta,\tau)+\phi^r(\delta, \tau)
\end{align}
where
\begin{align}
\label{eq:2}
\delta &= \frac{\rho}{\rho_c}\\
\tau &= \frac{T_c}{T}.
\end{align}
So I created a new directive IMPORT that will be a superset of the INCLUDE directive. I would like the IMPORT directive to do the same as INCLUDE but also expand equation labels (and possibly more stuff). So \label{eq:1} should be converted to \label{eq:my:math:article:derivation1:1}, such that the parent document does not have to worry about conflicts in equation labels when importing a snippet.
My question is then: Is this a good idea, and is it possible to extend the Template Toolkit with new directives like IMPORT?