Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
1  
Welcome to TeX.SX! Please give us a minimal code which shows your subequations. We don't want to guess around here. –  LaRiFaRi Jul 7 at 9:24
    
Dear LaRiFaRi, thanks for your quick reply. unfortunately, it's not working! –  esco Jul 7 at 9:55
    
You are missing one backslash after `\label{eq:Demand_Yg} ` –  LaRiFaRi Jul 7 at 10:42
    
What is hiding in chadstyle.sty? –  Andrew Swann Jul 7 at 10:49
    
You can see the importance of a minimal example: the information about the presence of hyperref was essential. –  egreg Jul 7 at 10:59

2 Answers 2

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).

share|improve this answer
    
chadstyle is simply a customized package for layout and font style. –  esco Jul 7 at 11:20

The subequations environment has the format hard coded in to it, so it is not so straightforward to change. The simplest solution is to patch the definition:

Sample output

\documentclass{article}

\usepackage{amsmath}
\usepackage{etoolbox}

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

\begin{document}

\begin{equation}
  a = b
\end{equation}

\begin{subequations}
  \begin{align}
    c &=d \\
    e &=f
  \end{align}
\end{subequations}

\begin{align}
  g &= h\\
  i &= j
\end{align}

\end{document}
share|improve this answer
    
I've tried without chadstyle package, and it works!!! Thanks to all of you! –  esco Jul 7 at 12:13
    
would it be possible to add this chadstyle package, and someone takes a brief look at it to see if it's possible to embed the patch somewhere there? Thanks! –  esco Jul 7 at 12:15
    
If it is not too big then you can add the code to your question. –  Andrew Swann Jul 7 at 13:01
    
Dear Andrew, I've added the code in my answer. Best, E –  esco Jul 7 at 13:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.