Hello,
I was not in fact thinking of chemical equations. I'm not sure if that's the source of feeling, but just to clarify by
atom I mean a basic
unit, or a
token, not atom as in chemstry.
The physics package provides a whole bunch of very useful shorthands, but it does not deal with the issue of spacing.
the chemmacros looks like it could be doing some relevant things internally, i'll try to read the source.
The mathmode docs do shine some light in how the spacing is implemented. It seems to me that LaTeX atomizes the equation and follows a set of rules to insert one of the three lengths (thinmuskip, medmuskip, thickmuskip) in between the atoms. What i'm after is modifying of those rules in such a way that the spacing is chosen in a way I described in the previous post.
I didn't know about the typesetting of the whole document. For what it is worth, here's the previous post in latex:
Code: Select all
\documentclass{article}
\setlength{\parindent}{0pt}
\usepackage{mathtools}
\usepackage[margin=1in]{geometry}
\newcommand{\noparskip}{}
\begin{document}
\subsubsection*{setup}
\begin{itemize}
\item
Let's take \emph{atom} to mean a sequence of printable alphanumerical characters together with all its possible decorations (super-/sub-scripts, \texttt{\textbackslash vec}, \texttt{\textbackslash hat}, etc). Atoms are separated by one or more spaces. For example, the following latex equation code:
\noparskip
\begin{verbatim}
ab c^{d} \hat e \mathbf{f}
\end{verbatim}
\noparskip
which compiles to:
\[ab c^{d} \hat e \mathbf{f}\]
should be atomized as:
\noparskip
\begin{verbatim}
ab, c^{d}, \hat e, \mathbf{f}
\end{verbatim}
\item
Atoms should be identified by the string being decorated (the "base"):
\noparskip
\begin{verbatim}
\texttt{ab} --> ab
c^{d} --> c
\hat e --> e
\mathbf{f} --> f
\end{verbatim}
\item
Atoms belong to categories depending on their base.
\item
Adjacent atoms in an expression should be grouped by the category they belong to.
Consider the following equation:
\begin{verbatim}
\psi i \hbar \partial_t \psi
\end{verbatim}
which typesets to:
\[
\psi i \hbar \partial_t \psi
\]
The atom categories are:
\begin{itemize}
\item Category 1 -- \texttt{i}, \texttt{\textbackslash hbar}
\item Category 2 -- \texttt{\textbackslash partial}
\item Category 3 -- \texttt{\textbackslash psi}
\end{itemize}
and the resulting (logical) grouping is: (parentheses below and in all what follows denote the logical grouping and are not printed)
\begin{verbatim}
(\psi) (i \hbar) (\partial_t) (\psi)
\end{verbatim}
\end{itemize}
\subsubsection*{rules}
\begin{itemize}
\item
Adjacent tokens within one group should be separated by \texttt{\textbackslash,}.
Example (parentheses denote logical grouping and are not printable):
\begin{verbatim}
(\psi) (i \, \hbar) (\partial_t) (\psi)
\end{verbatim}
which typesets to:
\[
\psi i \, \hbar \partial_t \psi
\]
\item
Separation between groups is more complicated.
The default behaviour would be to separate adjacent groups by \texttt{\textbackslash;} but groups can override this behaviour by specifying a pre- and a postfix separator.
For the purpose of an example, let's say Category 1 should be preceded by \texttt{\textbackslash quad} instead of \texttt{\textbackslash,} and Category 3 should be followed by nothing.
The above equation results in:
\begin{verbatim}
(\psi) \quad (i \, \hbar) \; (\partial_t) (\psi)
\end{verbatim}
which typesets to:
\[
\psi \quad i \, \hbar \; \partial_t \psi
\]
\item
In addition, printable non-alphanumerical characters should break the grouping and should not be surrounded by any spacing separators.
Example:
\begin{verbatim}
i \hbar \cdot i \hbar \psi
\end{verbatim}
becomes:
\begin{verbatim}
(i \, \hbar) \cdot (i \, \hbar) \; (\psi)
\end{verbatim}
\end{itemize}
\end{document}