0

I have three equations in an align environment which I'd like to be numbered as follows: (1a), (1b), (2) [The numbers are just indicative; I don't want them to be exactly 1 and 2]

With subequations I can easily get the numbering (1a), (1b), (1c)

\documentclass{article}
\usepackage{amsmath}

\begin{document}
%
\begin{subequations}
    \begin{align}
        \mathbf{a} &= \begin{bmatrix}
                    a_1\\
                    \vdots \\
                    a_2
                \end{bmatrix} \label{eq:1a} \\        
        &= \left[ a_1 \ \ldots \ a_2 \right]^\mathrm{T} \label{eq:1b}\\
        %
        \mathbf{b} &= \left[ b_1 \ldots \b_2 \right]^\mathrm{T}, \label{eq:2}
    \end{align}
\end{subequations}
%


\end{document}

Using some code found here, I can increase by one the third equation number, obtaining (1a), (1b), (2a), but that's still not what I want

\documentclass{article}
\usepackage{amsmath}

\renewenvironment{subequations}[1][]{%              optional argument: label-name for (first) parent equation
  \refstepcounter{equation}%
%  \def\theparentequation{\arabic{parentequation}}% we patched it already :)
  \setcounter{parentequation}{\value{equation}}%    parentequation = equation
  \setcounter{equation}{0}%                         (sub)equation  = 0
  \def\theequation{\theparentequation\alph{equation}}%
  \let\parentlabel\label%                           Evade sanitation performed by amsmath
  \ifx\\#1\\\relax\else\label{#1}\fi%               #1 given: \label{#1}, otherwise: nothing
  \ignorespaces
}{%
  \setcounter{equation}{\value{parentequation}}%    equation = subequation
  \ignorespacesafterend
}

\newcommand*{\nextParentEquation}[1][]{%            optional argument: label-name for (first) parent equation
  \refstepcounter{parentequation}%                  parentequation++
  \setcounter{equation}{0}%                         equation = 0
  \ifx\\#1\\\relax\else\parentlabel{#1}\fi%         #1 given: \label{#1}, otherwise: nothing
}

\begin{document}
%%
\begin{subequations}
    \begin{align}
        \mathbf{a} &= \begin{bmatrix}
                    a_1\\
                    \vdots \\
                    a_2
                \end{bmatrix} \label{eq:1a} \\        
        &= \left[ a_1 \ \ldots \ a_2 \right]^\mathrm{T} \label{eq:1b}\\ \nextParentEquation
        %
        \mathbf{b} &= \left[ b_1 \ \ldots \ b_2 \right]^\mathrm{T}, \label{eq:2}
    \end{align}
\end{subequations}
%%


\end{document}

Does anyone know how to modify the code to obtain exactly (1a), (1b), (2)?

gbernardi
  • 845
  • I think that this is essentially the same question: http://tex.stackexchange.com/questions/313367/block-of-equations-with-only-some-being-subequations Do you agree? – egreg Jul 05 '16 at 15:12
  • Dang it! Yes, that seems to be what I need. Sorry I couldn't find it before posting and thanks for pointing it out. – gbernardi Jul 05 '16 at 15:18
  • Can we close this one? – egreg Jul 05 '16 at 15:29
  • I tried to use the solution from the other question in a MWE and it works, but if I try to use it in the document where I need it, it doesn't work anymore and outputs this Any idea of any package that could be causing the clash? Otherwise I'll try to fiddle around with the different packages I'm using. – gbernardi Jul 05 '16 at 15:50
  • Did you run LaTeX twice? Anyway, since the code there does the job, it's better to close this question as duplicate. Try and make a minimal example that fails and open a new question. – egreg Jul 05 '16 at 15:52
  • Yes, I did run LaTeX twice.

    I tried to remove the packages one by one and the problem arises when I include cleveref

    – gbernardi Jul 05 '16 at 15:58
  • Please, ask a new question, then. I can see that the code may conflict with cleveref. Having a real example can help solve the problem. – egreg Jul 05 '16 at 15:59
  • Ok. Will do that. Thanks again for the help. – gbernardi Jul 05 '16 at 16:00
  • I think I have a solution. – egreg Jul 05 '16 at 16:29

0 Answers0