[Tex/LaTex] subequations customize arabic numbering in aligned environment

subequations

i've a rather simple problem for the experts out there! 🙂

using subequations, it automatically enumerates the subequations in alphabetic order.

is there a way to obtain instead an arabic-enumeration? like

Eq: … (1)

Eq: … (2)

Eq: … (3.1)

Eq: … (3.2)

Eq: … (4)

… and so on

Here is my MWE:

\documentclass[10pt,twoside]{article}    
\usepackage{chadstyle} % Loads my formatting 
\usepackage{url} 
\usepackage{hyperref} 
\usepackage{amssymb} 
\usepackage{amsthm, etoolbox} 
\usepackage[title,titletoc]{appendix} 
\usepackage{pdflscape} 
\usepackage{mathtools} 
\usepackage{multirow} 
\usepackage{tabularx} 
\usepackage{placeins} % rotating Tables 
\usepackage{rotating} % coloring table columns and rows 
\usepackage{colortbl}

\newcolumntype{a}{>{\columncolor[gray]{.8}}c} 
\newcolumntype{b}{>{\columncolor{white}}c}

\patchcmd{\subequations}{\def\theequation{\theparentequation\alph{equation}}}% 
{\def\theequation{\theparentequation.\arabic{equation}}}{}{}

%some shortcut commands ....

\begin{document}

\section{Model}

\begin{subequations} 
\begin{align} Y_m &= X P_m^{-\sigma_x} \label{eq:Demand_Yg} \\ 
Y_s &= X P_s^{-\sigma_x} \label{eq:Demand_Ys} 
\end{align} 
\end{subequations}

\end{document}

Would it be possible to embed the patch within this chadstyle package? As you see, I've already put in the beginning. Thanks!

%  chadstyle.sty   Chad Jones, 5/1/08
%
%  Chad's style file for nice paper format.
%  Various ideas for this style are taken from
%    -- Matthias Doepke and Michele Tertilt
%    -- Tony Roberts

\special{papersize=8.5in,11in}
%\usepackage{palatino,amssymb,amsfonts,amsmath,latexsym,setspace}
\usepackage{utopia,amssymb,amsfonts,latexsym,setspace}

\usepackage{amsthm, etoolbox}
\patchcmd\subequations
{\theparentequation\alph{equation}}
{\subequationsformat}
{}{}

\newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}

\usepackage[dvips]{graphicx}
\usepackage{fancyhdr}
\usepackage[longnamesfirst]{natbib}


% example file to change the style of LaTeX
% Tony Roberts May 2004
% first colour for latex or pdflatex
\ifx\pdfoutput\@undefined\usepackage[usenames,dvips]{color}
\else\usepackage[usenames,dvipsnames]{color}
% and fix pdf colour problems
\IfFileExists{pdfcolmk.sty}{\usepackage{pdfcolmk}}{} 
\fi

% Chad's colors:
% See http://web.njit.edu/~kevin/rgb.txt.html for possibilities
\definecolor{ChadDarkBlue}{rgb}{.1,0,.2}  
\definecolor{ChadBlue}{rgb}{.1,.1,.5}  
\definecolor{ChadRoyal}{rgb}{.2,.2,.8}  
%\definecolor{ChadGreen}{rgb}{0,.35,.1}
%\definecolor{ChadGreen}{rgb}{0,.5,.25}  % Too bright
%\definecolor{ChadGreen}{rgb}{0,.4,.2}    % Still too bright
\definecolor{ChadGreen}{rgb}{0,.4,0}    % Dark Green
%\definecolor{ChadRed}{rgb}{.8,.1,.2}    % Too bright
\definecolor{ChadRed}{rgb}{.5,0,.5}  % purple

%%% HYPERLINKS %%%%%%%%%%%%%%%%%%%%%
\usepackage[colorlinks,breaklinks,
 bookmarks=false,
 pdfstartview=Fit,  % for fitting entire page; FitW just fits width
 pdfview=Fit,       % after traversing a hyperlink
 linkcolor=ChadRed,
 urlcolor=ChadGreen,
 citecolor=Black,
 hyperfootnotes=false
     ]{hyperref}
\usepackage[figure,table]{hypcap} % Correct a problem with hyperref
\urlstyle{rm} %so it doesn't use a typewriter font for url's.

%%%%%%%%%%%%%%%%%%%%%


% Fix title, sections, etc.

