# problem with chemical structure numbering

I would like to have a numbering of chemistry related structures to appear like this.

Compound 1a and 1b are useful, whereas compound 1c and 2a are harmful.

I would not like to generate the references myself. I can generate the image is in png / jpg / bmp/ gif / tif / emf / svg format not in eps format.

Compound    R1  R2
Toluene, 1a CH3 H
Ethyl benzene, 1b   C2H5    H
Chlorobenzene, 1c   Cl  H
o-chlorotoluene, 2a CH3 Cl


The modified question is "The question is how can i label 1a, 1b, 1c and 2a in the running matter. And how can i insert the reference where ever i wish." See the included pdf image!

-
Welcome to TeX.sx. Your question as it stands now is very unclear. The format of your images has nothing to do with how they are labeled or referenced. LaTeX provides a \label and \ref system that will work for anything, and there are various methods for including figures as subfigures, including the subfig and subcaption packages. For example: How to put two images next to each other with a) and b) labels? and How can I put three pictures with sub-captions in two rows using subfig package? – Alan Munn Dec 16 '11 at 2:58

The best of the chemical numbering packages is chemnum, which is newer than chemcompounds (my previous pick-of-the-packages), bpchem and compoundcntr (which is very awkward to use). With chemnum, each compound is labelled using the \cmpd macro. This creates numerical references, but allows us to subdivide using . to generate letters. I would combined with mhchem for the formula parts:

\documentclass{article}
\usepackage{booktabs,chemnum}
\usepackage[version=3]{mhchem}
\begin{document}
\begin{table}
\centering
\caption{Benzene derivatives}
\label{tbl:compounds}
\begin{tabular}{lll}
\toprule
Compounds & R$^1$ & R$^2$ \\
\midrule
Toluene                (\cmpd{Ph.Me})    & \ce{CH3}  & \ce{H}  \\
Ethyl benzene          (\cmpd{Ph.Et})    & \ce{C2H5} & \ce{H}  \\
Chlorobenzene          (\cmpd{Ph.Cl})    & \ce{Cl}   & \ce{H}  \\
\emph{o}-Chlorotoluene (\cmpd{o-Tol.Cl}) & \ce{CH3}  & \ce{Cl} \\
\bottomrule
\end{tabular}
\end{table}

In Table~\ref{tbl:compounds}, compounds~\cmpd{Ph.Me} and~\cmpd{Ph.Et}
are useful, whereas compounds~\cmpd{Ph.Cl} and~\cmpd{o-Tol.Cl}
are harmful.

\end{document}


Notice that I've gone with the standard approach that chemical numbers are bold, which can be set using a package option.

-
Dear Wright,Thanks you very much. just out of curiosity, If required how do you take out the alphabets and looks like 1,2,3,4 etc and not like 1a, 1b, 1c etc. Regards – Anil Dec 16 '11 at 16:38
@Anil You can reference the entire of a range of numbers by missing out the subdivision (after the .). So in the example, \cmpd{Ph} will print '1' and \cmpd{o-Tol} will print '2'. – Joseph Wright Dec 16 '11 at 16:40
@Wright, You mean number of characters minus 1 is the number??? – Anil Dec 16 '11 at 16:49
@Anil. No, the argument to \cmpd is a label, and is freely-selectable in the same way that for \label. I picked Ph and o-Tol as these make chemical sense in the context of the table you asked about. I could have picked anything, provided that there was not . in it. With the standard settings the chemnum package uses . as the indicator for subdivision: you can alter this if you wish. – Joseph Wright Dec 16 '11 at 17:02
@Anil the syntax is \cmpd{<label>.<sublabel1>} = "1a", \cmpd{<label>.<sublabel2>} = "1b", \cmpd{<label1>.} = "1", \cmpd{<lable1>,<label2>,<label3>} = "1,2, and 3", \cmpd{<label1>.<sublabel1>,<label2>.<sublabel1>} = "1a and 2a" – clemens Dec 16 '11 at 17:08

