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 Regards, shenchen
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}
Thanks for the suggestion, Taco's \molecule macro works.
There is a similar problem for Units (with \usemodule[units]) that appears
in headings, table of contents and list of figure captions, etc.
Sample code:
\usemodule[units]
\starttext
\placecontent
\section{1 \Square\Centi\Meter}
Hello world! 1 \Square\Centi\Meter
\section{$1\Square\Centi\Meter$}
Hello world! $1\Square\Centi\Meter$
\section{$1 {\rm cm^2}$}
Hello world! $1 {\rm cm^2}$
\stoptext
Units appear normally in text. But only the primary dimension "m" appeared
in heading/list, while power/prefix are lost.
In this case, I was able to trace down in the source code a little bit.
In core-syn.tex, there is:
\setupsynonyms
[\v!unit]
[\c!textstyle=\dimension]
And \dimension is supposed to be invoked here:
\def\processsynonym#1#2#3%
{\begingroup % anders in mathmode lege \hbox, zie eenheden
\ifsynonymmeaning
\synonymmeaningfalse
\doattributes{\??sm#1}\c!synonymstyle\c!synonymcolor{#3}%
\else
\explicithmode
\doattributes{\??sm#1}\c!textstyle\c!textcolor{#2}%
\fi
\endgroup}
However, in the case of heading/lists, \dimension is not called. I don't
understand the part about \doattributes, and couldn't trace further. Thank
you.
Regards,
shenchen
On 12/24/07 7:06 AM, "Mojca Miklavec"
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
participants (2)
-
Mojca Miklavec
-
Shen Chen