## LaTeX forum ⇒ General ⇒ Chemical Equations numbered separate from Mathematical ones

LaTeX specific issues not fitting into one of the other forums of this category.
Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

### Chemical Equations numbered separate from Mathematical ones

Hello,

I am currently writting a document that contains both mathematical and chemical equations.

The problem being they are all numbered sequentially.

Mymathsonesareinthe:enviroment
and similarly my chemical equations are in the \begin{array} \end{array} enviroment

they come out like this:

m = a.t.h.s (1)
CH + MISTRY <-> EQ + ATION (2)
CH + MISTRY <-> EQ + ATION (3)
m = a.t.h.s (4)

Where as I want them to come out like:

m = a.t.h.s (1)
CH + MISTRY <-> EQ + ATION [1]
CH + MISTRY <-> EQ + ATION [2]
m = a.t.h.s (2)

Any help?

Thanks.

LaTeXguide.org • LaTeX-Cookbook.net

Stefan Kottwitz
Posts: 9882
Joined: Mon Mar 10, 2008 9:44 pm

### Chemical Equations numbered separate from Mathematical ones

Hi Eenzc,

you could define a new environment for chemical equations and use a different counter. Here is an example to show you how you could write it:
\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}
\newcounter{chemequation}
\renewcommand*\thechemequation{[\arabic{chemequation}]}
\newenvironment{chemequation}{%
\stepcounter{chemequation}%
$$}% {\tag*{\thechemequation}%$$}
\begin{document}
$$e^{\pi i} + 1 = 0 \label{eq:1}$$
\begin{chemequation}
\text{CO}_2 + \text{C}  \longrightarrow 2\text{CO}
\label{ch:1}
\end{chemequation}
$$ax + by +c = 0 \label{eq:2}$$
\begin{chemequation}
\text{H}_2\text{O}
\label{ch:2}
\end{chemequation}
$$y = x^3 + x \label{eq:3}$$
For the second math equation see \eqref{eq:2},
for the first chemical equation see \ref{ch:1}.
\end{document}

As you can see after compiling math and chemical equations are numbered independently, chemical equations are tagged using square brackets instead of parantheses.

Stefan

Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

### Re: Chemical Equations numbered separate from Mathematical ones

Thanks,

Its good and complies, however specifically I've used:

\begin{chemequation}
\begin{align}
\mathrm{SiH_{4} + O_{2}} ~& \mathrm{\rightleftharpoons SiO_{2} + 2H_{2} } \\
\mathrm{SiCl_{2}H_{2} + 2N_{2}O} ~& \mathrm{\rightleftharpoons SiO_{2} + 2N_{2} + 2HCl}
\end{align}
\end{chemequation}

Which doesn't compile the align should provide two equations on top of each other.

I don't really understand what \tag*{} or the \thechemequation do; Also I don't understand why the counter has the same name as the environment and not chemequationcounter or something.
----
edit: I now understand this "sort of" but \tag*{} does not work if I change begin{equation} to begin{align} in the preamble
----

Ultimately I'd like to add a chemical equation contents page:

I assume I can do this by :

\listof{chemequation}{List of Chemical Equations}

Many thanks for your time, effort and speedy help

Stefan Kottwitz
Posts: 9882
Joined: Mon Mar 10, 2008 9:44 pm

### Chemical Equations numbered separate from Mathematical ones

Hi Eenzc,

you cannot put chemequation around align, but you could define a chemalign environment.

Here's a quick solution just using align:
\newcommand*\chemtag{%
\stepcounter{chemequation}%
\tag*{\thechemequation}}
...
\begin{align}
\mathrm{SiH_{4} + O_{2}} ~&
\mathrm{\rightleftharpoons SiO_{2} + 2H_{2} } \chemtag\\
\mathrm{SiCl_{2}H_{2} + 2N_{2}O} ~&
\mathrm{\rightleftharpoons SiO_{2} + 2N_{2} + 2HCl} \chemtag
\end{align}

Regarding your other question we had a similar discussion in the topic List of Equations.

Stefan

Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

### Re: Chemical Equations numbered separate from Mathematical ones

Great stuff, thanks very much.

Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

### Chemical Equations numbered separate from Mathematical ones

My problem resurfaces:

I am using the following code to define an enviroment:

%%%%% create chemequation environment

\newcounter{chemequation}
\renewcommand*\thechemequation{[\arabic{chemequation}]}
\newenvironment{chemequation}{%
\stepcounter{chemequation}%
$$}% {\tag*{\thechemequation}%$$}

%%%%% create chemtag to iterate and ref chemequations in an align environment

\newcommand*\chemtag{%
\stepcounter{chemequation}%
\tag*{\thechemequation}}

%%%%%


I also have defined a new float for the purpose of creating a chemical equation t.o.c.

%%%%% to create a chemicalequation float

\usepackage{float}
\newfloat{chemicalequation}{htbp}{cex}[chapter]
\floatname{chemicalequation}{}

%%%%%%


I implement my equations as follows:

\begin{chemicalequation} [H]
\begin{align}
\mathrm{SiH_{4} + O_{2}} 					~& \mathrm{\rightleftharpoons SiO_{2} + 2H_{2} }\chemtag 				\\
\mathrm{SiCl_{2}H_{2} + 2N_{2}O} 	~& \mathrm{\rightleftharpoons SiO_{2} + 2N_{2} + 2HCl}\chemtag
\end{align}
\caption[The Equation 1]{}
\label{chem:PECVD}
\end{chemicalequation}


And my t.o.c. as

\listof{chemicalequation}{Chemical Equations}


The trouble being that it still captions my equations in the body text with a number in the caption space under the equation. I don't want anything there!

Thanks.

Stefan Kottwitz
Posts: 9882
Joined: Mon Mar 10, 2008 9:44 pm

### Chemical Equations numbered separate from Mathematical ones

Hi,

instead of using \caption you could define a new \chemicalcaption, that steps the counter and writes to the cex file like this:
\newcommand\chemicalcaption[1]{%
\refstepcounter{chemicalequation}
{\protect\numberline{\thechemicalequation}{\ignorespaces #1}}
}

Stefan

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

### Re: Chemical Equations numbered separate from Mathematical ones

Just to say that the mhchem package would make writing your equations a bit easier, for example:

\documentclass{article}
\usepackage[version=3]{mhchem}
\begin{document}
\ce{H2 + O2 -> H2O}
\end{document}

Joseph Wright
Joseph Wright

Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

### Re: Chemical Equations numbered separate from Mathematical ones

Thanks again guys, especially Stefan!

It works well and does what I want it to.