Latex 乳胶新环境标签

Latex 乳胶新环境标签,latex,newenvironment,Latex,Newenvironment,我有以下newenvironment命令: \newcounter{algoctr}[chapter] \setcounter{algoctr}{0} \newenvironment{algo}[1] { \refstepcounter{algoctr}\vspace{0.2cm}\noindent{\bf Algorithm \arabic{chapter}.\arabic{algoctr}: #1}}{\par} 我就这样用它 \begin{algo}{blabbing a blah}

我有以下
newenvironment
命令:

\newcounter{algoctr}[chapter] \setcounter{algoctr}{0}
\newenvironment{algo}[1] {
\refstepcounter{algoctr}\vspace{0.2cm}\noindent{\bf Algorithm
\arabic{chapter}.\arabic{algoctr}: #1}}{\par}
我就这样用它

\begin{algo}{blabbing a blah}
 blah
 blah
\label{eq:blabbing}
\end{algo}
但是,每次我引用标签(\ref{eq:blabbing}),我都会得到一个“1”,而不是一个“1.1”

有人能告诉我我做错了什么吗


谢谢

我不知道你们的柜台,但我可以推荐另一种可行的方法:

\usepackage{amsthm}

\newtheoremstyle{algostyle}
  {0.2cm}{0cm}%                                 margin top and bottom
  {\rmfamily}%                                  text layout
  {0cm}%                                        indention of header
  {\bfseries}{ }%                               header font and text after
  {0cm}%                                        space after header
  {\thmname{#1}\thmnumber{ #2}:\thmnote{ #3}}%  header

\theoremstyle{algostyle}
\newtheorem{algo}{Algorithm}[chapter]

\begin{algo}[blabbing a blah]%  brackets instead of curly braces for note
 blah
 blah
\label{eq:blabbing}
\end{algo}

你就快到了,你只需要重新定义LGOCTR,比如:

\renewcommand\thealgoctr{\arabic{chapter}.\arabic{algoctr}}
(未经测试。) 然后在您的环境中使用
\thealgoctr
,而不是显式引用计数器