2

I'm new to LaTeX. I'm using IEEEeqnarrayto align equations in my document (a compilation of solved problems), and I'd like to change equation numbering to (x,y) where x is the question number and y is the equation number (which resets with each question). Also I'd be using this within an enumerate environment, so I'd like the question number x to always match the item number.

If possible, please edit the sample below to make it work as described. I included the packages I'm using in my document to ensure compatibility. Thanks!

\documentclass[notitlepage]{article}
\usepackage{amsmath,amssymb,amsthm,mathrsfs}
\usepackage{IEEEtrantools,nccmath}
\usepackage[margin=1in]{geometry}

\begin{document}

This is a test file for custom equation numbering.
\begin{enumerate}
\item The equations below should be labeled (1.1), unlabeled, and labeled (1.2), in order from top to bottom.
    \begin{IEEEeqnarray}{rCl}
        1+1 & = & 2 \\
        1+2 & = & 3 \nonumber \\
        2+3 & = & 5
    \end{IEEEeqnarray}
\item The equations below should be labeled (2.1), unlabeled, and labeled (2.2), in order from top to bottom.
    \begin{IEEEeqnarray}{rCl}
        3+5  & = & 8 \\
        5+8  & = & 13 \nonumber \\
        8+13 & = & 21
    \end{IEEEeqnarray}
\end{enumerate}

\end{document}

2
  • Welcome to TeX.SX! How should the equations be numbered outside of an enumerate environment?
    – Vincent
    Commented May 16, 2020 at 0:43
  • @Vincent Thank you! I'm using an enumerate environment that covers my entire document, so there won't be any equations outside it that need to be numbered.
    – Francis M
    Commented May 16, 2020 at 1:17

1 Answer 1

0

You can use the command \numberwithin from amsmath. This command takes two arguments, both supposed to be counters. Using \numberwithin{<counter1>}{<counter2>} will reset <counter1> every time <counter2> is increased. It will also redefine how a number from <counter1> is displayed, representing it in the form "x.y", where x is the current <counter2> value, and y is the current <counter1> value.

The following example should work for your specific case.

\documentclass[notitlepage]{article}
\usepackage{amsmath,amssymb,amsthm,mathrsfs}
\usepackage{IEEEtrantools,nccmath}
\usepackage[margin=1in]{geometry}

\numberwithin{equation}{enumi}

\begin{document}

This is a test file for custom equation numbering.
\begin{enumerate}
\item The equations below should be labeled (1.1), unlabeled, and labeled (1.2), in order from top to bottom.
    \begin{IEEEeqnarray}{rCl}
        1+1 & = & 2 \\
        1+2 & = & 3 \nonumber \\
        2+3 & = & 5
    \end{IEEEeqnarray}
\item The equations below should be labeled (2.1), unlabeled, and labeled (2.2), in order from top to bottom.
    \begin{IEEEeqnarray}{rCl}
        3+5  & = & 8 \\
        5+8  & = & 13 \nonumber \\
        8+13 & = & 21
    \end{IEEEeqnarray}
\end{enumerate}

\end{document}

3
  • I think this will work, but what are the parameters of \numberwithin? Just in case I need to change something in the future
    – Francis M
    Commented May 16, 2020 at 1:57
  • @FrancisGerardMagtibay I added some details in my answer, let me know if it's clearer now.
    – Vincent
    Commented May 16, 2020 at 2:11
  • @FrancisGerardMagtibay No problem! :) To get used to the mechanics of the site, you could visit the help center, for example here.
    – Vincent
    Commented May 16, 2020 at 3:28

You must log in to answer this question.

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