New numbering system
Use \value{⟨counter⟩}
for obtaining the value of a LaTeX-counter in terms of arabic numerals.
By the way: I suggest removing spaces from the output of the macro completely. So the user can insert them explicitly wherever desired.
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\makeatletter
\newcommand*\newnum[1]{%
\ifcase\value{#1}%
\or semel%
\or bis%
\or ter%
\or quater%
\or quinquies%
% etc
\else\@ctrerr
\fi
}
\makeatother
% Don't use a space but use a thin space (\,) as Bernard did in his answer:
\patchcmd\subequations
{\def\theequation{\theparentequation\alph{equation}}}
{\def\theequation{\theparentequation\ifnum\value{equation}<1 \else\protect\,\fi\newnum{equation}}}
{}{\FAIL}
\begin{document}
\begin{subequations}
\begin{align}
f(x) &= ax +b +c \\
&= x \left(a + \frac{b}{x} + \frac{c}{x} \right) \\
&= ax + x \left( \frac{b}{x} + \frac{c}{x} \right)
\end{align}
\end{subequations}
\end{document}
By the way: Your second question
Another question: how do you create a command of this type, but which doesn't need an argument? (For example, both
\Alph
and\Alph{}
exist)
is not clear to me:
\documentclass{article}
\begin{document}
\show\Alph
\end{document}
reveals:
> \Alph=macro:
#1->\expandafter \@Alph \csname c@#1\endcsname .
l.3 \show\Alph
This means \Alph
is a macro which in any case during its expansion does process a non-delimited argument.
That non-delimited argument must be the name of a LaTeX-counter.
That argument gets wrapped into \expandafter\@Alph\csname c@⟨counter⟩\endcsname
.
The \expandafter
ensures that the control-word-token \c@counter
is formed from the \csname
..\endcsname
-construct before applying \@Alph
to that control-word-token. The control-word-token \c@counter
denotes the TeX-\count
-register which underlies the LaTeX-counter in question.
So \Alph
is a wrapper for \@Alph
which serves the purpose of forming something (a control-word-token denoting a \count
-register) that can be processed as a TeX-⟨number⟩-quantity from the name of a LaTeX-counter.
\@Alph
in turn processes an argument which must be a TeX-⟨number⟩-quantity.
A TeX-⟨number⟩-quantity in turn can, e.g., be a control-word-token denoting a \count
-register allocated in terms of \countdef
.
But that's not all. A TeX-⟨number⟩-quantity can e.g., be an alphabetic constant, something like `\a
or a sequence of digits.
(More details about the syntax rules for TeX-⟨number⟩-quantities can be found in the TeXBook, Chapter 24: Summary of Vertical Mode.)
Of course you can implement \newnum
/\@newnum
like this, too:
\documentclass{article}
\makeatletter
\newcommand*\@newnum[1]{%
\ifcase#1%
\or semel%
\or bis%
\or ter%
\or quater%
\or quinquies%
% etc
\else\@ctrerr
\fi
}%
\newcommand*\newnum[1]{%
\expandafter\@newnum\csname c@#1\endcsname
}%
\makeatother
\newcounter{testcounter}
\begin{document}
Testing \verb|\newnum| (argument must denote a \LaTeX-counter):
\medskip
\setcounter{testcounter}{1}
\newnum{testcounter}
\setcounter{testcounter}{2}
\newnum{testcounter}
\setcounter{testcounter}{3}
\newnum{testcounter}
\setcounter{testcounter}{4}
\newnum{testcounter}
\bigskip
Testing \verb|\@newnum| (argument must denote a \TeX-number-quantity):
\medskip
\makeatletter
\@newnum{1}%
\@tempcnta=2
\@newnum{\@tempcnta}%
\setcounter{testcounter}{3}
\@newnum{\value{testcounter}}%
\@newnum{`\^^D}
\makeatother
\end{document}
I couldn't patch it, but here is a code to redefine the environment (or define your own subequations environment):
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\makeatletter%
\def\newnum#1{\expandafter\@newnum\csname c@#1\endcsname}
\def\@newnum#1{%
\ifcase#1\or semel\or bis\or ter\or quater\or quinquies\or sexies\or septies\or octies\or nonies\else\@ctrerr\fi}
\renewenvironment{subequations}{%
\refstepcounter{equation}%
\protected@edef\theparentequation{\theequation}%
\setcounter{parentequation}{\value{equation}}%
\setcounter{equation}{0}%
\def\theequation{\theparentequation\,\newnum{equation}}%
\ignorespaces
}{%
\setcounter{equation}{\value{parentequation}}%
\ignorespacesafterend
}
\makeatother
\begin{document}
\setcounter{equation}{3}
\begin{equation}\label{eq}
a = b
\end{equation}
\begin{subequations}
\begin{align}
f(x) &= ax +b +c \\
&= x \left(a + \frac{b}{x} + \frac{c}{x} \right) \\
&= ax + x \left( \frac{b}{x} + \frac{c}{x} \right)
\end{align}
\end{subequations}
\end{document}