我在文本中使用了連續的範例,但我不知道如何定義相應的良好環境。
我正在使用 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}