I'm writing a text where I repeatedly speak of particular expressions which compose more complex expressions which I also repeatedly speak of (more specifically I'm writing a text with logical and set theoretic expressions). If I put my simple expressions in definitions and build up the more complex expressions from these definitions I benefit in the following ways:
- If I decide to change a particular expression it's easy to change it and it reflects throughout my text.
- It's easier to avoid mistakes of not repeating the exact expression. That is, it's easier to be consistent.
- The source might be easier to read and write.
Here's an example:
\documentclass{article}
\def\firstcond{A \land B}
\def\secondcond{C \lor D}
\def\thirdcond{E \land F}
\def\firstimp{\firstcond \to \secondcond}
\def\secondimp{\thirdcond \to P(\secondcond )}
\begin{document}
\begin{equation}
(\firstimp ) \leftrightarrow ( \secondimp )
\end{equation}
\(\lnot (\secondimp )\) instead of \(\secondimp\), thus
\begin{equation}
(\firstimp ) \leftrightarrow \lnot( \secondimp )
\end{equation}
\end{document}
Say that I decide that \firstcond is a bad expression and that it should read some other way. Then I can just change the definition of \firstcond and it reflects throughout my document (I know that this can be done by an editor's search and replace but that doesn't help with point 2 and 3).
What I prefer with this solution is that \def can be put after the preamble so that it can figure right before it's used so that its contents is near its first use in text. This makes it easier when writing because I don't have to scroll back and forth or switch between files to see the contents.
Now, my question. Is this the best way to achieve this kind of writing/way of working? Is there any way to improve on it? Note that I'm not looking for ways to make cross-references because in this case I don't want to burden the reader with the overhead of connecting a label to an expression.
\newcommandinstead of\defas that will automatically check that you don't overwrite previous definitions. – Peter Grill Jun 22 '11 at 18:57