带 qed 标记的版本表示未编号的示例

带 qed 标记的版本表示未编号的示例

考虑以下 MWE

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{examplex}[theorem]{Example}
\newtheorem*{continuedex}{Example \continuedexref\space Continued}
\newtheorem*{example*}{Example}

\newenvironment{examcont}[1]
  {\newcommand{\continuedexref}{\ref*{#1}}\continuedex}
  {\endcontinuedex}

\newenvironment{example}
  {\pushQED{\qed}\renewcommand{\qedsymbol}{$\triangle$}\examplex}
  {\popQED\endexamplex}

\begin{document}
\section{Foo}
\begin{example}
\label{exa:foo}
  A numbered example.
\end{example}
\begin{examcont}{exa:foo}
  An example continued.
\end{examcont}
\begin{example*}
  An unnumbered example.
\end{example*}
\end{document}

这使用 i) 这个回答为示例环境添加结束标记,以及 ii) 这个回答以允许继续举例。

目前,我只有标准示例环境的结束三角形标记。我想为后续示例和星号(未编号)示例都添加结束标记。我该如何实现?

在此处输入图片描述

答案1

符号必须插入到环境的末尾,正确“刷新”,因此使用\hfill\myqedsymbolwhere\myqedsymbol是特定符号的宏包装器(\triangle在本例中)

\documentclass{article}

\usepackage{amsthm}
\usepackage{hyperref}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{examplex}[theorem]{Example}
\newtheorem*{continuedex}{Example \continuedexref\space Continued}
\newtheorem*{example*}{Example}

\newcommand{\myqedsymbol}{\ensuremath{\triangle}}%

\newenvironment{examcont}[1]
  {\newcommand{\continuedexref}{\ref*{#1}}\continuedex}
  {\hfill\myqedsymbol\endcontinuedex}

\newenvironment{example}
  {\pushQED{\qed}\renewcommand{\qedsymbol}{\myqedsymbol}\examplex}
  {\popQED\endexamplex}

\begin{document}
\section{Foo}
\begin{example}
\label{exa:foo}
  A numbered example.
\end{example}
\begin{examcont}{exa:foo}
  An example continued.
\end{examcont}
\begin{example*}
  An unnumbered example.
\end{example*}
\end{document}

在此处输入图片描述

带 qed 标记的版本表示未编号的示例

问题出现在星号环境中,因此最好将其重命名example*并定义example*为包装器环境:

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{examplex}[theorem]{Example}
\newtheorem*{continuedex}{Example \continuedexref\space Continued}
\newtheorem*{examplestarred}{Example}

\newcommand{\myqedsymbol}{\ensuremath{\triangle}}%

\newenvironment{examcont}[1]{%
  \pushQED{\qed}%
  \renewcommand{\qedsymbol}{\myqedsymbol}%
  \newcommand{\continuedexref}{\ref*{#1}}%
  \continuedex%
}{%
  \popQED%
  \endcontinuedex%
}%


\newenvironment{example}{%
  \pushQED{\qed}%
  \renewcommand{\qedsymbol}{\myqedsymbol}%
  \examplex%
}{%
  \popQED%
  \endexamplex%
}%


\newenvironment{example*}{%
  \pushQED{\qed}%
  \renewcommand{\qedsymbol}{\myqedsymbol}%
  \examplestarred%
}{%
  \popQED%
  \endexamplestarred%
}%

\begin{document}
\section{Foo}
\begin{example}
\label{exa:foo}
  A numbered example.
\end{example}
\begin{examcont}{exa:foo}
  An example continued.
\end{examcont}
\begin{example*}
  An unnumbered example.
\end{example*}
\end{document}

在此处输入图片描述

相关内容