カウンターをリセットするにはどうすればいいですか?

カウンターをリセットするにはどうすればいいですか?

\begin{equation}と の方程式の横に表示されるカウンターをリセットして、\begin{align}最後の宿題の問題で方程式 42 のように数行上の方程式を参照しないようにしたいのですが、その方法はありますか?

編集:

テンプレートに従う必要があるため、セクションを使用できず、\numberwithin使用できません

編集#2:

テンプレートは

\documentclass[letterpaper,12pt,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[letterpaper, top = 1.5in, left = 1in, right = 1in, bottom = 1.5in]  
\usepackage{fancyhdr}       
\usepackage{amsfonts,amsmath,amsthm,amssymb}    

\title{}
\author{Author}     
\date{\today}               

\makeatletter               
\let\Author\@author         
\let\Date\@date             
\makeatother

\newcommand{\Problem}{\relax}
\newcounter{problemcount}
\newcommand{\nextproblem}[1]{\renewcommand{\Problem}{#1}\setcounter{equation {0}\setcounter{page}{0}}

\pagestyle{fancy}
\lhead{\Problem}
\chead{}
\rhead{
\Author
\\
Class
\\
Section
\\
\Date
}

\renewcommand{\headrulewidth}{0.4pt}
\setlength{\headheight}{56.2pt}
\setlength{\parindent}{0pt}

\makeatother

\begin{document}
\nextproblem{Problem 1}
\begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}
\newpage

\nextproblem{Problem 2}\begin{proof}\begin{align*}1+1&=2\\2&=2\end{align*}\end{proof}

\end{document}

答え1

それぞれの問題を別のセクションで説明する場合は、numberwithin提供されるコマンドamsmathパッケージ。例: \numberwithin{equation}{section}。自動的に実行されます\setcounter{equation}{0}

答え2

あなたのコードはそのままではコンパイルされませんでした。いくつか修正を加え、必要な行を追加して、必要な結果を得ました。私の理解が正しければ、ページ番号は問題ごとにリセットされ、方程式番号も同様にリセットされます。

後者の問題は、パッケージをロードすることで解決されますchngcntr。これにより、選択したカウンターが変更されるたびにカウンターをリセットできます。ただし、これはページ カウンターでは機能しませんが、コマンド\page numbering{arabic}を定義するコードにを追加するだけで\nextproblem機能します。

\documentclass[letterpaper,12pt,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[letterpaper, top = 1.5in, left = 1in, right = 1in, bottom = 1.5in]{geometry}
\usepackage{fancyhdr}
\usepackage{amsfonts,amsmath,amsthm,amssymb}
\usepackage{chngcntr}
\title{}
\author{Author}
\date{\today}

\makeatletter
\let\Author\@author
\let\Date\@date
\makeatother

\newcommand{\Problem}{\relax}
\newcounter{problemcount}
\setcounter{problemcount}{0}

\newcommand{\nextproblem}[1]{\clearpage\stepcounter{problemcount}\pagenumbering{arabic}\renewcommand{\Problem}{#1}}
\counterwithin*{equation}{problemcount}

\pagestyle{fancy}
\lhead{\Problem}
\chead{}
\rhead{
\Author
\\
Class
\\
Section
\\
\Date
}

\renewcommand{\headrulewidth}{0.4pt}
\setlength{\headheight}{56.2pt}
\setlength{\parindent}{0pt}

\makeatother

\begin{document}
\nextproblem{Problem 1}
\begin{proof}\begin{align}1+1&=2\\2&=2\end{align}\end{proof}
\newpage

\nextproblem{Problem 2}
\begin{proof}\begin{align}1+1&=2\\2&=2\end{align}\end{proof}

\end{document} 

ここに画像の説明を入力してください

ここに画像の説明を入力してください

関連情報