Is this the best way to achieve this kind of writing/way of working?
Yes.
I recently did a fairly similar thing in this paper. My coauthor and I were convinced that whatever notation we chose, we would get a comment from the referee along the lines of "The notation for X is awful. I suggest using Y." So I designed the paper to make it as easy as possible to change all the notation. At one point I even had it set up so that a single change would flip all actions from left to right (so that, for example, f
followed by g
would be g f
instead of f g
). So I have every sympathy for your situation and think that the general scheme is the right way to go.
Is there any way to improve on it?
Yes.
Make your macros more obvious what they are. (This may already be true for you, in which case ignore this comment!). It's been said that you should write so that when you look again at the code in 6 months' time, you don't have to puzzle out what everything means. In my example above, I had macros of the form \dcat
, \dobj
, \delt
for "The category D", "An object of D", and "An element of an object of D". It's not hard to remember what they mean, whilst still retaining the flexibility of changing how they are typeset. So my first piece of advice:
- Pick a good naming scheme for your macros.
The next is about saving time and energy. In my case, I found myself defining reams of these things, and all the same: I'd have a category and want to define objects, morphisms, elements, and variants thereof. All on the same basic pattern. So I wrote a "generator" macro that would take in a couple of basic parameters and then generate all the macros that I wanted to use (a crude sort of object-oriented programming). Of course, exactly how feasible that is for you depends on your abilities with TeX, but even if you feel it is beyond you right now, it is worth planning ahead a little and anticipating that you might put in place such a scheme and so choosing your names appropriately now. So my second piece of advice:
- Be lazy. Build layers in to your system so that it is easy to change the style of how these things are typeset as well as how individual terms appear.
For LaTeX I'd use an array
:
\documentclass{article}
\usepackage{amsmath,array}
\begin{document}
\[
x =
\left\{
\begin{array}{
@{}% no padding
l@{\quad}% some padding
r@{}% no padding
>{{}}r@{}% no padding
>{{}}l@{}% no padding
}
d,& & I_x &\leq I_p - t \\
s,& I_p - t &\leq I_x &\leq I_p + t \\
b,& I_p + t &\leq I_x
\end{array}
\right.
\]
\end{document}
If the center terms of the inequalities don't have the same width, more alignment points are needed to make them centered.

We don't want any of the automatic padding between colums that array
usually inserts, so between columns (and also at the start and end of the array) I put @{}
that disables the insertion. Exception: between the first and second column we want some space.
The mysterious >{{}}
bit is readily explained: when TeX is doing the second and third column in the second row, it would essentially do
$I_p-t$$\leq I_x$
because it treats each cell as a separate formula. This doesn't give the correct spacing, so we insert {}
at the start of the cells in the third column and the final result is
$I_p-t$${}\leq I_x$
which typesets exactly like
$I_p-t\leq I_x$
and the desired outcome is obtained.
Best Answer
I think this is a job for
cases
from theamsmath
packageor if you would prefer a
displaystyle
fraction, then you could usedcases
from themathtools
package, which extends (and loads) theamsmath
package.