Here is one approach to a compound numbering scheme (taken from a duplicate post on LaTeX User's Group):

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{xparse}% http://ctan.org/pkg/xparse
\newcounter{compoundcntr} \newcounter{subcompoundcntr}[compoundcntr]
\renewcommand{\thesubcompoundcntr}{\thecompoundcntr\alph{subcompoundcntr}}
\NewDocumentCommand{\compound}{s o m}{%
\IfBooleanTF{#1}
{% \compound*[<label>]{<name>}
\IfNoValueTF{#2}
{#3}% \compound{<name>}
{\stepcounter{compoundcntr}\refstepcounter{subcompoundcntr}#3, \thesubcompoundcntr\label{#2}}% \compound[<label>]{<name>}
}
{% \compound[<label>]{<name>}
\ifnum\value{compoundcntr}=0\stepcounter{compoundcntr}\fi% Can use \compound[<label>]{<name>} to start first compound
\IfNoValueTF{#2}
{#3}% \compound*{<name>}
{\refstepcounter{subcompoundcntr}#3, \thesubcompoundcntr\label{#2}}% \compound*[<label>]{<name>}
}
}
\begin{document}
\begin{table}[t]
\centering
\begin{tabular}{lll}
\toprule
Compound & R$^1$ & R$^2$ \\
\midrule
\compound*[toluene]{Toluene} & CH3 & H \\
\compound[ethylbenzene]{Ethyl benzene} & C2H5 & H \\
\compound[chlorobenzene]{Chlorobenzene} & Cl & H \\
\compound*[o-chlorotoluene]{o-chlorotoluene} & CH3 & Cl \\
\bottomrule
\end{tabular}
\caption{Some compounds} \label{tbl:compounds}
\end{table}

In Table~\ref{tbl:compounds}, compound~\ref{toluene} and~\ref{ethylbenzene} are useful, whereas compound~\ref{chlorobenzene} and~\ref{o-chlorotoluene} are harmful.
\end{document}


The main command is \compound*[<label>]{<name>}. If you specify the starred version (\compound*[<label>]{<name>}), a new "main compound" is created (incrementing the first number). The unstarred version (\compound[<label>]{<name>}) does not increment the "main compound" counter, but increments the "sub compound" counter. If you specify a <label> (yes, this is optional), it prints the compound number. Otherwise, it doesn't. Whatever you specify in <name> (a mandatory argument) is printed as the name.

In summary, the available commands are

• \compound*[<label>]{<name>} = new "main compound" with compound number
• \compound*{<name>} = new "main compound" without compound number
• \compound[<label>]{<name>} = new "sub compound" with compound number
• \compound{<name>} = new "sub compound" without compound number

Effectively \compound*{<name>} and \compound{<name>} are the same. You reference the compounds by using \ref{<label>}, as usual, as seen in the example. Modifications to label representation and command usage is also possible. Care has been taken to allow starting the first compound with \compound instead of \compound*.

If your interested in a single compound numbering scheme, the construction of \compound is much simpler. Here's a view on one such construction:

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{xparse}% http://ctan.org/pkg/xparse
\newcounter{compoundcntr}
\renewcommand{\thecompoundcntr}{\arabic{compoundcntr}}
\NewDocumentCommand{\compound}{s o m}{%
\IfBooleanTF{#1}
{% \compound*[<label>]{<name>}
#3%
}
{% \compound[<label>]{<name>}
\refstepcounter{compoundcntr}% Increment compound counter for correct referencing
#3, \thecompoundcntr
\IfNoValueTF{#2}
{}% \compound{<name>}
{\label{#2}}% \compound[<label>]{<name>}
}
}
\begin{document}
\begin{table}[t]
\centering
\begin{tabular}{lll}
\toprule
Compound & R$^1$ & R$^2$ \\
\midrule
\compound[toluene]{Toluene} & CH3 & H \\
\compound[ethylbenzene]{Ethyl benzene} & C2H5 & H \\
\compound[chlorobenzene]{Chlorobenzene} & Cl & H \\
\compound[o-chlorotoluene]{o-chlorotoluene} & CH3 & Cl \\
\bottomrule
\end{tabular}
\caption{Some compounds} \label{tbl:compounds}
\end{table}

In Table~\ref{tbl:compounds}, compound~\ref{toluene} and~\ref{ethylbenzene} are useful, whereas compound~\ref{chlorobenzene} and~\ref{o-chlorotoluene} are harmful.
\end{document}


Using \compound*[<label>]{<name>} doesn't make much sense, since <label> is disregarded.

-
Thanks Werner and it worked fine – Anil Dec 16 '11 at 5:33
@Anil: If this answered your question, please consider upvoting and marking it as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). – Werner Dec 16 '11 at 5:45
@Werner The R groups here should not be italic (a "mathematician's mistake"), and the radical numbers (1 and 2 after R) should be superscript. Subscript => number of R groups, superscript => different R groups. – Joseph Wright Dec 16 '11 at 8:26
@JosephWright: Thanks - didn't know that; corrected. – Werner Dec 16 '11 at 20:04