开发者

How to define in LaTeX a new counter that includes the chapter number too?

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

\newcounter{bioclipse}
\newenvironment{bioclipse}[2][]{
   \begin{shaded}\refstepcounter{bioclipse}\par\medskip\noindent%
   \textbf{Bioclipse Exc开发者_如何学编程ursion~\thechapter-\thebioclipse #1: #2
   \vspace{0.1cm} \hrule \vspace{0.1cm}}
   \rmfamily}{\medskip \end{shaded}
}

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

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

This outputs a text with caption and a number. Because it uses \thechapter, 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.

However, when I refer to it with \ref{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?


Insert:

\def\thebioclipse{\thechapter-\arabic{bioclipse}}

and get

\newcounter{bioclipse}
\def\thebioclipse{\thechapter-\arabic{bioclipse}}
\newenvironment{bioclipse}[2][]{
   \begin{shaded}\refstepcounter{bioclipse}\par\medskip\noindent%
   \textbf{Bioclipse Excursion~\thebioclipse #1: #2
   \vspace{0.1cm} \hrule \vspace{0.1cm}}
   \rmfamily}{\medskip \end{shaded}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