Is there a way to make an environment for chemical reactions like the
equation-environment? I'm thinking of something like:
\begin{reaction}
2 H_2 + O_2 \command-for-arrow 2 H_2 O
\end{reaction}
I HAVE tried the dchem package and it writes the letters in math-font
and not upright as they should be. On the other hand it would be nice
not to have to write $'s for everytime you want a subscribt (which is
quite often!) or \text{ } for every letter.
And be the way: Is there a way to number these seperatly from the
equation environment and of cause give them a label?
best regards
/Nikolaj
have a look at the mhchem package on ctan.
--
/daleif (remove RTFSIGNATURE for email)
A good tip (to all the others) is to put:
\usepackage{mhchem}
\makeatletter
\newcommand\reaction@[2]{\begin{equation} #2 \ce{#1}\end{equation}}
\newcommand\reaction@nonumber[1]%
{\begin{equation*}\ce{#1}\end{equation*}}
\newcommand\reaction{\@ifstar{\reaction@nonumber}{\reaction@}}
\makeatother
in your preamble and then in your input-file write:
\reaction{ formula }{label{labelname}}
to get a numbered, "equation-like" formula, which you can make a ref to
and \reaction*{ formula } for one without a number.
This does however use same numbering as the equation environment and
the first equation would be numbered as (2) if you have a reaction
before that :-( If anyone has a "hack" to deal with this, and perhaps
put equationnumbers in the right margin and reactionnumbers in the
left... or a different kind of numbering (eg. roman vs. arabic) I'd be
glad to hear it.
> Is there a way to make an environment for chemical reactions like the
> equation-environment? I'm thinking of something like:
>
> \begin{reaction}
>
> 2 H_2 + O_2 \command-for-arrow 2 H_2 O
>
> \end{reaction}
>
> I HAVE tried the dchem package and it writes the letters in math-font
No it doesn't! Do you have an example that demonstrates your claim?
--
Donald Arseneau as...@triumf.ca
I placed my dvi-file here: http://www.civil.aau.dk/~nigo03/master.dvi
It was produced by writing \usepackage{dchem} in the preamble and
\begin{reaction}
H + O_2 \eqbm^{\cit k\sub{a}}_{\cit k\sub{-a}} HO_2
\end{reaction}
in a input file which gives a mathfont or at least not upright H and
O...
Perhaps I got something else in my preamble which "clashes" with the
dchem-package?
I include the following packages, beside dhcem:
\usepackage{t1enc,babel}
\usepackage[dvips]{epsfig}
\usepackage{epic}
\usepackage{eepic}
\usepackage[dvips]{graphicx,color}
\usepackage[footnotesize,bf]{caption}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{theorem}
\usepackage{varioref}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{makeidx}
\usepackage{ifthen}
\usepackage{here}
\usepackage{lastpage}
\usepackage{subfigure}
\usepackage{mathptmx}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{fancybox}
...perhaps some of it is overkill, but... well :-)
best regards
/Nikolaj
> With respect for one of the LaTeX masters :-) Mine does!
>
> I placed my dvi-file here: http://www.civil.aau.dk/~nigo03/master.dvi
If you measured the equilibrium of Mu + O_2 it might be interesting :-P
> \usepackage{t1enc,babel}
Except for this line, which will gives errors by itself, the packages
work fine. I tested with
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
...
etc.
--
Donald Arseneau as...@triumf.ca
um, donald, since you don't publish dchem, is it not possible he's got
a corrupt version? -- there are any number of copies on the net, and i
bet they're not all the same.
now, if you were to submit it to ctan, there would be a reference copy
under your explicit control... ;-)
--
Robin (http://www.tex.ac.uk/faq) Fairbairns, Cambridge
> It was produced by writing \usepackage{dchem} in the preamble and
>
> \begin{reaction}
> H + O_2 \eqbm^{\cit k\sub{a}}_{\cit k\sub{-a}} HO_2
> \end{reaction}
I tried with this document:
(added documentclass, begin/enddocument and dchem)
-----------------------------------
\documentclass[english]{article}
\usepackage{t1enc,babel}
\usepackage[dvips]{epsfig}
\usepackage{epic}
\usepackage{eepic}
\usepackage[dvips]{graphicx,color}
\usepackage[footnotesize,bf]{caption}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{theorem}
\usepackage{varioref}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{makeidx}
\usepackage{ifthen}
\usepackage{here}
\usepackage{lastpage}
\usepackage{subfigure}
\usepackage{mathptmx}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{fancybox}
\usepackage{dchem}
\begin{document}
\begin{reaction}
H + O_2 \eqbm^{\ma k\sub{a}}_{\ma k\sub{-a}} HO_2
\end{reaction}
\end{document}
-----------------------------------
It works fine, but I changed \cit with \ma, as \cit was undefined for me.
Which version of dchem.sty are you using? Mine is dated Mar 18, 2000,
although it was sent to me about a month ago.
By the way, Donald, you should by all means publish this, even undocumented
and maybe buggy. If you feel you're going to change things in the future,
change the name to dchem-preview or dchem-wip... but I want to be able to
use this package when submitting papers for review, and it's easier if its
on ctan.
--
Ignacio __ Fernández Galván
/ /\
Linux user / / \ PGP Pub Key
#289967 / / /\ \ 0x01A95F99
/ / /\ \ \
http://djelibeibi.unex.es
/________\ \ \
jellby \___________\/ yahoo.com
or with its real name on the macros/latex/exptl subtree?
Does what? Please quote some context.
> \usepackage{t1enc,babel}
See Donald's post.
> \usepackage{theorem}
Use ntheorem instead, it does the same, but better. Don't forget the
[amsmath] option.
> \usepackage{here}
Just a side note: texdoc here gives me:
here Obsolete package for "here" floats.
Provides the H option for floats in LaTeX to mean that the float should
really be placed here. It has been removed from CTAN at the request of
the author. LaTeX2e now has a ! option and [!ht] usually does what the
user of H expects and has the big advantage of guaranteeing that floats
stay in the right order. See the float package for an alternative which
does include H for LaTeX2e. The author is David Carlisle.
> ...perhaps some of it is overkill, but... well :-)
more than just some, I think, but... well :-p
H.
--
Hendrik Maryns
Interesting websites:
www.lieverleven.be (I cooperate)
www.eu04.com European Referendum Campaign
aouw.org The Art Of Urban Warfare
Yep, agreed - why isn't it on ctan?
Med venlig hilsen / Best regards
Martin Jørgensen
--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Donald:
I Googled for dchem.sty and got two different files. With this source:
\documentclass{article}
\usepackage{dchem}
\begin{document}
Test:
\begin{reaction}
H + O_2 \eqbm^{\cit k\sub{a}}_{\cit k\sub{-a}} HO_2
\end{reaction}
\end{document}
I got a slanted alphabet with one version of dchem.sty and an error
message with the other.
It would appear that "dchem" is not sufficiently well defined to make
_any_ claims about it, one way or the other. I second robin's
suggestion.
Dan
I never did this kind of programming before, but here are two solutions
that worked with my little test file.
Here, a new counter for all reactions is used. These are labelled as the
equations with a "R" prefix.
\documentclass{article}
%\documentclass{book}
\usepackage[version=2]{mhchem}
\makeatletter
\newcounter{reaction}% create new counter for reactions
\@addtoreset{reaction}{chapter}% new chapter? => reset counter to 0
\newcommand\reaction@[2]{\bgroup%
\let\c@equation\c@reaction%
\let\theequationold\theequation%
\def\theequation{R\,\theequationold}%
\begin{equation}%
#2%
\ce{#1}%
\end{equation}%
\egroup%
}
\newcommand\reaction@nonumber[1]%
{\begin{equation*}\ce{#1}\end{equation*}}
\newcommand\reaction{\@ifstar{\reaction@nonumber}{\reaction@}}
\makeatother
\begin{document}
%\chapter{}
\begin{equation} 1+1=2 \end{equation}
\reaction{H + 2O -> H2O}{\label{L1}}
\reaction{H + 2O -> H2O}{\label{L2}}
\begin{equation} 1+1=2 \end{equation}
%\chapter{}
\begin{equation} 1+1=2 \end{equation}
\reaction{H + 2O -> H2O}{\label{L3}}
\begin{equation} 1+1=2 \end{equation}
\reaction{H + 2O -> H2O}{\label{L4}}
see~\ref{L2}
\end{document}
For some more control over the layout (e.g. to use roman numbers), on
could use
\newcommand\reaction@[2]{\bgroup%
\@ifundefined{thechapter}% how the tag should look like
{\renewcommand\theequation{R\,\thereaction}}%
{%\ifnum\thechapter>0%
\renewcommand\theequation{R\,\thechapter.\thereaction}%
%\else%
% \renewcommand\theequation{R\,\thereaction}%
%\fi%
}%
\addtocounter{reaction}{1}%
\begin{equation}%
%\begin{equation} increases the equation counter, ...
\addtocounter{equation}{-1}% we reverse that
#2%
\ce{#1}%
\end{equation}%
\egroup%
}
instead.
Feedback appreciated. Will this kind of numbering be used often? If so,
I could add these snippets in the Tips and Tricks section of the mhchem
manual.
Martin
i'd love to see it on CTAN as well. i've used it for my thesis, and it
worked like a charm!
markus
> H + O_2 \eqbm^{\cit k\sub{a}}_{\cit k\sub{-a}} HO_2
>
> I got a slanted alphabet with one version of dchem.sty and an error
> message with the other.
The one with the error message would be the right one :-)
I remember \cit, but it is \ma now.
On the other hand, I can't remember a version that didn't
do the principal task of using \mathrm (equivalent).
Probably a year ago I decided to submit it in its rough state,
which I probably should have done 5 or 6 years ago! Still
haven't. sigh..... and there are bugs to fix in url and a new
version of wrapfig....
--
Donald Arseneau as...@triumf.ca
>> This does however use same numbering as the equation environment and
>> the first equation would be numbered as (2) if you have a reaction
>> before that :-( If anyone has a "hack" to deal with this, and perhaps
>> put equationnumbers in the right margin and reactionnumbers in the
>> left... or a different kind of numbering (eg. roman vs. arabic) I'd be
>> glad to hear it.
>
> I never did this kind of programming before, but here are two
> solutions that worked with my little test file.
>
> Here, a new counter for all reactions is used. These are labelled as
> the equations with a "R" prefix.
Maybe tke a look at bpchem.sty, which provides this for numbering chemical
substances.
Björn
--
Bjoern Pedersen Lichtenbergstr.1
Technische Universitaet Muenchen D-85747 Garching
ZWE Instrumentierung FRM-II
Tel. + 49 89 289-14707 Fax -14666