环境的延续

环境的延续

我在我的文本中使用了一个连续的例子,但我不知道如何定义相应的良好环境。

我正在使用 amsmath 和 ntheorem 包并定义了我自己的示例环境:

\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{example}[theorem]{Example}

我正在使用以下文档类:

\documentclass[11pt,a4paper,twoside,openright]{book}

我希望能够继续这个例子,也许像这样

\begin{example} \label{ex1}
 This is an example.
\end{example}

Some text stands here. And then there is some space between this and the continued example. 
Further should the continued example not be intended but start at the beginning of the line.

\begin{continuance}[\ref{ex1}]
This is the continued example.
\end{continuance}

Some more text, which should follow after a little vertical space.

结果是:

例 1.1这是一个例子。

此处保留了一些文本。然后,此文本与后续示例之间有一些空格。此外,后续示例不应是有意为之,而应从行首开始。

例 1.1 的延续这是继续的例子。

还有一些文本,应位于一小段垂直空间之后。

我该如何定义这个持续环境?

编辑:现在的问题是它看起来像这样

例 1.1这是一个例子。

此处保留了一些文本。然后,此文本与后续示例之间有一些空格。此外,后续示例不应是有意为之,而应从行首开始。
[此处是缩进] 示例 1.1 的延续这是继续的例子。
还有一些文本,应位于一小段垂直空间之后。

答案1

您可以使用\newtheorem*

\documentclass{book}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{example}[theorem]{Example}
\newtheorem*{continuancex}{Continuance of Example \continuanceref}
\newenvironment{continuance}[1]
  {\newcommand\continuanceref{\ref{#1}}\continuancex}
  {\endcontinuancex}

\begin{document}
\chapter{Title}
\begin{example} \label{ex1}
 This is an example.
\end{example}

Some text stands here. And then there is some space between this and the continued example.
Further should the continued example not be intended but start at the beginning of the line.

\begin{continuance}{ex1}
This is the continued example.
\end{continuance}

Some more text, which should follow after a little vertical space.
\end{document}

这样,您将使用整体定理风格。


以下版本适用于ntheorem

\documentclass{book}
\usepackage{ntheorem}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{example}[theorem]{Example}
\newcommand{\continuanceref}{}
\newtheorem{continuancex}{Continuance of Example}
\renewcommand{\thecontinuancex}{\continuanceref}
\newenvironment{continuance}[1]
  {\renewcommand\continuanceref{\ref{#1}}\continuancex}
  {\endcontinuancex}

\begin{document}
\chapter{Title}
\begin{example} \label{ex1}
 This is an example.
\end{example}

Some text stands here. And then there is some space between this and the continued example.
Further should the continued example not be intended but start at the beginning of the line.

\begin{continuance}{ex1}
This is the continued example.
\end{continuance}

Some more text, which should follow after a little vertical space.
\end{document}

这是工作版本babel

\documentclass{book}
\usepackage[english]{babel}
\usepackage{ntheorem,refcount}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{example}[theorem]{Example}
\newtheorem{continuancex}{Continuance of Example}
\renewcommand{\thecontinuancex}{\continuanceref}
\newenvironment{continuance}[1]
  {\edef\continuanceref{\getrefnumber{#1}}\begin{continuancex}}
  {\end{continuancex}}

\begin{document}
\chapter{Title}
\begin{example}\label{ex1}
 This is an example.
\end{example}

Some text stands here. And then there is some space between this and the continued example.
Further should the continued example not be intended but start at the beginning of the line.

\begin{continuance}{ex1}
This is the continued example.
\end{continuance}

Some more text, which should follow after a little vertical space.
\end{document}

答案2

需要运行两次 LaTeX 才能获得正确的引用:

\documentclass[11pt,a4paper,twoside,openright]{book}
\usepackage{amsmath}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{example}[theorem]{Example}
\newenvironment{continuance}[1]
  {\par\bigskip\noindent\textbf{Continuence of Example #1. }\itshape}
  {\par}
\begin{document}

\begin{example} \label{ex1}
 This is an example.
\end{example}

Some text stands here. And then there is some space between this and the continued example. 
Further should the continued example not be intended but start at the beginning of the line.

\begin{continuance}{\ref{ex1}}
This is the continued example.
\end{continuance}

\end{document}

在此处输入图片描述

相关内容