Generalchemical equation numbering

LaTeX specific issues not fitting into one of the other forums of this category.
yotama9
Posts: 61
Joined: Thu Sep 24, 2009 2:59 pm

Re: chemical equation numbering

Post by yotama9 »

OK. the code I want if on page 11 and not 10. This is the source to my misunderstanding. This part start with explaining how to create a mhchem costume command in the equation environment so I skipped the end of this part. My mistake.

As for your code. I don't understand it completely. Is there a latex commands database to understand it? what does the @ or the $$ stand for?

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

chemical equation numbering

Post by localghost »

yotama9 wrote:OK. the code I want if on page 11 and not 10. This is the source to my misunderstanding. This part start with explaining how to create a mhchem costume command in the equation environment so I skipped the end of this part. My mistake. […]
References are mostly to the current version of a manual available on CTAN.
yotama9 wrote:[…] As for your code. I don't understand it completely. Is there a latex commands database to understand it? what does the @ or the $$ stand for? […]
For the documentation of the LaTeX2e sources you can take a look at source2e (or a web search for source2e.pdf). The »at« sign protects important internal LaTeX commands and registers. It should be used very careful. The double dollar signs are a TeX command and enclose a displayed equation environment (not to be used in LaTeX syntax, see l2tabu).

Supplement:
In the meantime I was able to work out a more general solution that works with the standard classes. The relevant part of the code has to be modified as shown below.

Code: Select all

\makeatletter
\@definecounter{reaction}
\def\reaction{$$\refstepcounter{reaction}}
\def\endreaction{\eqno \hbox{\@reacnum}$$\@ignoretrue}
\def\@reacnum{{\normalfont \normalcolor (\thereaction)}}
\@ifundefined{chapter}%
  {\renewcommand\thereaction{C\,\@arabic\c@reaction}}
  {\@addtoreset{reaction}{chapter}
   \renewcommand\thereaction{C\,\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@reaction}}
\makeatother
At the moment a starred version of the reaction environment is missing.
rainsong
Posts: 1
Joined: Mon Nov 19, 2018 1:12 am

chemical equation numbering

Post by rainsong »

Thanks @localghost! Your method solved my problem
Post Reply