I need a chemical reaction environment, numbered and able to be referenced/labeled. It must also that is consistent with equation
in its looks.
I have read many questions and my code is an adaptation of this answer.
However I would really like to be able to use the same default \label
.
I don't need a List of Reactions as most other questions seems to seek.
\documentclass{article}
\usepackage{hyperref}
\usepackage{amsmath,}
\usepackage{mhchem}[version=4]
\usepackage{tocloft}
\newcommand{\reactionlistname}{List of reactions}
\newlistof{reactions}{rxs}{\reactionlistname}
\newcounter{system}
\renewcommand*{\thesystem}{\arabic{system}}
\newcommand*{\systemautorefname}{Reaction}
\makeatletter
\renewcommand*{\p@system}{%
\expandafter\p@@system
}
\newcommand*{\p@@system}[1]{%
#1%
}
\makeatother
\newenvironment{reaction}[1][]{%
\refstepcounter{system}%
\ifx\\#1\\%
\else
\label{#1}%
\fi
\begin{equation}%
}{%
\tag{\thesystem}%
\end{equation}%
}
\begin{document}
You can see the chemical decomposition at \autoref{rea:bla} and its mathematical representation in \autoref{eq:foo}.
\begin{equation}\label{eq:foo}
t^2 + 27t
\end{equation}
\begin{reaction}[rea:bla]
\ce{SiC + 2O2 -> CO2 + SiO2},
\end{reaction}
\end{document}
Edit 1:
I've also tried chemmacros
, based on here, but then I get Equation 1
instead of Reaction 1
:
\documentclass{article}
\usepackage{amsmath,}
\usepackage{chemmacros}
\chemsetup{
modules = {reactions} ,
formula = mhchem
}
\usepackage{hyperref}
\begin{document}
You can see the chemical decomposition at \autoref{rea:bla} and its mathematical representation in \autoref{eq:foo}.
\begin{equation}\label{eq:foo}
t^2 + 27t
\end{equation}
\begin{reaction}\label{rea:bla}
\ce{SiC + 2O2 -> CO2 + SiO2},
\end{reaction}
\end{document}
hyperref
should be loaded as the last package, with very few exceptions (most notablycleveref
). – Bernard Feb 19 '19 at 19:06hyperref
know that it should write Reaction? There is no variable names! – Sigur Feb 19 '19 at 22:11