本文介绍了如何在LaTeX中识别两个计数器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某个文档中,我想使两个计数器定理"和小节"成为一个整体.有什么想法吗?

In a certain document, I want to make the two counters "theorem" and "subsection" to be one and the same thing. Any ideas?

由于数学部分可能会造成混淆,因此我在没有任何此类引用的情况下重新表述以下问题.

Since the math parts are potentially confusing, I rephrase the question as follows without any such references.

我使用某个计数器"mycounter"来进行计数,并且该计数器在某个程序包中是预定义的.当该小节上升时,我希望"mycounter"上升.反之亦然.重置小节后,我希望重置"mycounter".

I use a certain counter "mycounter" for counting something, and this counter is predefined in a certain package. When the subsection goes up, I want "mycounter" to go up. And vice-versa. When subsection is reset, I want "mycounter" to be reset.

这是我希望通过识别两个计数器来实现的目标.

This is what I hope to achieve by identifying the two counters.

推荐答案

赫伯特·西兹(Herbert Sizt)快要出现了.

Herbert Sizt is almost there.

\newtheorem{theorem}{Theorem}[subsection]将对子部分中的定理进行编号(即,第1.2节中的定理为1.2.1、1.2.2等).而是\newtheorem{theorem}[subsection]{Theorem}似乎可以执行OP所需的操作.在第1.5节(假设)之后是定理1.6,在此之后是第1.7节.该定理的格式与各节的格式不同.

\newtheorem{theorem}{Theorem}[subsection] would number theorems within subsections (ie, the theorems within Section 1.2 would be 1.2.1, 1.2.2, etc). Instead \newtheorem{theorem}[subsection]{Theorem} appears to do what the OP requires. Section 1.5 (say) would be followed by theorem 1.6, which would be followed by section 1.7. The theorem is formatted differently from sections.

另一种方法是做

\def\theorem#1{\begingroup
  \let\tempsubsection\thesubsection
  \def\thesubsection{Thm.~\tempsubsection}%
  \subsection{#1}%
  \endgroup
}

这有点自制",但使这些定理的布局与\subsection完全相同,这可能是必需的,也可能不是.

That's slightly more 'home-made', but makes the theorems have exactly the same layout as \subsection, which may or may not be what's required.

这篇关于如何在LaTeX中识别两个计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 18:44