1

I have the following codes that label equations the usual way:

\begin{align}
  \partial^2 EU/\partial \alpha \partial \widebar{d}&= U'(\epsilon)[G_{\alpha}(\alpha,\theta,\epsilon) - \widebar{P} C_{\alpha}(\alpha,\theta)] - U'(0)[G_{\alpha}(\alpha,\theta,0) - C_{\alpha}(\alpha,\theta)], \label{eqn:21}
\end{align}
\begin{align}  
  \partial^2 EU/\partial \theta \partial \widebar{d} &= U'(\epsilon)[G_{\theta}(\alpha,\theta,\epsilon) - \widebar{P} C_{\theta}(\alpha,\theta)] + U'(0) [C_{\theta}(\alpha,\theta) - G_{\theta}(\alpha,\theta,0)]. \label{eqn:22}
\end{align}\\ 

Output:

enter image description here

Instead of numbers I want to label the equations as A.21 and A.22. Any suggestions on how I do that?

Here is what I have in my preamble:

\documentclass[12pt,reqno]{amsart}

% Packages
\usepackage[onehalfspacing]{setspace}
\usepackage{graphicx}
\usepackage{amssymb,amsthm}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{float}
\makeatletter
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
\newcommand*\widebar[1]{%
  \begingroup
  \def\mathaccent##1##2{%
    \rel@kern{0.8}%
    \overline{\rel@kern{-0.8}\macc@nucleus\rel@kern{0.2}}%
    \rel@kern{-0.2}%
  }%
  \macc@depth\@ne
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
  \macc@set@skewchar\relax
  \let\mathaccentV\macc@nested@a
  \macc@nested@a\relax111{#1}%
  \endgroup
}
\makeatother
\usepackage{cite}
%\usepackage{natbib}
%\bibpunct{(}{)}{;}{;}{,}{,}
\usepackage{xr-hyper}
\usepackage[
  colorlinks=true,
  citecolor=blue,
  urlcolor=blue,
  linkcolor=blue
]{hyperref}
\usepackage{bm}
\usepackage{fullpage}
\usepackage{ amssymb }
\usepackage{caption} 
\usepackage{forest}
\captionsetup{labelfont=normalfont,
              labelsep=colon}
