2

Objective

Hi. I define a counter, say, no for my customized commands, such as

\newcounter{no}
\counterwithin{no}{chapter}
\newcommand{\no}{\refstepcounter{no}%
                 \theno}
\newcommand{\df}{\normalfont{\textbf{Definition \no}}\;}

Now I would like the equation counter (\theequation) follows the customized counter \thno.

How I use customized counter and what I expect

For example,

\chapter{A chapter}
\begin{itemize}
\item[] \df This is some definition.
\end{itemize}

\begin{equation}
some equation.
\end{equation}

I expect the result would be

Definition 1.1 This is some definition.

                                    some equation.                                 (1.2)

What I've tried

  1. I've tried

    \let\theequation\theno
    

    but \theequation does not update in equation environment; the temporary remedy for using equation environment is

    \addtocounter{no}{1}   % update the counter
    \begin{equation}
    ...
    \end{equation}
    

    but that is annoying.

  2. Since the customized counter no is NOT used for new environment, remedy using \newtheorem does not fit for me.

  3. I've tried

    \let\theequation\theno
    \renewenvironment{equation}{\refstepcounter{no}\begin{equation}}{\end{equation}}
    

    or

    \renewenvironment{equation}{\refstepcounter{no}\begin{equation}}{\tag{\theno}\end{equation}}
    

    but they all give the error message: ! TeX capacity exceeded, sorry [save size=200000].

  • By the way, I also wish that the counter of align can follow the customized counter no so that the numbering of no, equation, and algin are consecutive.

Could anyone help? Thanks.

New contributor
HRC is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1

2 Answers 2

4

You just want to use equation.

\documentclass{book}

\counterwithin{equation}{chapter}

\newcommand{\no}{\refstepcounter{equation}\theequation}

\newcommand{\df}{\textbf{Definition \no}\enspace\ignorespaces}

\begin{document}

\chapter{A chapter}

\df This is some definition.
\begin{equation}
some equation.
\end{equation}

\end{document}

Note that \normalfont is not a command taking an argument like \textbf. Anyway, I'm not sure why not using standard tools such as \newtheorem.

enter image description here

Better code, in my opinion:

\documentclass{book}
\usepackage{amsthm}

\counterwithin{equation}{chapter}

%\newcommand{\no}{\refstepcounter{equation}\theequation}

\theoremstyle{definition}
\newtheorem{df}[equation]{Definition}

\begin{document}

\chapter{A chapter}

\begin{df}
This is some definition.
\begin{equation}
some equation.
\end{equation}
\end{df}

\end{document}
0
2

Is this what you want?

enter image description here

\documentclass{report}
\usepackage{amsmath,amsthm}
\newtheorem{definition}[equation]{Definition}
\begin{document}
\chapter{AAAAA}

\begin{definition}
  hello
\end{definition}

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

\begin{definition}
  world
\end{definition}

\begin{equation}
  c=d
\end{equation}

\begin{definition}
  foo
\end{definition}

\begin{align}
  a & = b \\
    & = c
\end{align}
\end{document}
1
  • Hi. Thanks for replying. The numbering, yes. But the definition is not in environment.
    – HRC
    May 15 at 5:58

You must log in to answer this question.

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