Graphics, Figures & Tableschemical formula numbering

Information and discussion about graphics, figures & tables in LaTeX documents.
dfodor
Posts: 6
Joined: Sun Nov 01, 2009 8:28 pm

chemical formula numbering

Post by dfodor »

Hi!

Is there any common way to refer to chemical compounds in latex? My problem is that I can draw the complexes and insert them as a figure but I cannot refer to the compounds in a simple way. Let's say I have complex A and B in a reaction (in the same figure) and I would like to refer to complex A. Just like to a mathematical equation. I can insert of course an "a" or a "b" below the complexes in the figure but I would like to make it automatically (like \ref{a} or something like that).

I hope I could explain clearly, what I want.

Thanks.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

chemical formula numbering

Post by josephwright »

In your text, you can use chemcompounds or bpchem: I favour chemcompounds. In schemes, I've written a package called chemscheme that will do a substitution for temporary "markers" in your graphics.
Joseph Wright
dfodor
Posts: 6
Joined: Sun Nov 01, 2009 8:28 pm

Re: chemical formula numbering

Post by dfodor »

Hi Joseph,

thanks again for helping :)
That was fast.

Have a nice day
muchalh
Posts: 12
Joined: Fri Aug 14, 2009 4:51 am

chemical formula numbering

Post by muchalh »

Am I getting it right?

To automatically number compounds in a graphic I should use chemstyle. To automatically number and reference compounds in the text I should use bpchem or chemcompounds.

Is it possible to use the labels used to replace "markers" to reference in the text? For example use the \schemeref labels and refer to them later in the text.

Code: Select all

\begin{scheme}[ht]
\schemeref{Oxdd4Cl} %Product: 4-ClC6H4-substituted
\schemeref{ThioUCF3} %Thiourea with 3,5-CF3
\schemeref{ThioUCin} %Thiourea with cincona alkaloid
\includegraphics{thiourea-screen}
\caption{The caption I need to come up with}
\end{scheme}
In the above example the "markers" are substituted beautifully but I don't know if I can refer to them later. Using /ref{Oxdd4Cl} gives me `??' as output.

Thanks,

muchalh
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: chemical formula numbering

Post by josephwright »

Internally, chemscheme uses either chemcompounds or bpchem (which one is a user option). The default is to use chemcompounds, so you'd use the \compound macro for cross references.
Joseph Wright
bit
Posts: 14
Joined: Wed Feb 11, 2009 1:07 am

chemical formula numbering

Post by bit »

Hello guys!

My girlfriend uses Xelatex in order to write Greek with Texmakerx on Windows - Miktex2.8.

However, she can not make chemstyle properly work and display the eps images. Specifically, in the preamble she loads:

Code: Select all

\documentclass[a4paper,11pt]{report}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{xgreek}
\setmainfont[Mapping=TeX-text]{Minion Pro}
%\usepackage{graphicx}
%\usepackage[colorlinks]{hyperref}
%\usepackage[colorinlistoftodos]{todonotes}
\usepackage[runs=2]{auto-pst-pdf}
\usepackage{booktabs}
\usepackage{chemscheme}
and in the tex file she uses:

Code: Select all

\begin{scheme}[ht]
\includegraphics[scale=0.5]{eikones/coumarins.eps} 
\caption{Synthesis of coumarins}
\end{scheme}

\begin{scheme}[ht]
 \schemeref[TMP1]{h}
 \schemeref[TMP2]{d}
 \includegraphics[scale=0.5]{eikones/coumarins.eps} 
 \caption{Synthesis of coumarins}
\end{scheme}
The first scheme is perfectly compiled and seen in the final pdf outpout, but the second scheme with the schemeref commands is not well compiled and she gets error of undefined control sequence...

Does anybody know if there is a problem with chemstyle and xelatex, or what could be wrong in that case?

Thank you all in advance!

Alex
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: chemical formula numbering

Post by josephwright »

Unfortunately, psfrag (which ultimately does the substitution) does not work with xetex. I guess I should add something to the docs about this: I'll look at it later today. Sorry about this!
Joseph Wright
bit
Posts: 14
Joined: Wed Feb 11, 2009 1:07 am

Re: chemical formula numbering

Post by bit »

Hello Joseph!

Thank you for replying and informing on this problem.

To be honest, this will be very sad for my girlfriend who has just started writing her PhD thesis on latex (after my encourage and support on learning latex) and has to handle many compounds-schemes! :cry:

However, if it could be fixed, it would be wonderful for all those chemists that have to use xelatex mainly because they need it as an alternative to write their latex docs to different languages than English, like Greek for example (with xelatex one doesn't have to write \selectlanguage{greek} and \selectlanguage{english} in order to change between those two languages).

I am not very familiar with programming, so I hope it could be easy to fix, if you have the time to look at it!

Thank you for your information again!

I am looking forward to your news!!!

Alex
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: chemical formula numbering

Post by josephwright »

If it was easy I'd have done it (I am on the LaTeX kernel team, so I do know my way around TeX). The problem is, unfortunately, pretty fundamental and is to do with how XeTeX handles graphics. This is more similar to PDF-mode for pdfTeX rather than the traditional DVI route. Some changes were made to allow pstricks to work, but I don't think psfrag is easy. It would certainly require engine-level changes, and that is not something I'm too keen on attempting (I've done a little bit once, but the graphics area is complicated).
Joseph Wright
bit
Posts: 14
Joined: Wed Feb 11, 2009 1:07 am

Re: chemical formula numbering

Post by bit »

Dear Joseph,

thank you again for replying and for orientating me into the problem...I hope some day this could be fixed!

I hope for the best towards developing into all directions for latex users. I acknowledge all efforts that come from the community! ;)

Kind regards,

Alex
Post Reply