LaTeX forum ⇒ GeneralChemical 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

Postby Eenzc » Thu Jun 26, 2008 2:44 pm

Hello,

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

The problem being they are all numbered sequentially.

My maths ones are in the: \begin{equation} \end{equation} 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.

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
User avatar
Stefan Kottwitz
Site Admin
Posts: 9882
Joined: Mon Mar 10, 2008 9:44 pm

Chemical Equations numbered separate from Mathematical ones

Postby Stefan Kottwitz » Thu Jun 26, 2008 3:09 pm

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}%
\begin{equation}}%
{\tag*{\thechemequation}%
\end{equation}}
\begin{document}
\begin{equation}
  e^{\pi i} + 1 = 0
  \label{eq:1}
\end{equation}
\begin{chemequation}
  \text{CO}_2 + \text{C}  \longrightarrow 2\text{CO}
  \label{ch:1}
\end{chemequation}
\begin{equation}
  ax + by +c = 0
  \label{eq:2}
\end{equation}
\begin{chemequation}
  \text{H}_2\text{O}
  \label{ch:2}
\end{chemequation}
\begin{equation}
  y = x^3 + x
  \label{eq:3}
\end{equation}
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
LaTeX.org admin

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

Re: Chemical Equations numbered separate from Mathematical ones

Postby Eenzc » Thu Jun 26, 2008 4:31 pm

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 9882
Joined: Mon Mar 10, 2008 9:44 pm

Chemical Equations numbered separate from Mathematical ones

Postby Stefan Kottwitz » Thu Jun 26, 2008 6:50 pm

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
LaTeX.org admin

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

Re: Chemical Equations numbered separate from Mathematical ones

Postby Eenzc » Thu Jun 26, 2008 7:53 pm

Great stuff, thanks very much.

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

Chemical Equations numbered separate from Mathematical ones

Postby Eenzc » Wed Jul 02, 2008 4:13 pm

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}%
\begin{equation}}%
{\tag*{\thechemequation}%
\end{equation}}

%%%%% 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!

Please help.

Thanks.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9882
Joined: Mon Mar 10, 2008 9:44 pm

Chemical Equations numbered separate from Mathematical ones

Postby Stefan Kottwitz » Thu Jul 03, 2008 3:10 am

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}
  \addcontentsline{cex}{section}%
    {\protect\numberline{\thechemicalequation}{\ignorespaces #1}}
}

Stefan
LaTeX.org admin

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

Re: Chemical Equations numbered separate from Mathematical ones

Postby josephwright » Thu Jul 03, 2008 2:17 pm

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

Postby Eenzc » Fri Jul 04, 2008 9:22 am

Thanks again guys, especially Stefan!

It works well and does what I want it to.


Return to “General”

Who is online

Users browsing this forum: No registered users and 9 guests