
我想重置方程式旁邊出現的計數器\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}