
다음과 유사한 결과를 얻는 비교적 간단한 방법이 있는지 궁금합니다.
특히, 나는 정리/기본형/명제에 이름 및/또는 숫자를 할당한 다음 해당 정리/기본형/명제의 표준 QED 기호를 정리/기본형/명제 이름의 개요 버전으로 대체할 수 있기를 원합니다. /숫자.
불행히도 정리 환경 수정에 대한 지식이 충분히 낮아서 시작하는 방법에 대한 단서가 전혀 없기 때문에 여기에는 최소한의 작업 예제가 없습니다. 어떤 제안이라도 대단히 감사하겠습니다.
답변1
이것은 당신이 원하는 것을 수행하지만 번거롭고 유익하지 않습니다.
\documentclass{book}
\usepackage{amsthm,xpatch}
\makeatletter
\let\qed@empty\openbox % <--- change here, if desired
\def\@begintheorem#1#2[#3]{%
\deferred@thm@head{%
\the\thm@headfont\thm@indent
\@ifempty{#1}
{\let\thmname\@gobble}
{\let\thmname\@iden}%
\@ifempty{#2}
{\let\thmnumber\@gobble\global\let\qed@current\qed@empty}
{\let\thmnumber\@iden\xdef\qed@current{#2}}%
\@ifempty{#3}
{\let\thmnote\@gobble}
{\let\thmnote\@iden}%
\thm@swap\swappedhead
\thmhead{#1}{#2}{#3}%
\the\thm@headpunct\thmheadnl\hskip\thm@headsep
}\ignorespaces
}
\renewcommand{\qedsymbol}{%
\ifx\qed@thiscurrent\qed@empty
\qed@empty
\else
\fbox{\scriptsize\qed@thiscurrent}%
\fi
}
\renewcommand{\proofname}{%
Proof%
\ifx\qed@thiscurrent\qed@empty
\else
\ of \qed@thiscurrent
\fi
}
\xpretocmd{\proof}{\let\qed@thiscurrent\qed@current}{}{}
\newenvironment{proof*}[1]
{\def\qed@thiscurrent{\ref{#1}}\proof}
{\endproof}
\makeatother
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem*{nthm}{Theorem}
\begin{document}
\chapter{Title}
\section{Title}
\begin{thm}
Pigs can fly.
\end{thm}
\begin{proof}
Would you doubt it?
\end{proof}
\begin{nthm}
Unnumbered.
\end{nthm}
\begin{proof}
What should we say?
\end{proof}
The following theorem will be proved later.
\begin{thm}\label{thm:later}
$P=NP$.
\end{thm}
Long text here.
\begin{proof*}{thm:later}
Oh, well! Should I really do it? We'll use the following lemma.
\begin{lem}
Something surely can fly.
\end{lem}
\begin{proof}
Clear.
\end{proof}
Now use the lemma and apply the well known identity
\[
1=0.\qedhere
\]
\end{proof*}
\end{document}
증명이 지연되면 proof*
상대 정리에서 사용되는 레이블을 인수로 원하는 환경을 사용하십시오.
보시다시피, 증명은 중첩될 수 있습니다. 저는 "지연된" 증명 안에 중첩된 증명만 보여드렸지만 표준 환경에서도 작동하는지 확인할 수 있습니다 proof
.
설명의 일부 단어입니다.
\@begintheorem
먼저 몇 가지 설정을 추가하기 위해 정의를 수정합니다 . 정리에 번호가 지정되어 있지 않으면 (우리가 이미 환경에 있기 때문에 전역적으로) (표준 QED 기호로 정의되어 있으므로 나중에 그 이유를 살펴보겠습니다) \qed@current
로 설정합니다. \qed@empty
정리에 번호가 매겨져 있으면 정리 번호가 포함되어 있기 \xdef\qed@current{#2}
때문에 그렇게 합니다 #2
(그러나 명시적인 형식이 아니므로 완전히 확장해야 함).
정리 숫자에 형식 지정 지침이 포함되어 있거나 다른 숫자 체계가 사용되는 경우( babel
예: 그리스 숫자)는 다음과 같아야 합니다.
\protected@edef\@tempa{#2}\global\let\qed@current\@tempa
문제를 피하기 위해. 표준 영어 설정에서는 이것이 필요하지 않습니다.
이 두 가지 변경 사항 외에는 \@begintheorem
원본과 동일합니다.
그런 다음 재정의합니다 \qedsymbol
. \qed@thiscurrent
와 비교됩니다 \qed@empty
. 동일하면 표준 기호를 조판하고, 그렇지 않으면 조판합니다.
\fbox{\scriptsize\qed@thiscurrent}
왜냐하면 앞으로 보게 되겠지만 에는 \qed@thiscurrent
현재 증명되고 있는 정리의 수가 포함되어 있기 때문입니다.
또한 마지막으로 언급된 정리에 번호가 매겨져 있으면 "of "를 \proofname
추가하도록 재정의됩니다 .<number>
\qed@thiscurrent
환경 이 (로컬 로 proof
) 설정되도록 수정되었습니다 . finally 는 다음과 같은 작업을 수행 하지만 로 번호를 검색하도록 정의되어 있습니다 .\qed@thiscurrent
\qed@current
proof*
proof
\ref
정리를 따르는 간단한 경우 proof
는 쉽습니다. \qed@thiscurrent
정리 번호가 포함됩니다. 에 대해서도 마찬가지입니다 proof*
.
proof
환경이 다른 환경 안에 있는 경우 proof
명령문은 전역적으로 재설정되지만 이는 기본 증명의 끝 부분에 \qed@current
영향을 미치지 않습니다 . 중첩된 증명의 경우 로컬로 설정되고 로컬을 이전 값으로 되돌리기 때문입니다.\qed@thiscurrent
\qed@thiscurrent
\end{proof}
\qed@thiscurrent
답변2
우리가amsthm패키지를 사용하면 명령을 하이재킹 \qedsymbol
하고 정리 환경이 내부적으로 구성되는 방식을 해킹하여 이를 수행할 수 있습니다. 이는 마지막 정리 번호의 박스형 버전이 되도록 \@begintheorem
덮어쓰기 위해 일부 코드를 추가하는 것으로 귀결됩니다 .\qedsymbol
아래 코드에는 두 가지 문제가 있습니다. 첫 번째는 이(가) \qedsymbol
손실되었지만 대신 사용할 수 있다는 것입니다 \realqedsymbol
.
두 번째 문제는 예를 들어 하나의 정리를 진술한 다음 주요 결과로 돌아가기 전에 증명 중간에 다른 보조정리를 증명하면 마지막 상자 숫자가 잘못된다는 것입니다. 이에 대한 가장 간단한 수정은 아마도 다음과 같은 명령을 정의하는 것입니다.
\newcommand\QedSymbol[1]{\gdef\qedsymbol{\fbox{\ref{#1}}}}
\qedsymbol
박스형 명령과 동일하게 수동으로 설정합니다 \ref
. 이것을 사용하려면 \label{MyWondrousTheorem}
(훌륭한) 정리에 대한 참조를 추가하고 \Qedsymbol{MyWondrousTheorem}
증명이 끝나기 전에 사용해야 합니다 .
정리와 유사한 환경 에 정리 번호가 없으면 \qedsymbol
실제 .\realqedsymbol
\qedsymbol
나는 이것을 많이 테스트하지 않았으므로 이것이 무언가를 깨뜨리거나 이것이 작동하지 않는 다른 특수한 경우가 있을 수 있습니다.
코드는 다음과 같습니다.
\documentclass{article}
\usepackage{amsmath,amsthm}
\makeatletter% the hack to change the qedsymbol automatically
\let\@@begintheorem=\@begintheorem% save real AMS theorem environment
\let\realqedsymbol\qedsymbol
\def\@begintheorem#1#2[#3]{%
\@@begintheorem{#1}{#2}[#3]% start the theorem
\@ifempty{#2}{\let\qedsymbol\realqedsymbol}{\gdef\qedsymbol{\fbox{#2}}}
}
\makeatother
\swapnumbers\numberwithin{equation}{section}
\newtheorem{Proposition}[equation]{Proposition}
\newtheorem{Lemma}[equation]{Lemma}
\begin{document}
\section{Important facts}
\begin{Lemma}
$1+1=2$
\end{Lemma}
\begin{proof}Count.
\end{proof}
\begin{Proposition}
$1+3=4$
\end{Proposition}
\begin{proof}Count more carefully.
\end{proof}
\begin{Proposition}
$2+2=4$
\end{Proposition}
\begin{proof}Count more carefully.
\end{proof}
\end{document}
\documentclass{article}
\usepackage{amsmath,amsthm}
\makeatletter
\let\@@begintheorem=\@begintheorem% save real AMS theorem environment
\let\@qedsymbol\qedsymbol
\def\@begintheorem#1#2[#3]{%
\@@begintheorem{#1}{#2}[#3]% start the theorem
\@ifempty{#2}{\let\qedsymbol\@qedsymbol}{\gdef\qedsymbol{\fbox{#2}}}
}
\makeatother
\swapnumbers\numberwithin{equation}{section}
\newtheorem{Proposition}[equation]{Proposition}
\newtheorem{Lemma}[equation]{Lemma}
\begin{document}
\section{Important facts}
\begin{Lemma}
$1+1=2$
\end{Lemma}
\begin{proof}Count.
\end{proof}
\begin{Proposition}
$1+3=4$
\end{Proposition}
\begin{proof}Count more carefully.
\end{proof}
\begin{Proposition}
$2+2=4$
\end{Proposition}
\begin{proof}Count more carefully.
\end{proof}
\end{document}
증명 중간에 중간 결과가 나타나는 문제를 해결하는 또 다른 방법은 \qedsymbol
증명 환경이 시작될 때 재정의되는 것입니다. 그러나 이 접근 방식은 모든 정리와 유사한 환경이 동일한 카운터(내 MWE에서와 같이)를 사용하는 경우에만 가능합니다. 위의 코드는 다른 정리와 유사한 환경에서 다른 카운터를 사용하더라도 작동할(해야 할까요?:) 장점이 있습니다.
답변3
이것은 내가 과거에 사용한 것을 수정한 것입니다(어디에서 얻었는지 확실하지 않음).
암호:
\documentclass{article}
\usepackage{amsmath}
\newcommand*{\QED}[1]{%
\ifmmode% Check for math mode.
\tag*{\fbox{#1}}%
\else%
{\rightskip\fill\parfillskip-\rightskip%
\linepenalty100%
\exhyphenpenalty0%
\linebreak[0] % <-- Need space here (allows for a break.
\hspace*{\fill}\fbox{#1}}%
\fi%
}%
\begin{document}
In text mode you can use \verb|QED| as shown here.\QED{2.2}
You can also use it in math mode
\begin{align*}
F &= ma \\
\implies E &= mc^2\QED{2.3}
\end{align*}
\end{document}
답변4
패키지 를 사용하면 매우 간단하게 ntheorem
재정의할 수 있습니다 \qedsymbol
. 와 결합하여 두 개의 선택적 인수를 취할 수 있는 환경을 xparse
정의합니다 Proof
. 첫 번째는 고전적인 증명 환경의 선택적 인수이지만 괄호로 구분됩니다. 두 번째 선택적 인수는 증명 끝 기호로, 기본값은 정사각형이지만 증명된 정리에 대한 참조일 수 있습니다(실제로는 참조 또는 텍스트). 후자의 경우에는 \fcolorbox
.
예:
\documentclass[A4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[svgnames]{xcolor}
\usepackage{amsfonts,empheq}
\usepackage[amsmath, thref, thmmarks]{ntheorem}
\usepackage{cleveref}
\usepackage{xparse}
\usepackage{chngcntr}
\theoremstyle{plain}
\theoremseparator{.} \theoremheaderfont{\bfseries}
\theorembodyfont{\itshape}
\newtheorem{Thm}{Theorem}[section]
\newtheorem{Lem}{Lemma}%[section]
\theoremstyle{nonumberplain}
\theoremheaderfont{\itshape}
\theorembodyfont{\upshape}
\newtheorem{proof}{Proof}
\NewDocumentEnvironment{Proof}{d() o}
{\IfNoValueTF{#1}{\begin{proof}}{\begin{proof}[#1]}
\IfNoValueTF{#2}{\qedsymbol{\ensuremath{\Box}}}{\qedsymbol{\fcolorbox{red}{Lavender}{\color{red}\upshape#2}}}}%
{\qed\end{proof}}%
\counterwithin{Lem}{Thm}
\begin{document}
\section{Some Not So Standard Results}
\begin{Thm}\label{special}
$ \mathrm{SL}_n(\mathbb{K}) ⊂ \mathrm{ GL}_n(\mathbb{K})$.
\end{Thm}
\begin{Proof}[\Cref{special}]
We shall prove first:
\begin{Lem}\label{basic}
$ \mathrm{SL}_n(\mathbb{K}) ⊂ \mathrm{ GL}_n(\mathbb{K})$.
\end{Lem}
%% First proof of lemma
\begin{Proof}(of the lemma)[\Cref{basic}]
Easy enough.
\end{Proof}
%% Second proof of lemma
\begin{Proof}(another one)
Still easier proof.
\end{Proof}
%% End of theorem proof
Left as an exercise ;\,o)
\end{Proof}
\end{document}