\let\LaTeXtitle\title
\renewcommand{\title}[1]{\LaTeXtitle{\color{ChadBlue}{\LARGE #1}}}
\renewcommand{\abstractname}{\color{ChadBlue}Abstract}
\renewcommand{\figurename}{\color{ChadBlue}Figure}
\renewcommand{\tablename}{\color{ChadBlue}Table}

\let\LaTeX@startsection\@startsection 
\renewcommand{\@startsection}[6]{\LaTeX@startsection%
{#1}{#2}{#3}{#4}{#5}{\color{ChadBlue}\raggedright #6}} 

% Fix periods at end of section numbers 
%\renewcommand \thesection {\@arabic\c@section.}
%\renewcommand\thesubsection   {\thesection\@arabic\c@subsection.}
%\renewcommand\thesubsubsection{\thesubsection \@arabic\c@subsubsection.}


% Margin, Paragraph Setup
\onehalfspacing
\textheight=23cm \textwidth=17cm \topmargin=-8.5mm 
%default: \textheight=22cm \textwidth=16cm \topmargin=-6.5mm
\oddsidemargin=3mm \evensidemargin=3mm
%\setlength{\parindent}{0em} 
%\setlength{\parskip}{1.5ex plus0.5ex minus0.5ex}
%\setlength{\parsep}{0pt}
 \setlength{\parskip}{0pt}

% This is how to control linespacing using setspace
% (\singlespacing or doublespacing just call this command)
\setstretch{1.4}

%% Setting up page headers
\pagestyle{fancy}
\rhead[]{\thepage}
\lhead[\thepage]{}
\cfoot[]{} 
\renewcommand{\headrulewidth}{0pt}

\newcommand{\runningheads}[2]{
\chead[\color{ChadGreen}{\uppercase {\footnotesize #1}}]  % Author page header
{\color{ChadGreen}{\uppercase {\footnotesize #2}}}  % Short title
}

% Make hyperlinks jump more accurately
\makeatletter
\newcommand\org@hypertarget{}
\let\org@hypertarget\hypertarget
\renewcommand\hypertarget[2]{%
\Hy@raisedlink{\org@hypertarget{#1}{}}#2%
} \makeatother 


% Spacing in Tables and Figures
%\renewcommand{\tabcolsep}{1pt}   % space between columns
\renewcommand{\arraystretch}{1.5} % space between rows
\addtolength{\textfloatsep}{0pt} % space between floats and text
\addtolength{\abovecaptionskip}{0pt} % space above caption
\addtolength{\belowcaptionskip}{.15in} % space below caption

\newcommand{\spc}[0]{\vspace{.1in}}
\newcommand{\fignote}[2]{\begin{center}\parbox[c]{#1}{\footnotesize #2} \end{center}}
\newcommand{\tabnote}[2]{\begin{center}\parbox[c]{#1}{\footnotesize #2} \end{center}}

Dear all,
I've found the solution to the problem using chadstyle package. I've simply included the command within the subequation environment:

 \documentclass[10pt,twoside]{article}
 \usepackage{amsthm, etoolbox}
 .
 .
 .
 \begin{document}
 .
 .
 .
 \begin{subequations}
 \newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}
  \begin{align}
    a = b \\
    c = d
  \end{align}
 \end{subequations}
 .
 .
 .
 \end{document}

Thanks for your time and all the suggestions!
Best, E

Best Answer

The amsmath package doesn't provide an interface for changing the appearance of the equation numbers in subequations, but we can add one with etoolbox:

\documentclass{article}
\usepackage{amsmath,etoolbox}

\patchcmd\subequations
 {\theparentequation\alph{equation}}
 {\subequationsformat}
 {}{}

\newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}

\begin{document}

Some text
\begin{equation}
1=1
\end{equation}
some text
\begin{subequations}
\begin{gather}
2=2\\
3=3
\end{gather}
\end{subequations}
some text
\begin{equation}
0=0
\end{equation}

\end{document}

Basically I remove the default setting passing control to a macro that's user definable. Modify \subequationsformat to suit your taste.

enter image description here


With hyperref it's slightly more complicated in that the patch has to be done before loading hyperref.

\documentclass[10pt,twoside]{article}    
%\usepackage{chadstyle} % Loads my formatting 
\usepackage{url} 
\usepackage{amssymb} 
\usepackage{amsthm, etoolbox} 
\usepackage[title,titletoc]{appendix} 
\usepackage{pdflscape} 
\usepackage{mathtools} 
\usepackage{multirow} 
\usepackage{tabularx} 
\usepackage{placeins} % rotating Tables 
\usepackage{rotating} % coloring table columns and rows 
\usepackage{colortbl}

\patchcmd\subequations
  {\theparentequation\alph{equation}}
  {\subequationsformat}
  {}{}

\usepackage{hyperref} 

\newcolumntype{a}{>{\columncolor[gray]{.8}}c} 
\newcolumntype{b}{>{\columncolor{white}}c}

\newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}


%some shortcut commands ....

\begin{document}

\section{Model}

\begin{subequations} 
\begin{align} Y_m &= X P_m^{-\sigma_x} \label{eq:Demand_Yg}\\
Y_s &= X P_s^{-\sigma_x} \label{eq:Demand_Ys} 
\end{align} 
\end{subequations}

\ref{eq:Demand_Yg}

\end{document}

None of your packages should be loaded after hyperref. Check with those you have in chadstyle (I can't know what's in it).