我用它chemfig
来创建一些结构公式,但我需要创建一个新的环境,比如方程式,它有专用的索引和引用计数器。我正在寻找这个,但我很难找到适合我的东西。
例如,我想要这样的东西:
text text text text~\ref{eq:foo}
\begin{equation}
a = b
\label{eq:foo}
\end{equation}
text text text text~\ref{sf:foo}
\begin{structuralFormula}
H_{2}O
\label{sf:foo}
\end{structuralFormula}
text text text text~\ref{eq:bar}
\begin{equation}
h^2 = c_1^2 + c_2^2
\label{eq:bar}
\end{equation}
text text text text~\ref{sf:bar}
\begin{structuralFormula}
\chemfig{
C(
-[:0]H
)(
-[:90]H
)(
-[:180]H
)(
-[:270]H
)
}
\label{sf:bar}
\end{structuralFormula}
即,我需要一个新的环境,其工作方式与方程完全相同,并且具有一个新的索引条目,仅专用于这个新环境。我将这些数字称为索引条目,但我真的不知道这是否是正确的技术名称。
我已经有类似的东西了:
\documentclass[
12pt, % tamanho da fonte
openright, % capítulos começam em pág ímpar (insere página vazia caso preciso)
twoside, % para impressão em verso e anverso. Oposto a oneside
a4paper, % tamanho do papel.
chapter=TITLE, % títulos de capítulos convertidos em letras maiúsculas
section=TITLE, % títulos de seções convertidos em letras maiúsculas
english, % idioma adicional para hifenização
french, % idioma adicional para hifenização
spanish, % idioma adicional para hifenização
brazil, % o último idioma é o principal do documento
]{abntex2}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{indentfirst}
\usepackage[final]{graphicx}
\usepackage{microtype}
\usepackage{hyperref}
\usepackage{subfig}
\usepackage{epigraph}
\usepackage{url}
\usepackage{placeins}
\usepackage{multirow}
\usepackage[figuresright]{rotating}
\usepackage{chemfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{environ}
\makeatletter
\hypersetup{
colorlinks=true,
linkcolor=black,
citecolor=black,
filecolor=black,
urlcolor=black,
bookmarksdepth=4
}
\makeatother
\NewEnviron{structuralFormula}{%
\begin{equation}
\BODY
\end{equation}
}
\begin{document}
text text text text~\ref{eq:foo}
\begin{equation}
a = b
\label{eq:foo}
\end{equation}
text text text text~\ref{sf:foo}
\begin{structuralFormula}
H_{2}O
\label{sf:foo}
\end{structuralFormula}
text text text text~\ref{eq:bar}
\begin{equation}
h^2 = c_1^2 + c_2^2
\label{eq:bar}
\end{equation}
text text text text~\ref{sf:bar}
\begin{structuralFormula}
\chemfig{
C(
-[:0]H
)(
-[:90]H
)(
-[:180]H
)(
-[:270]H
)
}
\label{sf:bar}
\end{structuralFormula}
\end{document}
这会产生以下结果:
但我想要像第一张图片那样的数字。
答案1
article
用而不是的初步版本abntex2
(那个失败了!)
\documentclass{article}
\usepackage{tocloft}
\usepackage{chemfig}
\usepackage{environ}
\newcommand{\listofstructformname}{List of structural formulas}
\newlistof{structform}{stf}{\listofstructformname}
\makeatletter
\NewEnviron{structuralFormula}[1]{%
\let\c@equation\c@structform
\renewcommand{\theHequation}{structform.\theequation}
\begin{equation}
\BODY
\addcontentsline{stf}{section}{\protect\numberline{\theequation}#1}
}[%
\end{equation}
]
\makeatother
\usepackage{hyperref}
\hypersetup{%
colorlinks=true,
linkcolor=black,
citecolor=black,
filecolor=black,
urlcolor=black,
bookmarksdepth=4
}
\begin{document}
\listofstructform
\clearpage
text text text text~\ref{eq:foo}
\begin{equation}
a = b
\label{eq:foo}
\end{equation}
text text text text~\ref{sf:foo}
\begin{structuralFormula}{Water}
H_{2}O
\label{sf:foo}
\end{structuralFormula}
text text text text~\ref{eq:bar}
\begin{equation}
h^2 = c_1^2 + c_2^2
\label{eq:bar}
\end{equation}
text text text text~\ref{sf:bar}
\begin{structuralFormula}{Something I don't know}
\chemfig{
C(
-[:0]H
)(
-[:90]H
)(
-[:180]H
)(
-[:270]H
)
}
\label{sf:bar}
\end{structuralFormula}
\end{document}
更新由于 的特殊性abntex2
(它基于memoir
),简单的设置tocloft
不起作用——必须手动设置列表。
\documentclass[
12pt, % tamanho da fonte
openright, % capítulos começam em pág ímpar (insere página vazia caso preciso)
twoside, % para impressão em verso e anverso. Oposto a oneside
a4paper, % tamanho do papel.
chapter=TITLE, % títulos de capítulos convertidos em letras maiúsculas
section=TITLE, % títulos de seções convertidos em letras maiúsculas
english, % idioma adicional para hifenização
french, % idioma adicional para hifenização
spanish, % idioma adicional para hifenização
brazil, % o último idioma é o principal do documento
]{abntex2}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{indentfirst}
\usepackage[final]{graphicx}
\usepackage{microtype}
\usepackage{subfig}
\usepackage{epigraph}
\usepackage{url}
\usepackage{placeins}
\usepackage{multirow}
\usepackage[figuresright]{rotating}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{chemfig}
\usepackage{environ}
\newcommand{\listofstructformname}{List of structural formulas}
\makeatletter
\newcounter{structform}
\newcommand{\listofstructform}{%
\begingroup
\let\contentsname\listofstructformname
\let\latex@@starttoc\@starttoc
\def\@starttoc##1{\latex@@starttoc{stf}}
\tableofcontents
\endgroup
}
\NewEnviron{structuralFormula}[1]{%
\let\c@equation\c@structform
\renewcommand{\theHequation}{structform.\theequation}% Make hyperref happy!
\renewcommand{\@currentlabelname}{#1}% Make nameref working
\begin{equation}
\BODY
\addcontentsline{stf}{section}{\protect\numberline{\theequation}#1}
}[%
\end{equation}
]
\makeatother
\usepackage{hyperref}
\hypersetup{%
colorlinks=true,
linkcolor=black,
citecolor=black,
filecolor=black,
urlcolor=black,
bookmarksdepth=4
}
\begin{document}
\tableofcontents
\clearpage
\listofstructform
\clearpage
text text text text~\ref{eq:foo}
\begin{equation}
a = b
\label{eq:foo}
\end{equation}
text text text text~\ref{sf:foo}
\begin{structuralFormula}{Water}
H_{2}O
\label{sf:foo}
\end{structuralFormula}
text text text text~\ref{eq:bar}
\begin{equation}
h^2 = c_1^2 + c_2^2
\label{eq:bar}
\end{equation}
text text text text~\ref{sf:bar}
\begin{structuralFormula}{Something I don't know}
\chemfig{
C(
-[:0]H
)(
-[:90]H
)(
-[:180]H
)(
-[:270]H
)
}
\label{sf:bar}
\end{structuralFormula}
\end{document}