我收到有关我的索赔和索赔证明的警告,内容如下:
pdfTeX 警告(ext4):具有相同标识符(name{claimcount.1})的目标已被使用,重复项被忽略
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox \fi \fi l.38 \end{document} ] (./duplicate identifier.aux) )(有关更多信息,请参阅成绩单文件)<
一切都编译得很好,但我还是想摆脱警告。作为参考,以上是代码的结果(MWE)
\documentclass[a4paper,hidelinks,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm,chngcntr,csquotes,hyperref}
\newcounter{theorem} \numberwithin{theorem}{chapter}
\newcounter{claimcount}
\setcounter{claimcount}{0}
\newtheorem{claim}[claimcount]{Claim}
{\AtBeginEnvironment{proof}{\setcounter{claimcount}{0}}
\theoremstyle{remark}
\newcounter{cproofcount}
\setcounter{cproofcount}{0}
\AtBeginEnvironment{proof}{\setcounter{cproofcount}{0}}
\newtheorem{cproof/}[cproofcount]{Proof of Claim}}
\newenvironment{cproof}
{\renewcommand{\qedsymbol}{$\dashv$}%
\pushQED{\qed}\begin{cproof/}}
{\popQED\end{cproof/}}
%
\title{}
\author{}
\date{}
\begin{document}
\begin{claim} \end{claim}
\begin{cproof} \end{cproof}
\begin{proof}
\begin{claim}
\end{claim}
\end{proof}
\end{document}
我想在每个证明环境中计算声明及其证明,以便编号不会在不同的定理中继续。现在,上述方法有效,但我收到的警告数量等于证明中的声明数量。我该如何实现这一点同时避免警告?
答案1
我们可以proof
用一个隐形的计数器来计数,然后使用 LaTeX\@addtoreset
重新开始计算每个证明中的声明。
我也对你的定义做了一些修改。现在你可以cproof
直接在 a 后面使用claim
来生成 a索赔证明 x。如果您使用可选参数,则cproof
可以给出不同的编号。如果您想要先陈述几个主张,然后再证明它们,这可能会很有用。在这种情况下,您可以使用\label
和\ref
来获得正确的编号。
\documentclass[a4paper,hidelinks,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm,chngcntr,csquotes,hyperref}
\newtheorem{theorem}{Theorem}[chapter]
\newcounter{proofcount}
\AtBeginEnvironment{proof}{\stepcounter{proofcount}}% count the proofs
\newtheorem{claim}{Claim}
\makeatletter % reset the claim counter each time proofcount is
\@addtoreset{claim}{proofcount}% increased, effectively this restarts the claims
\makeatother % at 1 for each proof
\theoremstyle{remark}
\makeatletter
% \rev@cproofmark will hold the number of the claim we set out to prove
\newtheorem*{cproof/}{Proof of Claim \rev@cproofmark}
% cproof now has an optional argument to feed it the number of the claim
% we want to prove, if the argument is not given the number of the last claim is used
% code for the optional argument by David Carlisle
% https://tex.stackexchange.com/a/217763/35864
\newenvironment{cproof}[1][\@nil]
{\def\@tmp{#1}%
\ifx\@tmp\@nnil
\def\rev@cproofmark{\theclaim}% no optional argument: take last claim
\else
\let\rev@cproofmark\@tmp% take the argument
\fi
\renewcommand{\qedsymbol}{$\dashv$}%
\pushQED{\qed}\begin{cproof/}}
{\popQED\end{cproof/}}
\makeatother
\begin{document}
\chapter{Lorem}
\begin{theorem}
Ipsum dolor
\[ 1+1=2\]
\end{theorem}
\begin{proof}
\begin{claim}
Foo
\end{claim}
\begin{cproof}% here the numebr is picked up automatically
Foo
\end{cproof}
\begin{claim}
Bar
\end{claim}
\begin{cproof}
Foo
\end{cproof}
\end{proof}
\begin{theorem}
Ipsum dolor
\[ 2+2=4\]
\end{theorem}
\begin{proof}
\begin{claim}\label{claim:two:one}
Foo
\end{claim}
\begin{claim}\label{claim:two:two}
Bar
\end{claim}
\begin{cproof}[\ref{claim:two:one}]% manual numbering
Foo
\end{cproof}
\begin{cproof}[\ref{claim:two:two}]
Foo
\end{cproof}
\end{proof}
\end{document}