\usepackage{mathabx}
\usepackage{subfig}
\usetikzlibrary{arrows.meta,shapes,positioning}
%
\tikzset{
    full/.style={circle,draw,inner sep=0, minimum size=1mm,fill=black},
    every node/.style={minimum height=5mm,font=\footnotesize}
}
%
\makeatletter
\def\subsection{\@startsection{subsection}{1}%
  \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
  {\normalfont\itshape}}
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \edef\@toclevel{\ifnum#2=\@m 0\else\number#2\fi}%
  \ifnum #2>\c@secnumdepth \let\@secnumber\@empty
  \else \@xp\let\@xp\@secnumber\csname the#1\endcsname\fi
  \@tempskipa #5\relax
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \edef\@secnumpunct{%
      \ifdim\@tempskipa>\z@ % not a run-in section heading
        \@ifnotempty{#8}{.\@nx\enspace}%
      \else
        \@ifempty{#8}{.}{.\@nx\enspace}%
      \fi
    }%
    \@ifempty{#8}{%
      \ifnum #2=\tw@ \def\@secnumfont{\bfseries}\fi}{}%
    \protected@edef\@svsec{%
      \ifnum#2<\@m
        \@ifundefined{#1name}{}{%
          \ignorespaces\csname #1name\endcsname\space
        }%
      \fi
      \@seccntformat{#1}%
    }%
  \fi
  \ifdim \@tempskipa>\z@ % then this is not a run-in section heading
    \begingroup #6\relax
    \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty\@M #8\par}%
    \endgroup
    \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
  \else
  \def\@svsechd{#6\hskip #3\@svsec
    \@ifnotempty{#8}{\ignorespaces#8\unskip
       %\@addpunct.
       }%
    \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
  }%
  \fi
  \global\@nobreaktrue
  \@xsect{#5}}
\makeatother

\pagestyle{plain}

\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{12pt}

\setcounter{secnumdepth}{2}

\allowdisplaybreaks[4]
% Commenting/debugging
\let\IG\iffalse
\let\ENDIG\fi

%% Shortcuts
\newcommand{\td}[2]{\dfrac{d #1}{d #2}}
\newcommand{\std}[2]{\dfrac{d^2 #1}{d {#2}^2}}
\newcommand{\ctd}[3]{\dfrac{d^2 #1}{d #2 d #3}}

\newcommand{\pd}[2]{\dfrac{\partial #1}{\partial #2}}
\newcommand{\spd}[2]{\dfrac{\partial^2 #1}{\partial {#2}^2}}
\newcommand{\cpd}[3]{\dfrac{\partial^2 #1}{\partial #2 \partial #3}}

\newcommand{\pdi}[2]{\partial #1/\partial #2}

\newcommand{\LR}{\Leftrightarrow}
\newcommand{\Lg}{\mathcal{L}}
\newcommand{\half}{\tfrac{1}{2}}
\newcommand{\eqp}{\phantom{=}}
\newcommand{\eqs}{\buildrel s \over =}
\newcommand{\me}{\mathrm{e}}
%begin codes for footnotes (symbols)
\makeatletter
\newcommand*{\myfnsymbolsingle}[1]{%
  \ensuremath{%
    \ifcase#1% 0
    \or % 1
      \dagger%   
    \or % 2
      1 
    \or % 3  
      2
    \or % 4   
      3
    \or % 5
      4
    \else % >= 6
      \@ctrerr  
    \fi
  }%   
}   
\makeatother

\newcommand*{\myfnsymbol}[1]{%
  \myfnsymbolsingle{\value{#1}}%
}

% remove upper boundary by multiplying the symbols if needed
\usepackage{alphalph}
\newalphalph{\myfnsymbolmult}[mult]{\myfnsymbolsingle}{}

\renewcommand*{\thefootnote}{%
  \myfnsymbolmult{\value{footnote}}%
}
%end codes for footnotes (symbols) 
  • 3
    What is A? The section number? Or just \renewcommand{\theequation}{A.\arabic{equation}} I don't think, that the \\ after the last align is necessary – user31729 Jun 5 '15 at 13:49
  • @ChristianHupfer The equations are in the appendix section and so I want to use A.1,A.2,etc. to distinguish the equations in the appendix from the equations in the rest of the paper. – OGC Jun 5 '15 at 13:52
  • 1
    Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – LaRiFaRi Jun 5 '15 at 14:09
3

Since the OP decided to have starred sections, the easiest way is to use

\renewcommand{\theequation}{A.\arabic{equation}}

but not recommended, since this harder to change.

If the equation number should be preceded by the section number or appendix number, then \renewcommand{\theequation}{\thesection.\arabic{equation}} is one way to do this.

Other alternative:

Just say \numberwithin{equation}{section}, this will do effectively the same

Note: The equations are too large or you have to enlarge the textwidth.

\documentclass{article}

%    \usepackage{mathtools} 
\usepackage{amsmath}
\usepackage{mathabx}
\begin{document}

\appendix
\section{First appendix}

\renewcommand{\theequation}{\thesection.\arabic{equation}}

\setcounter{equation}{21}

\begin{align}
  \partial^2 EU/\partial \alpha \partial \widebar{d}&= U'(\epsilon)[G_{\alpha}(\alpha,\theta,\epsilon) - \widebar{P} C_{\alpha}(\alpha,\theta)] - U'(0)[G_{\alpha}(\alpha,\theta,0) - C_{\alpha}(\alpha,\theta)], \label{eqn:21}
\end{align}
\begin{align}  
  \partial^2 EU/\partial \theta \partial \widebar{d} &= U'(\epsilon)[G_{\theta}(\alpha,\theta,\epsilon) - \widebar{P} C_{\theta}(\alpha,\theta)] + U'(0) [C_{\theta}(\alpha,\theta) - G_{\theta}(\alpha,\theta,0)]. \label{eqn:22}
\end{align} 

\end{document}
  • I am getting an error installing mathtools package. It's saying "`mathtools.sty' not found." I am using TexMaker. – OGC Jun 5 '15 at 13:59
  • Okay I will make an update. – OGC Jun 5 '15 at 14:00
  • @user36829 1, 2, 3, 4, and 5. – LaRiFaRi Jun 5 '15 at 14:02
  • It's labelling on the basis of the section number so I have sth like 4.21,4.22,etc. I have \section*{THE APPENDIX}. Didn't number the Appendix section. – OGC Jun 5 '15 at 14:04
  • 2
    @user36829: That was my initial suggestion in the comment above to your question ;-) – user31729 Jun 5 '15 at 14:27
2

Another solution that uses the \newtagform and \usetagform, from mathtools, and the apptools package to automate thu use of these commands.

Additionally, I changed you partial derivatives to fractions, with the easy syntax of the esdiff package. I also loaded the geometry package to keep equations on one line, and grouped the two align environment in a single align.

\documentclass{article}

\usepackage{mathtools}
\usepackage{geometry}
\usepackage[thinc]{esdiff}
\makeatletter
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
\newcommand*\widebar[1]{%
\begingroup
\def\mathaccent##1##2{%
\rel@kern{0.8}%
\overline{\rel@kern{-0.8}\macc@nucleus\rel@kern{0.2}}%
\rel@kern{-0.2}%
}%
\macc@depth\@ne
\let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
\mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
\macc@set@skewchar\relax
\let\mathaccentV\macc@nested@a
\macc@nested@a\relax111{#1}%
\endgroup
}
\makeatother

\newtagform{appendix}{(A.}{)}
\usepackage{apptools}
\AtAppendix{\setcounter{equation}{0}\usetagform{appendix}}

\begin{document}
\setcounter{equation}{20}
\begin{align}
  \diffp{EU}{{\alpha} {\widebar{d}}} & = U'(\epsilon)\bigl(G_{\alpha}(\alpha,\theta,\epsilon) - \widebar{P} C_{\alpha}(\alpha,\theta)\bigr) - U'(0)\bigl(G_{\alpha}(\alpha,\theta,0) - C_{\alpha}(\alpha,\theta)\bigr), \label{eqn:21} \\
  \diffp{EU}{{\theta} {\widebar{d}}} & = U'(\epsilon)\bigl(G_{\theta}(\alpha,\theta,\epsilon) - \widebar{P} C_{\theta}(\alpha,\theta)\bigr) + U'(0) \bigl(C_{\theta}(\alpha,\theta) - G_{\theta}(\alpha,\theta,0)\bigr). \label{eqn:22}
\end{align}

\appendix
\setcounter{equation}{20}
\section
{A first appendix}Blah blah blah
\begin{align}
  \diffp{EU}{{\alpha} {\widebar{d}}} & = U'(\epsilon)\bigl(G_{\alpha}(\alpha,\theta,\epsilon) - \widebar{P} C_{\alpha}(\alpha,\theta)\bigr) - U'(0)\bigl(G_{\alpha}(\alpha,\theta,0) - C_{\alpha}(\alpha,\theta)\bigr), \label{eqn:21} \\
  \diffp{EU}{{\theta} {\widebar{d}}} & = U'(\epsilon)\bigl(G_{\theta}(\alpha,\theta,\epsilon) - \widebar{P} C_{\theta}(\alpha,\theta)\bigr) + U'(0) \bigl(C_{\theta}(\alpha,\theta) - G_{\theta}(\alpha,\theta,0)\bigr). \label{eqn:22}
\end{align}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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