1

I'm currently redefining numbering in mathematical environments but I'm encountering a problem with subbequations.

I wish I had a numbering system like this:

Eq. 1. (for normal equations)

Eq. 1.A (for subequations)

If I put

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[leqno]{amsmath}
\usepackage{unicode-math}
\usepackage{etoolbox}
\usepackage{unicode-math}

\makeatletter
    \renewcommand\theequation{%
        \@arabic\c@equation.%
    }

    \renewcommand\tagform@[1]{%
        \maketag@@@{%
        \textbf{\textsc{Eq}.~\ignorespaces#1\unskip}
    }%
}
\makeatother

\patchcmd\subequations
    {\def\theequation{\theparentequation\alph{equation}}}
    {\def\theequation{\theparentequation\protect\Alph{equation}}}
    {}
    {\FAIL}

\begin{document}
\begin{equation}
(a+b)^2 = a^2 + 2 a b + b^2
\label{eq1}
\end{equation}

Some text... \ref{eq1}

\begin{subequations}
    \begin{equation}
    f(x) = a x + b
    \end{equation}
    \begin{equation}
    g(x) = q x + s
    \end{equation}
    \begin{equation}
    h(x) = t x + b
    \end{equation}
\end{subequations}
\end{document}

I've got Eq. 1.A. But if I use \ref{eq1} for instance, I've got 1. instead of 1.

If I put

\renewcommand\theequation{%
    \@arabic\c@equation%
}
\renewcommand\tagform@[1]{%
    \maketag@@@{%
        \textbf{\textsc{Eq}.~\ignorespaces#1.\unskip}
    }%
}
\patchcmd\subequations % nouvelle numérotation pour les sous-équations
    {\def\theequation{\theparentequation\alph{equation}}}
    {\def\theequation{\theparentequation.\protect\Alph{equation}}}
    {}
    {\FAIL}

I don't have a problem with \ref{eq1} but I've got Eq. 1.A..

Additional information:

@egreg It's a command I defined to number the equations, but I've replaced it here with Alph{} to simplify things and I forget to remove it. Thank you for pointing that out to me.

Thank you @muzimuzhi ! But that's not exactly what I'd like. For normal equations I would like to have a point after the equation number.

So the correct numbering would be:

Eq. 1.

Eq. 2.A

Eq. 2.B

Eq. 2.C

So there would be a dot "." after the Arabic numbers, but nothing after the capital letters.

4
  • Welcome to TeX. SE!
    – Zarko
    Mar 23, 2020 at 16:45
  • 1
    Please provide a full minimal example for this instead of posting sniplets. Otherwise we have to guess and those guesses might not fit your setup
    – daleif
    Mar 23, 2020 at 17:04
  • What's \latinnum?
    – egreg
    Mar 23, 2020 at 17:53
  • Check my updated answer. Mar 23, 2020 at 21:17

1 Answer 1

2

In the following example, I provide a strange-defined \p@equation which is used inside \stepcounter{<counter>}. There may be more elegant solution.

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[leqno]{amsmath}
\usepackage{etoolbox}
\usepackage{unicode-math}

\makeatletter
\renewcommand\theequation{%
  \@arabic\c@equation.%
}

\renewcommand\tagform@[1]{%
  \maketag@@@{%
    \textbf{\textsc{Eq}.~\ignorespaces#1\unskip}
  }%
}


\patchcmd\subequations
    {\def\theequation{\theparentequation\alph{equation}}}
    {\def\theequation{\theparentequation\Alph{equation}}}
    {}
    {\FAIL}

\def\p@equation#1{\expandafter\delete@trailing@dot\expanded{#1}.\@nil}
\def\delete@trailing@dot#1.#2.#3\@nil{\ifx\relax#2\relax#1\else#1.#2\fi}
\makeatother

\begin{document}

\begin{equation}
  (a+b)^2 = a^2 + 2 a b + b^2 \label{eq1}
\end{equation}

Some text... \ref{eq1} and \ref{eq2a}

\begin{subequations}
  \begin{align}
    f(x) = a x + b \label{eq2a}\\
    g(x) = q x + s \\
    h(x) = t x + b
  \end{align}
\end{subequations}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .