如何在 LaTeX 中定义一个包含章节号的新计数器? [英] How to define in LaTeX a new counter that includes the chapter number too?

查看:12
本文介绍了如何在 LaTeX 中定义一个包含章节号的新计数器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于我已经定义了一个维护计数器的新环境:

Given I have defined a new environment for which a counter is maintained:


ewcounter{bioclipse}

ewenvironment{bioclipse}[2][]{
   egin{shaded}
efstepcounter{bioclipse}parmedskip
oindent%
   	extbf{Bioclipse Excursion~	hechapter-	hebioclipse #1: #2
   vspace{0.1cm} hrule vspace{0.1cm}}
   
mfamily}{medskip end{shaded}
}

现在,我可以为这样的环境添加标签:

Now, I can add a label to such an environment:

egin{bioclipse}{Wizards: New Molecule from SMILES}
  label{chapCompRepr:ex:fromSMILESWizard}
  Bioclipse has a 	extit{New Wizard} to create a new chemical graph.
end{bioclipse}

这会输出带有标题和数字的文本.因为它使用了 hechapter,所以这个数字也会包含章节号;即第 3 章中的第一个环境,将在 3-1 中编号.在输出中,就是这样.

This outputs a text with caption and a number. Because it uses hechapter, this number will include the chapter number too; that is, the first environment in Chapter 3, will be numbered in 3-1. In the output, that is.

但是,当我用 ef{chapCompRepr:ex:fromSMILESWizard} 引用它时,这个数字不包括章节号......我应该如何更改我的环境定义,或者它包含章节号的计数器定义,并重置每章的第二个数字?

However, when I refer to it with ef{chapCompRepr:ex:fromSMILESWizard}, this number does not include the chapter number... How should I change my environment definition, or counter definition that it includes the chapter number, and resets the second number for each chapter?

推荐答案

插入:

def	hebioclipse{	hechapter-arabic{bioclipse}}

得到


ewcounter{bioclipse}
def	hebioclipse{	hechapter-arabic{bioclipse}}

ewenvironment{bioclipse}[2][]{
   egin{shaded}
efstepcounter{bioclipse}parmedskip
oindent%
   	extbf{Bioclipse Excursion~	hebioclipse #1: #2
   vspace{0.1cm} hrule vspace{0.1cm}}
   
mfamily}{medskip end{shaded}
}

这篇关于如何在 LaTeX 中定义一个包含章节号的新计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