如何在不破坏原始定理编号的情况下对 LaTeX 中的非连续附录进行编号?

发布于 2024-08-12 00:38:45 字数 287 浏览 2 评论 0原文

我正在写一篇充满定义、定理、引理等内容的论文。我需要给出一个概念的基本定义,然后在论文的后面部分扩展这个定义,因为更多的参数会增加复杂性,从而增加定义。所以我需要看起来(结构上)像这样的东西:

定义1

定义2

定义3

附录1.a(参考定义1)

附录1.b(参考定义1)

定义4

附录1.c(参考定义1) )

附录 3.a(参考定义 3)

定义 5

我似乎找不到任何可以让我这样做的东西。有人有想法吗?

I am writing a thesis heavy with Definitions, Theorems, Lemmas and the like. I need to give a basic definition of a concept, and then later in the thesis expand on this definition as more parameters add to the complexity and thus to the definition. So I need something which would look (structurally) like this:

Definition 1

Definition 2

Definition 3

Addendum 1.a (Referring to Definition 1)

Addendum 1.b (Referring to Definition 1 )

Definition 4

Addendum 1.c (Referring to Definition 1)

Addendum 3.a (Referring to Definition 3)

Definition 5

I can't seem to find anything that will let me do this. Does anyone have an idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蹲墙角沉默 2024-08-19 00:38:45

序言:

\newtheorem{Definition}{Definition}
\newtheorem{Addendum}{Addendum}[Definition]
\def\theAddendum{\theDefinition .\alph{Addendum}}

正文:

\newcount\saveDefCounter

\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}

\saveDefCounter\arabic{Definition}
\setcounter{Definition}{1}

\begin{Addendum} ... \end{Addendum}
\begin{Addendum} ... \end{Addendum}

\setcounter{Definition}{\saveDefCounter}

\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}

In preambule:

\newtheorem{Definition}{Definition}
\newtheorem{Addendum}{Addendum}[Definition]
\def\theAddendum{\theDefinition .\alph{Addendum}}

Main text:

\newcount\saveDefCounter

\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}

\saveDefCounter\arabic{Definition}
\setcounter{Definition}{1}

\begin{Addendum} ... \end{Addendum}
\begin{Addendum} ... \end{Addendum}

\setcounter{Definition}{\saveDefCounter}

\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}
毁我热情 2024-08-19 00:38:45

根据Alexey的回答,尝试

\documentclass{article}
\newtheorem{Definition}{Definition}

\makeatletter
\newenvironment{add}[1]{ % environment has one required arg, a label to follow
  \@ifundefined{c@add@#1}{ % does a private counter exist for the label?
    \newcounter{add@#1} % define if not
  }{ % do nothing if it does
  }
  \stepcounter{add@#1}
  \@begintheorem{Addendum}{\ref{#1}.\csname theadd@#1\endcsname}\ignorespaces
  % use latex internal macro to write the theorem start environment
}{ % end the environment
  \@endtheorem
}
\makeatother

\begin{document}

\begin{Definition}\label{def1} ... \end{Definition}
\begin{Definition}\label{def2} ... \end{Definition}
\begin{Definition}\label{def3} ... \end{Definition}


\begin{add}{def1} ... \end{add}
\begin{add}{def2} ... \end{add}
\begin{add}{def1} ... \end{add}


\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}
\end{document}

添加环境必须获得一个标签,指定它要附加到的定义。如果您想使其可重用,请将 \makeatletter 和 \makeatother 之间的位放入样式文件中。

Based on Alexey's answer, try

\documentclass{article}
\newtheorem{Definition}{Definition}

\makeatletter
\newenvironment{add}[1]{ % environment has one required arg, a label to follow
  \@ifundefined{c@add@#1}{ % does a private counter exist for the label?
    \newcounter{add@#1} % define if not
  }{ % do nothing if it does
  }
  \stepcounter{add@#1}
  \@begintheorem{Addendum}{\ref{#1}.\csname theadd@#1\endcsname}\ignorespaces
  % use latex internal macro to write the theorem start environment
}{ % end the environment
  \@endtheorem
}
\makeatother

\begin{document}

\begin{Definition}\label{def1} ... \end{Definition}
\begin{Definition}\label{def2} ... \end{Definition}
\begin{Definition}\label{def3} ... \end{Definition}


\begin{add}{def1} ... \end{add}
\begin{add}{def2} ... \end{add}
\begin{add}{def1} ... \end{add}


\begin{Definition} ... \end{Definition}
\begin{Definition} ... \end{Definition}
\end{document}

The add environment must get a label specifying the definition to which it is to append. Put the bit between \makeatletter and \makeatother in a style file if you want to make it reusable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文