From: "Mojca Miklavec" <mojca.miklavec.lists@gmail.com>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: Chemistry in lists
Date: Mon, 24 Dec 2007 00:06:16 +0100 [thread overview]
Message-ID: <6faad9f00712231506o15617410h9c43d83a28b6cf7a@mail.gmail.com> (raw)
In-Reply-To: <C392E783.10ABE%ShenChen@nus.edu.sg>
On Dec 22, 2007 9:10 AM, Shen Chen wrote:
> Hi all,
>
>
> I have some chemical formulae in chapter heading and figure captions,
> typeset with the chemic module. The chemic module always uses roman font as
> desired.
>
> When I include them in table of contents and list of figures, the chemical
> formulae appears in math italic font instead of roman font. See the
> following code for example. Chemic Manual mentioned using \rm but it doesn't
> seem to be the case. $\rm H_2O$ works fine in the list, but not
> \chemical{H_2O}. Any suggestions? Thank you.
>
> \usemodule[chemic]
> \starttext
>
> \writetolist[chapter]{}{ABC}
> \writetolist[chapter]{}{$H_2O$}
> \writetolist[chapter]{}{$\rm H_2O$}
> \writetolist[chapter]{}{\chemical{H_2O}}
> \completecontent
>
> \stoptext
The code is too complex for me to be able to understand what's going
on (but it seems like a problem which should be fixed, I agree).
I'm using an "ugly" piece of code from the wiki instead of the module
http://wiki.contextgarden.net/Chemistry
(bottom of the page) when I need to typeset simple chemistry. I also
needed a formula to apear in titiles and it worked really nice.
Mojca
% by Taco
\newbox\chemlowbox
\def\chemlow#1%
{\setbox\chemlowbox\hbox{{\switchtobodyfont[small]#1}}}
\def\chemhigh#1%
{\ifvoid\chemlowbox \high{{\switchtobodyfont[small]#1}}%
\else \/\lohi{\box\chemlowbox}{{\switchtobodyfont[small]#1}}\fi }
\def\finishchem%
{\ifvoid\chemlowbox \else
\iffluor \fluorfalse \kern-.1em \fi\low{\box\chemlowbox}\fi}
% for "kerning" after F
\newif\iffluor
\unexpanded\def\molecule%
{\bgroup
\catcode`\_=\active \uccode`\~=`\_ \uppercase{\let~\chemlow}%
\catcode`\^=\active \uccode`\~=`\^ \uppercase{\let~\chemhigh}%
\dostepwiserecurse {65}{90}{1}
{\catcode \recurselevel = \active
\uccode`\~=\recurselevel
\uppercase{\edef~{\noexpand\finishchem
\rawcharacter{\recurselevel}}}}%
\uccode `\~=`\F \uppercase{\def~{\finishchem F\fluortrue}}%
\catcode`\-=\active \uccode`\~=`\- \uppercase{\def~{--}}%
\loggingall
\domolecule }%
\def\domolecule#1%
{\expandafter\scantokens\expandafter
{\detokenize{#1\finishchem}}\egroup}
\molecule{H_2O}
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2007-12-23 23:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-22 8:10 Shen Chen
2007-12-23 23:06 ` Mojca Miklavec [this message]
2007-12-24 5:54 ` Shen Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6faad9f00712231506o15617410h9c43d83a28b6cf7a@mail.gmail.com \
--to=mojca.miklavec.lists@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).