ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Chemistry in lists
@ 2007-12-22  8:10 Shen Chen
  2007-12-23 23:06 ` Mojca Miklavec
  0 siblings, 1 reply; 3+ messages in thread
From: Shen Chen @ 2007-12-22  8:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Chemistry in lists
  2007-12-22  8:10 Chemistry in lists Shen Chen
@ 2007-12-23 23:06 ` Mojca Miklavec
  2007-12-24  5:54   ` Shen Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Mojca Miklavec @ 2007-12-23 23:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Chemistry in lists
  2007-12-23 23:06 ` Mojca Miklavec
@ 2007-12-24  5:54   ` Shen Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Shen Chen @ 2007-12-24  5:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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" <mojca.miklavec.lists@gmail.com>
wrote:

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

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-24  5:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-22  8:10 Chemistry in lists Shen Chen
2007-12-23 23:06 ` Mojca Miklavec
2007-12-24  5:54   ` Shen Chen

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).