| 1 |
% -------------------------------------------------------------------------- |
| 2 |
% the CHEMNUM package |
| 3 |
% |
| 4 |
% a comprehensive approach for the numbering of chemical compounds |
| 5 |
% |
| 6 |
% -------------------------------------------------------------------------- |
| 7 |
% Clemens Niederberger |
| 8 |
% -------------------------------------------------------------------------- |
| 9 |
% https://github.org/cgnieder/chemnum/ |
| 10 |
% [email protected] |
| 11 |
% -------------------------------------------------------------------------- |
| 12 |
% If you have any ideas, questions, suggestions or bugs to report, please |
| 13 |
% feel free to contact me. |
| 14 |
% -------------------------------------------------------------------------- |
| 15 |
% Copyright 2011--2021 Clemens Niederberger |
| 16 |
% |
| 17 |
% This work may be distributed and/or modified under the |
| 18 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 19 |
% of this license or (at your option) any later version. |
| 20 |
% The latest version of this license is in |
| 21 |
% http://www.latex-project.org/lppl.txt |
| 22 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 23 |
% version 2008/05/04 or later. |
| 24 |
% |
| 25 |
% This work has the LPPL maintenance status `maintained'. |
| 26 |
% |
| 27 |
% The Current Maintainer of this work is Clemens Niederberger. |
| 28 |
% -------------------------------------------------------------------------- |
| 29 |
% !arara: pdflatex: { shell: on , interaction: nonstopmode } |
| 30 |
% !arara: pdflatex: { shell: on , interaction: nonstopmode } |
| 31 |
% !arara: biber |
| 32 |
% arara: pdflatex: { interaction: nonstopmode } |
| 33 |
% arara: pdflatex: { interaction: nonstopmode } |
| 34 |
\documentclass[load-preamble+,ngerman,british,american]{cnltx-doc} |
| 35 |
\usepackage{chemnum} |
| 36 |
\setcnltx{ |
| 37 |
package = chemnum , |
| 38 |
info = numbering of chemical compounds , |
| 39 |
authors = Clemens Niederberger , |
| 40 |
email = [email protected] , |
| 41 |
url = https://github.com/cgnieder/chemnum/ , |
| 42 |
add-cmds = { |
| 43 |
chemnumshowdef, |
| 44 |
chemnumshowref, |
| 45 |
cmpd , |
| 46 |
initcmpd , |
| 47 |
labelcmpd , |
| 48 |
cmpdplain , |
| 49 |
cmpdproperty , |
| 50 |
cmpdref , |
| 51 |
replacecmpd , |
| 52 |
resetcmpd , |
| 53 |
setchemnum , |
| 54 |
cmpdshowdef , |
| 55 |
cmpdshowref , |
| 56 |
newcmpdcounterformat , |
| 57 |
subcmpdplain , |
| 58 |
submaincmpdplain , |
| 59 |
subcmpdproperty , |
| 60 |
subcmpdshowdef , |
| 61 |
subcmpdshowref , |
| 62 |
} , |
| 63 |
add-silent-cmds = { |
| 64 |
arrow, |
| 65 |
bottomrule, |
| 66 |
ch,chemfig,chemname, |
| 67 |
CNlabel,CNlabelnoref,CNlabelsub,CNlabelsubnoref, |
| 68 |
CNref,CNrefsub,CNsubnoref, |
| 69 |
compound,cs, |
| 70 |
declarecompound,definesubmol,detokenize, |
| 71 |
expandfull,expandtwice, |
| 72 |
fcite, |
| 73 |
includegraphics, |
| 74 |
keyis, |
| 75 |
marginnote, midrule, |
| 76 |
NewDocumentCommand, |
| 77 |
schemestart,schemestop,setchemfig, |
| 78 |
theffbibliography, toprule |
| 79 |
} , |
| 80 |
index-setup = { othercode=\footnotesize,level=\addsec }, |
| 81 |
makeindex-setup = { columns=3,columnsep=1em } , |
| 82 |
add-frame = false |
| 83 |
} |
| 84 |
\usepackage[artemisia]{textgreek} |
| 85 |
\activatechemgreekmapping{textgreek} |
| 86 |
|
| 87 |
\usepackage{chemformula} |
| 88 |
\setchemformula{format=\libertineLF} |
| 89 |
\usepackage{chemfig,relsize} |
| 90 |
\setchemfig{ |
| 91 |
atom sep = 1.78500 em , |
| 92 |
bond style = {line width = 0.06642 em} |
| 93 |
} |
| 94 |
\renewcommand*\printatom[1]{\textsmaller{\ensuremath{\mathsf{#1}}}} |
| 95 |
|
| 96 |
\usepackage{array,booktabs,csquotes} |
| 97 |
|
| 98 |
\usepackage{graphicx} |
| 99 |
|
| 100 |
\defbibheading{bibliography}[References]{\addsec{#1}} |
| 101 |
|
| 102 |
\usepackage{acro,accsupp} |
| 103 |
\acsetup{ |
| 104 |
format/short = \scshape , |
| 105 |
first-style = short |
| 106 |
} |
| 107 |
\DeclareAcronym{pdf}{ |
| 108 |
short = pdf , |
| 109 |
long = portable document format , |
| 110 |
pdfstring = PDF , |
| 111 |
short-acc = PDF |
| 112 |
} |
| 113 |
\DeclareAcronym{eps}{ |
| 114 |
short = eps , |
| 115 |
long = encapsulated postscript , |
| 116 |
pdfstring = EPS , |
| 117 |
short-acc = EPS |
| 118 |
} |
| 119 |
\DeclareAcronym{ps}{ |
| 120 |
short = ps , |
| 121 |
long = postscript , |
| 122 |
pdfstring = PS , |
| 123 |
short-acc = PS |
| 124 |
} |
| 125 |
\DeclareAcronym{id}{ |
| 126 |
short = id , |
| 127 |
long = identification key , |
| 128 |
pdfstring = ID , |
| 129 |
short-acc = ID |
| 130 |
} |
| 131 |
|
| 132 |
\begin{document} |
| 133 |
\selectlanguage{american} |
| 134 |
|
| 135 |
\section{License and Requirements}\label{sec:license-requirements} |
| 136 |
\license |
| 137 |
|
| 138 |
\chemnum\ requires the bundles \bnd{l3kernel}~\cite{bnd:l3kernel} and |
| 139 |
\bnd{l3packages}~\cite{bnd:l3packages}. It also requires the |
| 140 |
\pkg{translations} package~\cite{pkg:translations}, |
| 141 |
\pkg{chemgreek}~\cite{pkg:chemgreek} and the \pkg{psfrag}~\cite{pkg:psfrag} |
| 142 |
package. |
| 143 |
|
| 144 |
\section{Overview over the Available Commands}\label{sec:overv-over-avail} |
| 145 |
|
| 146 |
This section lists all available commands with a brief description. Commands |
| 147 |
marked with \expandablesymbol\ are expandable in an \cs*{edef} like context. |
| 148 |
Most of the commands will be explained in a later section in more detail. |
| 149 |
|
| 150 |
\begin{commands} |
| 151 |
\command{cmpd}[\sarg\code{+}\oarg{options}\marg{list of \acp{id}}] |
| 152 |
The main command for creating and refering to compound labels. This |
| 153 |
command is described in detail in section~\ref{sec:deta-comp-labels}. For |
| 154 |
many people this will be the only command they need. |
| 155 |
\command{refcmpd}[\oarg{options}\marg{\ac{id}}] |
| 156 |
This command only refers to an already defined label but does not define a |
| 157 |
label itself. This is an alias of \cs{cmpd}\code{+}. |
| 158 |
\command{labelcmpd}[\oarg{options}\marg{\ac{id}}] |
| 159 |
This command only defines a new label but does not print it. This is an |
| 160 |
alias of \cs{cmpd}\sarg. |
| 161 |
\expandable\command{cmpdplain}[\marg{\ac{id}}] |
| 162 |
Reads a label and writes it expandably without formatting. It is not able |
| 163 |
to parse a list. Its sole purpose is usage in \ac{pdf} strings |
| 164 |
(\cf\ \cs*{texorpdfstring}\marg{\TeX}\marg{\ac{pdf} string}). This |
| 165 |
command is described in section~\ref{sec:deta-comp-labels}. |
| 166 |
\expandable\command{subcmpdplain}[\marg{main \ac{id}}\marg{sub \ac{id}}] |
| 167 |
Reads a sublabel and writes it expandably without formatting. It is not |
| 168 |
able to parse a list. Its sole purpose is usage in pdfstrings |
| 169 |
(\cf\ \cs*{texorpdfstring}\marg{\TeX}\marg{\ac{pdf} string}). This |
| 170 |
command is described in section~\ref{sec:deta-comp-labels}. |
| 171 |
\expandable\command{submaincmpdplain}[\marg{main \ac{id}}\marg{sub \ac{id}}] |
| 172 |
Reads a main label and a sublabel and writes them expandably without |
| 173 |
formatting. It is not able to parse a list. Its sole purpose is usage in |
| 174 |
\ac{pdf} strings (\cf\ \cs*{texorpdfstring}\marg{\TeX}\marg{\ac{pdf} |
| 175 |
string}). This command is described in |
| 176 |
section~\ref{sec:deta-comp-labels}. |
| 177 |
\command{replacecmpd}[\code{+}\oarg{options}\marg{\ac{id}}] |
| 178 |
A command for replacing tags in \ac{eps} files, see |
| 179 |
section~\ref{sec:replacing-tags-eps-ps} for details. |
| 180 |
\command{initcmpd}[\oarg{options}\marg{list of \acp{id}}] |
| 181 |
Initiate compound labels. This command can only be used in the preamble. |
| 182 |
It is desribed in section~\ref{sec:deta-comp-labels}. |
| 183 |
\expandable\command{cmpdproperty}[\marg{\ac{id}}\marg{property}] |
| 184 |
Get the associated property \meta{property} of compound |
| 185 |
\meta{\ac{id}}. This command is described in |
| 186 |
section~\ref{sec:deta-comp-labels}. |
| 187 |
\expandable\command{subcmpdproperty}[\marg{main \ac{id}}\marg{sub |
| 188 |
\ac{id}}\marg{property}] |
| 189 |
Get the associated property \meta{property} of subcompound \meta{sub |
| 190 |
\ac{id}} of compound \meta{main \ac{id}}. This command is described |
| 191 |
in section~\ref{sec:deta-comp-labels}. |
| 192 |
\command{newcmpdcounterformat}[\marg{name}\marg{command}] |
| 193 |
Makes the label format \meta{name} known to \chemnum. \meta{command} |
| 194 |
needs to be a command that takes an integer number as argument and should |
| 195 |
return a formatted version of it. In practice you should not need to use |
| 196 |
this command as the most common formats already are defined. This command |
| 197 |
is described in section~\ref{sec:change-numbering}. |
| 198 |
\command{resetcmpd}[\oarg{integer}]\Default{1} |
| 199 |
Reset the numbering for main compound labels to start with \meta{integer} |
| 200 |
again. This is the same as |
| 201 |
\cs*{setcounter}\Marg{cmpdmain}\Marg{$\text{\meta{integer}}-1$}. The |
| 202 |
command is described in section~\ref{sec:reset-numbering}. |
| 203 |
\command{cmpdshowdef}[\marg{\ac{id}}] |
| 204 |
Internal command used to display \meta{\ac{id}} of a newly defined compound |
| 205 |
label when the option \option{show-keys} is used. The command is |
| 206 |
described in section~\ref{sec:debugg-inform}. |
| 207 |
\command{cmpdshowref}[\marg{\ac{id}}] |
| 208 |
Internal command used to display \meta{\ac{id}} of a referencing compound |
| 209 |
label when the option \option{show-keys} is used. The command is |
| 210 |
described in section~\ref{sec:debugg-inform}. |
| 211 |
\command{subcmpdshowdef}[\marg{main \ac{id}}\marg{sub \ac{id}}] |
| 212 |
Internal command used to display \meta{main \ac{id}} and \meta{sub |
| 213 |
\ac{id}} of a newly defined subcompound label when the option |
| 214 |
\option{show-keys} is used. The command is described in |
| 215 |
section~\ref{sec:debugg-inform}. |
| 216 |
\command{subcmpdshowref}[\marg{main \ac{id}}\marg{sub \ac{id}}] |
| 217 |
Internal command used to display \meta{main \ac{id}} and \meta{sub |
| 218 |
\ac{id}} of a referencing subcompound label when the option |
| 219 |
\option{show-keys} is used. The command is described in |
| 220 |
section~\ref{sec:debugg-inform}. |
| 221 |
\command{setcmpdproperty}[\marg{property}\marg{main \ac{id}}\marg{value}] |
| 222 |
\sinceversion{1.3}Sets property \meta{property} of compound \meta{main |
| 223 |
\ac{id}} to \meta{value}. |
| 224 |
\command{setcmpdlabel}[\marg{main \ac{id}}\marg{value}] |
| 225 |
\sinceversion{1.3}Sets property \code{counter-representation} of compound |
| 226 |
\meta{main \ac{id}} to \meta{value}. |
| 227 |
\end{commands} |
| 228 |
|
| 229 |
\section{Numbering Compounds}\label{sec:numbering-compounds} |
| 230 |
\subsection{Main Command}\label{sec:main-command}\resetcmpd |
| 231 |
|
| 232 |
The main command of this package is this one: |
| 233 |
\begin{commands} |
| 234 |
\command{cmpd}[\marg{\ac{id}}] |
| 235 |
When \meta{\ac{id}} is used the first time, the label is created, saved |
| 236 |
(= declared) and printed. Each further use just prints the label. |
| 237 |
\end{commands} |
| 238 |
|
| 239 |
\begin{example} |
| 240 |
Compounds \cmpd{a} and \cmpd{b} are declared and can be used any time: |
| 241 |
\cmpd{a}. No pre-declaring is necessary. Compounds like \cmpd{c} are |
| 242 |
numbered in the order they appear in the text.\par |
| 243 |
Once again: \cmpd{b}, \cmpd{a}, \cmpd{c}. |
| 244 |
\end{example} |
| 245 |
|
| 246 |
If it is necessary to declare a compound without printing the label it is |
| 247 |
possible with |
| 248 |
\begin{commands} |
| 249 |
\command{cmpd}[\sarg\marg{\ac{id}}] |
| 250 |
Declare the label \meta{\ac{id}} but don't print anything. |
| 251 |
\end{commands} |
| 252 |
|
| 253 |
\begin{example} |
| 254 |
The hidden version\cmpd*{d} declares the label but doesn't print anything. |
| 255 |
The next \cmpd{e} continues to count with the next number. With \cmpd{d} |
| 256 |
the label can be used, of course. |
| 257 |
\end{example} |
| 258 |
|
| 259 |
You can pretty much use what you like for a label name except for the |
| 260 |
separator symbols (see also section~\ref{sec:chang-input-mark}). Be careful |
| 261 |
with blanks though! Leading and trailing spaces are ignored, spaces at other |
| 262 |
places are not. It's probably best not to use blanks in label names at all. |
| 263 |
|
| 264 |
\begin{example}[add-sourcecode-options={showspaces=true}] |
| 265 |
\cmpd{aa}, \cmpd{aa }, \cmpd{ aa}, and \cmpd{ aa } all have the same label. |
| 266 |
Likewise \cmpd{a a}, \cmpd{a a }, \cmpd{ a a}, \cmpd{ a a }, \cmpd{a a}, |
| 267 |
\cmpd{a a }, \cmpd{ a a}, and \cmpd{ a a }. |
| 268 |
\end{example} |
| 269 |
|
| 270 |
\subsection{Sublabels}\label{sec:sublabel} |
| 271 |
If you want a label like \cmpd{a.one}, you need to use the following syntax: |
| 272 |
\begin{commands} |
| 273 |
\command{cmpd}[\Marg{\meta{main \ac{id}}.\meta{sub \ac{id}}}] |
| 274 |
\meta{main \ac{id}} is the main name which stays the same, \meta{sub |
| 275 |
\ac{id}} varies. This syntax means that the point \code{.} |
| 276 |
\emph{cannot} be a part of \meta{main \ac{id}} or \meta{sub \ac{id}} |
| 277 |
(except if you enclose the respective \ac{id} in braces). Instead of the |
| 278 |
point you also can use another symbol, see |
| 279 |
section~\ref{sec:chang-input-mark} for details. |
| 280 |
\end{commands} |
| 281 |
|
| 282 |
\begin{example} |
| 283 |
\cmpd{f.one} and \cmpd{f.two} are related, as are \cmpd{g.one} and |
| 284 |
\cmpd{g.two}. Of course these labels can be used again: \cmpd{g.two} and |
| 285 |
\cmpd{f.one}. |
| 286 |
\end{example} |
| 287 |
|
| 288 |
This also works if the main name has already been used. |
| 289 |
\begin{example} |
| 290 |
\cmpd{a} and its variants \cmpd{a.one} and \cmpd{a.two} |
| 291 |
\end{example} |
| 292 |
|
| 293 |
The same way the main name of combined labels can be used solely. |
| 294 |
\begin{example}[side-by-side] |
| 295 |
\cmpd{f} and \cmpd{g} |
| 296 |
\end{example} |
| 297 |
|
| 298 |
How you can create a combined label like \cmpd{f.{one,two}} is explained in |
| 299 |
section~\ref{sec:lists-rang-subl}. |
| 300 |
|
| 301 |
\subsection{Lists}\label{sec:lists} |
| 302 |
There is actually more to the \cs{cmpd} command. It also prints lists of |
| 303 |
labels. The right description would be something like: |
| 304 |
\begin{commands} |
| 305 |
\command{cmpd}[\marg{(possibly comma separated list of) label name(s)}] |
| 306 |
Treats each entry of the list as described before. |
| 307 |
\end{commands} |
| 308 |
This means that with default settings the comma can't be part of the label |
| 309 |
name unless hidden in braces. As separator another symbol can be used, too, |
| 310 |
see section~\ref{sec:chang-input-mark} for details. |
| 311 |
|
| 312 |
\begin{example} |
| 313 |
More than one label can be put inside \cs{cmpd}, separated by commas. Then |
| 314 |
a list like \cmpd{a, b, c, e, g.two} is printed. |
| 315 |
\end{example} |
| 316 |
The Harvard comma (see section~\ref{sec:lang-depend-sett}) in \enquote{\code{, and}} |
| 317 |
between \cmpd{e} and \cmpd{g.two} suggests that there are options to customize |
| 318 |
the list, see section~\ref{sec:formatting-labels} for more on this. |
| 319 |
|
| 320 |
The option \option{merge} has an effect on lists: if it is set to \code{true} |
| 321 |
multiple occurences of a main label with a possibly different set of sublabels |
| 322 |
are merged into one label: |
| 323 |
|
| 324 |
\begin{example} |
| 325 |
With \keyis{merge}{true} a list like \cmpd{c,g.two,a,g.{one,four}} looks |
| 326 |
like \cmpd[merge=true]{c,g.two,a,g.{one,four}}. |
| 327 |
\end{example} |
| 328 |
|
| 329 |
\subsection{Lists and Ranges of Sublabels}\label{sec:lists-rang-subl} |
| 330 |
Sometimes it can be useful to display a label with a list or a range of |
| 331 |
sublabels. Suppose you have compounds |
| 332 |
\cmpd{q.one,q.two,q.three,q.four,q.five} which for example differ in their |
| 333 |
substituents. It can be useful to refer to them all at once: |
| 334 |
|
| 335 |
The syntax is rather intuitive -- you just input a list of sublabels: |
| 336 |
\begin{example} |
| 337 |
\setchemnum{compress=false}% |
| 338 |
list of labels: \cmpd{q.one, q.two, q.three, q.four, q.five}\par |
| 339 |
label with list of sublabels: \cmpd{q.{one,two,three,four,five}} |
| 340 |
\end{example} |
| 341 |
Since the sublist is input with a comma in the default setting you have to |
| 342 |
put them into braces. If you add a list of sublabels to a main label they |
| 343 |
will always be printed in the order the sublabels have been declared and not |
| 344 |
in the order they're input in the list: |
| 345 |
|
| 346 |
\begin{example} |
| 347 |
\setchemnum{compress=false}% |
| 348 |
compare \cmpd{q.{one,two,three,four,five}} |
| 349 |
with \cmpd{q.{five,four,three,two,one}} and |
| 350 |
\cmpd{q.{three,four,one,five,two}} |
| 351 |
\end{example} |
| 352 |
|
| 353 |
Using this syntax you also can create ranges of sublabels. For this you |
| 354 |
enable the option \option{compress}. Or rather: this is the default setting. |
| 355 |
If you don't want compressed sublabels you have to disable the option like in |
| 356 |
the previous examples. |
| 357 |
\begin{example}[side-by-side] |
| 358 |
\cmpd{q.{two,four,three}} \par |
| 359 |
\cmpd{q.{five,one,three,four}} \par |
| 360 |
\cmpd{q.{one,three,five,two}} |
| 361 |
\end{example} |
| 362 |
|
| 363 |
Obviously you can't use a comma as part of a sublabel name. You can change |
| 364 |
the input marker, though. See section~\ref{sec:overv-over-avail-1} for |
| 365 |
available options. |
| 366 |
|
| 367 |
Sometimes it can be useful to get only the sublabel without the main label. |
| 368 |
This is achieved with the option \option{sub-only}: |
| 369 |
|
| 370 |
\begin{example} |
| 371 |
% uses packages `chemfig', `chemformula' and `booktabs' |
| 372 |
\chemname{\chemfig{*6(=-=-(-R)=-)}}{\cmpd{benzene.{H,Me,OH,NH2}}} |
| 373 |
\quad |
| 374 |
\begin{tabular}{lll} |
| 375 |
\toprule |
| 376 |
& \ch{-R} & Name \\ |
| 377 |
\midrule |
| 378 |
\cmpd[sub-only]{benzene.H} & \ch{-H} & Benzene \\ |
| 379 |
\cmpd[sub-only]{benzene.Me} & \ch{-CH3} & Toluene \\ |
| 380 |
\cmpd[sub-only]{benzene.OH} & \ch{-OH} & Phenol \\ |
| 381 |
\cmpd[sub-only]{benzene.NH2} & \ch{-NH2} & Phenylamine (Aniline) \\ |
| 382 |
\bottomrule |
| 383 |
\end{tabular} |
| 384 |
\end{example} |
| 385 |
|
| 386 |
\subsection{Usage in Section Headings and Captions}\label{sec:usage-sect-head} |
| 387 |
If you use labels in section headings or captions you will want to use either |
| 388 |
\cs{refcmpd} or \cs{cmpd}\code{+} (they are completely equivalent). Otherwise |
| 389 |
the corresponding labels will be declared when the section headings appear in |
| 390 |
the table of contents or maybe the page header. This would mess up the |
| 391 |
desired order of the compound numbers. |
| 392 |
|
| 393 |
\section{Details on Compound Labels}\label{sec:deta-comp-labels} |
| 394 |
\subsection{How Things Work}\label{sec:how-things-work} |
| 395 |
|
| 396 |
When you call \cs{cmpd} with a new label three things happen: |
| 397 |
\begin{itemize} |
| 398 |
\item The new label gets initiated. This is nothing more than adding it to |
| 399 |
an internal list. The purpose of this is explained in |
| 400 |
section~\ref{sec:initiating-labels}. |
| 401 |
\item The new label gets declared. This means that a number of internal |
| 402 |
commands are defined. Amongst other things they hold a number of |
| 403 |
properties associated with the corresponding label. Those properties are |
| 404 |
explained in more detail in section~\ref{sec:prop-comp-labels}. The |
| 405 |
necessary information of the label are also written to the \code{aux} |
| 406 |
file. |
| 407 |
\item The label gets printed. |
| 408 |
\end{itemize} |
| 409 |
|
| 410 |
Since new labels are declared when \cs{cmpd} is first used using it in section |
| 411 |
titles that are written to the table of contents may to lead to wrong |
| 412 |
numbering. In order to avoid this compound label information is written to |
| 413 |
the \code{aux} file. The command \cs{refcmpd}\oarg{options}\marg{\ac{id}} |
| 414 |
only reads those information but does not declare a label. There is also a |
| 415 |
command which does the opposite: it declares a label if it hasn't been |
| 416 |
declared before but will not print the corresponding label: |
| 417 |
\cs{labelcmpd}\oarg{options}\marg{\ac{id}}. Both commands have shortcut |
| 418 |
versions: \cs{cmpd}\code{+} is the same as \cs{refcmpd}, \cs{cmpd}\sarg\ is |
| 419 |
the same as \cs{labelcmpd}. |
| 420 |
|
| 421 |
Another command available is \cs{cmpdplain}\marg{\ac{id}}. This command is |
| 422 |
similar to \cs{refcmpd}. There are a few important differences, though: |
| 423 |
\cs{cmpdplain} does \emph{not} take a list of labels as argument. It also is |
| 424 |
\emph{not} able to interpret sublabels. \cs{cmpdplain} does not format the |
| 425 |
label with whatever format has been declared. And last but not least: it is |
| 426 |
expandable. This means it can be used to get labels in \ac{pdf} bookmarks. |
| 427 |
It's equivalent \cs{subcmpdplain}\marg{main \ac{id}}\marg{sub \ac{id}} does |
| 428 |
the same for sublabels. A third sibling, \cs{submaincmpdplain}\marg{main |
| 429 |
\ac{id}}\marg{sub \ac{id}}, writes both the main and the sublabel. |
| 430 |
|
| 431 |
I should also say a few words on lists of labels. A usage like |
| 432 |
\verbcode+\cmpd{a,b,c,e}+ will be printed as a \emph{sorted} list. The order |
| 433 |
will be in the order \emph{in which the labels have been defined}. The above |
| 434 |
usage gives \cmpd{a,b,c,e}. The same thing holds for the order of sublabels |
| 435 |
of a compound: the usage \verbcode+\cmpd{q.{one,three,four,two,five}}+ gives |
| 436 |
\cmpd{q.{one,three,four,two,five}} or |
| 437 |
\cmpd[compress=false]{q.{one,three,four,two,five}} (depending on the |
| 438 |
\option{compress} option). Be careful if you have a list with several |
| 439 |
occurences of the same main label but with different sublabels: the labels |
| 440 |
will not be sorted depending on their sublabels. |
| 441 |
\begin{example}[side-by-side] |
| 442 |
\cmpd{q.five,q.two} \par |
| 443 |
\cmpd{q.two,q.five} \par |
| 444 |
\cmpd[merge]{q.five,q.two} \par |
| 445 |
\cmpd{q.five,b,r,q.two,a} |
| 446 |
\end{example} |
| 447 |
|
| 448 |
A last thing on lists: duplicate entries (\ie, \emph{exact} duplicates) will |
| 449 |
be removed. |
| 450 |
|
| 451 |
\subsection{Properties of Compound Labels}\label{sec:prop-comp-labels} |
| 452 |
|
| 453 |
Every label has a number of properties. The first property is of course its |
| 454 |
\ac{id} which identifies the label. The other properties are: |
| 455 |
\begin{description} |
| 456 |
\item[number] An internal unique number. |
| 457 |
\item[counter-representation] The counter representation associated with the |
| 458 |
label. This is the actual label that get's printed. |
| 459 |
\item[pre-label-code] Code to be inserted before the label is printed. |
| 460 |
\item[post-label-code] Code to be inserted after the complete label is |
| 461 |
printed. |
| 462 |
\item[pre-main-label-code] Code to be inserted before the \emph{main} label |
| 463 |
is printed. |
| 464 |
\item[post-main-label-code] Code to be inserted after the \emph{main} label |
| 465 |
is printed. |
| 466 |
\item[label-format] Formatting commands for the label. This is most likely |
| 467 |
something like \cs*{bfseries}. This is the \emph{default} format. Unlike |
| 468 |
the other properties it can be changed locally with the \option{format} |
| 469 |
option on a case by case basis. |
| 470 |
\end{description} |
| 471 |
|
| 472 |
The properties for a label are set the when a label is declared for the first |
| 473 |
time. |
| 474 |
|
| 475 |
\begin{commands} |
| 476 |
\expandable\command{cmpdproperty}[\marg{\ac{id}}\marg{property}] |
| 477 |
Get the associated property \meta{property} of compound \meta{\ac{id}}. This |
| 478 |
command is expandable. |
| 479 |
\end{commands} |
| 480 |
|
| 481 |
\begin{example} |
| 482 |
\def\expandfull{\romannumeral-`0}% |
| 483 |
\def\expandtwice{\detokenize\expandafter\expandafter\expandafter}% |
| 484 |
\ttfamily |
| 485 |
number: \cmpdproperty{benzene}{number}\par |
| 486 |
counter-representation: \cmpdproperty{benzene}{counter-representation}\par |
| 487 |
pre-label-code: \cmpdproperty{benzene}{pre-label-code}\par % empty |
| 488 |
post-label-code: \cmpdproperty{benzene}{post-label-code}\par % empty |
| 489 |
label-format: \expandtwice{\expandfull\cmpdproperty{benzene}{label-format}} |
| 490 |
\end{example} |
| 491 |
|
| 492 |
Similarly a sublabel has associated properties. Additionally to the obvious |
| 493 |
ones -- its \ac{id} and the \ac{id} the main label it belongs to -- these |
| 494 |
are |
| 495 |
\begin{description} |
| 496 |
\item[number] An internal unique number. |
| 497 |
\item[counter-representation] The counter representation associated with the |
| 498 |
label. This is the actual label that get's printed. |
| 499 |
\end{description} |
| 500 |
|
| 501 |
\begin{commands} |
| 502 |
\expandable\command{subcmpdproperty}[\marg{main \ac{id}}\marg{sub |
| 503 |
\ac{id}}\marg{property}] |
| 504 |
Get the associated property \meta{property} of subcompound \meta{sub |
| 505 |
\ac{id}} of compound \meta{main \ac{id}}. This command is |
| 506 |
expandable. |
| 507 |
\end{commands} |
| 508 |
|
| 509 |
\begin{example} |
| 510 |
\ttfamily |
| 511 |
main-compound: \subcmpdproperty{benzene}{OH}{main-compound}\par |
| 512 |
number: \subcmpdproperty{benzene}{OH}{number}\par |
| 513 |
counter-representation: \subcmpdproperty{benzene}{OH}{counter-representation} |
| 514 |
\end{example} |
| 515 |
|
| 516 |
If you compile with the \keyis{log}{verbose} all properties of a label are |
| 517 |
listed in the log when it is declared. This will typically look like this: |
| 518 |
|
| 519 |
\begin{sourcecode} |
| 520 |
................................................. |
| 521 |
. chemnum info: defined new compound: |
| 522 |
. ID = a |
| 523 |
. internal number = 1 |
| 524 |
. label = A |
| 525 |
. pre label code = |
| 526 |
. post label code = |
| 527 |
. pre main label code = |
| 528 |
. post main label code = |
| 529 |
. format = \bfseries |
| 530 |
................................................. |
| 531 |
\end{sourcecode} |
| 532 |
|
| 533 |
\subsection{Initiating Labels}\label{sec:initiating-labels} |
| 534 |
Initiating labels is not the same as declaring them although it happens |
| 535 |
simultaneously. When a label is \emph{initiated} its \ac{id} is added to an |
| 536 |
internal list. When a label is \emph{declared} all of its properties and |
| 537 |
associated macros are defined. Initiating can serve two purposes: |
| 538 |
\begin{enumerate} |
| 539 |
\item It can help in keeping track of defined labels; if you set the option |
| 540 |
\option{init} \chemnum\ will either issue a warning or an error (depending |
| 541 |
on the actual setting you chose) if a label is used (and hence probably |
| 542 |
declared) \emph{that hasn't been initiated}. This can also help in |
| 543 |
detecting typos in label names. |
| 544 |
\item Since the labels are declared in the preamble you don't need to worry |
| 545 |
about a label erroneously being declared in the table of contents. This |
| 546 |
means the variants \cs{cmpd}\sarg\ and \cs{cmpd}\code{+} shouldn't be |
| 547 |
needed. |
| 548 |
\end{enumerate} |
| 549 |
|
| 550 |
Initiating is done via the command \cs{initcmpd}: |
| 551 |
\begin{sourcecode} |
| 552 |
\initcmpd{a,b,c,d} |
| 553 |
\end{sourcecode} |
| 554 |
You simply use all \acp{id} you want to use like you would use them in |
| 555 |
\cs{cmpd}. \cs{initcmpd} also has an optional argument that allows you to set |
| 556 |
options for those labels. Legal options are the same as for \cs{cmpd}. |
| 557 |
|
| 558 |
Remember: \cs{initcmpd} will both initiate the labels \emph{and} declare the |
| 559 |
labels! |
| 560 |
|
| 561 |
\section{Overview over the Available Options}\label{sec:overv-over-avail-1} |
| 562 |
% Except for the \option{version} option |
| 563 |
All of the following options are either |
| 564 |
set as options to \cs{cmpd} or \cs{initcmpd} directly or via |
| 565 |
\cs{setchemnum}\marg{options}, each time as a comma separated list of |
| 566 |
key/value pairs. Options that can only be set via \cs{setchemnum} are marked |
| 567 |
with \module{general}, those that only have an effect when used with \cs{cmpd} and |
| 568 |
friends are marked with \module{cmpd}. Those marked with \module{both} can |
| 569 |
be set either way. The options affecting the compounds are further divided in |
| 570 |
two classes: I named them global \module*{(g)} and local \module*{(l)}. Options |
| 571 |
from the global class are set when a label is declared the first time and then |
| 572 |
are a fixed property of the corresponding label. Options from the local class |
| 573 |
can be changed at each instance of a label and will then only be active for |
| 574 |
the one instance. |
| 575 |
|
| 576 |
A few of the options only have an effect when used with the \cs{replacecmpd} |
| 577 |
command. They are marked with \module{replace}. |
| 578 |
|
| 579 |
\begin{options} |
| 580 |
\keyval{counter-within}{counter}\Module{general} |
| 581 |
Reset the compound numbers when \meta{counter} is stepped. |
| 582 |
\keychoice{counter-format}{arabic,alph,Alph,roman,Roman,greek,Greek}% |
| 583 |
\Module{both (g)}\Default{arabic} |
| 584 |
The format of the number associated with the main compounds. |
| 585 |
\keychoice{sub-counter-format}{arabic,alph,Alph,roman,Roman,greek,Greek}% |
| 586 |
\Module{both (g)}\Default{alph} |
| 587 |
The format of the number associated with the sub compounds. |
| 588 |
\keybool{compress}\Module{both (l)}\Default{true} |
| 589 |
If set to true a list of sublabels is compressed, \ie, |
| 590 |
\cmpd[compress=false]{q.{one,three,four,five}} becomes |
| 591 |
\cmpd{q.{one,three,four,five}}. |
| 592 |
\keybool{merge}\Module{both (l)}\Default{false} |
| 593 |
If set to true a list of labels is merged, \ie, |
| 594 |
``\cmpd{q.five,a,q.two}'' becomes ``\cmpd[merge=true]{q.five,a,q.two}''. |
| 595 |
\keyval{pre-label-code}{code}\Module{both (g)}\Default |
| 596 |
Code to be inserted before a label. |
| 597 |
\keyval{post-label-code}{code}\Module{both (g)}\Default |
| 598 |
Code to be inserted after a label. |
| 599 |
\keyval{pre-main-label-code}{code}\Module{both (g)}\Default |
| 600 |
\sinceversion{1.2a}Code to be inserted before a main label. |
| 601 |
\keyval{post-main-label-code}{code}\Module{both (g)}\Default |
| 602 |
\sinceversion{1.2a}Code to be inserted after a main label. |
| 603 |
\keyval{main-sub-sep}{code}\Module{both (l)}\Default{.} |
| 604 |
The separator symbol that is used in \cs{cmpd} to separate the \meta{main |
| 605 |
\ac{id}} from a \meta{sub \ac{id}}. |
| 606 |
\keyval{format}{formatting commands}\Module{both (l)}\Default{\cs*{bfseries}} |
| 607 |
The default format of the labels. |
| 608 |
\keyval{list-label-sep}{code}\Module{both (l)}\Default{,} |
| 609 |
The separator that is used to separate different \meta{main \acp{id}} in |
| 610 |
\cs{cmpd}. |
| 611 |
\keyval{sub-list-label-sep}{code}\Module{both (l)}\Default{,} |
| 612 |
The marker that is used to split an input list of sublabels. |
| 613 |
\keyval{list-sep-two}{code}% |
| 614 |
\Module{both (l)}\Default{\visualizespaces{\GetTranslation{chemnum-sep-two}}} |
| 615 |
The output separator between labels in a list that contains of two items. |
| 616 |
\keyval{list-sep-more}{code}\Module{both (l)}\Default{\visualizespaces{, }} |
| 617 |
The output separator between labels in a list that contains of more than |
| 618 |
two items. |
| 619 |
\keyval{list-sep-last-two}{code}% |
| 620 |
\Module{both (l)}\Default{\visualizespaces{\GetTranslation{chemnum-sep-last-two}}} |
| 621 |
The output separator between the last two labels in a list that contains |
| 622 |
of more than two items. |
| 623 |
\keybool{sub-only}\Module{cmpd (l)}\Default{false} |
| 624 |
If true the command \cs{cmpd} will only print sublabels but no main |
| 625 |
labels. |
| 626 |
\keybool{sub-all}\Module{cmpd (l)}\Default{false} |
| 627 |
If true the command \cs{cmpd} will print all sublabels belonging to the |
| 628 |
corresponding main label. |
| 629 |
\keyval{sub-list-sep-two}{code}\Module{both (l)}\Default{,} |
| 630 |
The output separator between labels in a sublist that contains of two |
| 631 |
items. |
| 632 |
\keyval{sub-list-sep-more}{code}\Module{both (l)}\Default{,} |
| 633 |
The output separator between labels in a sublist that contains of more |
| 634 |
than two items. |
| 635 |
\keyval{sub-list-sep-last-two}{code}\Module{both (l)}\Default{,} |
| 636 |
The output separator between the last two labels in a sublist that |
| 637 |
contains of more than two items. |
| 638 |
\keyval{sub-list-sep-range}{code}\Module{both (l)}\Default{--} |
| 639 |
The output separator between two labels in a sublist denoting a range. |
| 640 |
This is only used when the option \option{compress} is active. |
| 641 |
\keybool{replace-auto}\Module{general}\Default{true} |
| 642 |
When set to true this adds an incremented integer to the replacement tag. |
| 643 |
\keyval{replace-tag}{text}\Module{general}\Default{TMP} |
| 644 |
The default replacement tag. |
| 645 |
\keyval{replace-tag-nr}{int}\Module{general}\Default{1} |
| 646 |
The\sinceversion{1.1} next number used by \cs{replacecmpd} when the |
| 647 |
default tag is used. |
| 648 |
\keyval{tag}{text}\Module{replace}\Default{TMP\meta{number}} |
| 649 |
The local replacement tag. \meta{number} is incremented by one at each |
| 650 |
use and starts with \code{1}. The starting number can be changed with the |
| 651 |
option \option{replace-tag-nr}. The increment happens locally. |
| 652 |
\keyval{replace-style}{code}\Module{general}\Default{\cs*{sffamily}} |
| 653 |
Additional \TeX\ code that it placed before the \cs{cmpd} command in the |
| 654 |
replacement. |
| 655 |
\keyval{style}{code}\Module{replace}\Default{\cs*{sffamily}} |
| 656 |
Local additional \TeX\ code that it placed before the \cs{cmpd} command in |
| 657 |
the replacement. |
| 658 |
\keychoice{replace-pos}{\marg{\TeX\ pos}\marg{\ac{ps} |
| 659 |
pos}}\Module{general}\Default{bb} |
| 660 |
Options for \pkg{psfrag}'s \cs{psfrag}. |
| 661 |
\keychoice{pos}{\marg{\TeX\ pos}\marg{\ac{ps} |
| 662 |
pos}}\Module{replace}\Default{bb} |
| 663 |
Local options for \pkg{psfrag}'s \cs{psfrag}. |
| 664 |
\keychoice{init}{\default{true},main,false,strict,main-strict}% |
| 665 |
\Module{general}\Default{false} |
| 666 |
Determines how labels have to be initiated. \code{false} means that |
| 667 |
labels are initiated when they're used the first time in the text. |
| 668 |
\code{true} means that labels should be initiated in the preamble with |
| 669 |
\cs{initcmpd}. \code{main} is the same as \code{true} but only for main |
| 670 |
labels. \code{strict} means that if an un-initiated label is used an |
| 671 |
error is thrown. \code{main-strict} is the same as \code{strict} but only |
| 672 |
for main labels. |
| 673 |
\keychoice{log}{\default{true},false,silent,verbose}\Module{general}\Default{false} |
| 674 |
Determines how the declaration of the labels will be logged. \code{false} |
| 675 |
means that no information is written to the \code{.log} file. \code{true} |
| 676 |
means that basic information is written to the \code{.log} file when a |
| 677 |
label or a sublabel is declared. \code{silent} is an alias of |
| 678 |
\code{true}. \code{verbose} means that detailed information is written to |
| 679 |
the \code{.log} file when a label or a sublabel is declared. |
| 680 |
\keychoice{show-keys}{\default{true},false,def,ref}\Module{general}\Default{false} |
| 681 |
This option will write visual hints when a label is defined (choices |
| 682 |
\code{true} or \code{def}) or when a label is referenced (choices |
| 683 |
\code{true} or \code{ref}). |
| 684 |
\keybool{hyperlinks}\Module{general}\Default{false} |
| 685 |
\sinceversion{1.2}When package \pkg{hyperref} is loaded and this option is |
| 686 |
set to \code{true} then each main label links back to the first time it |
| 687 |
has been used (\ie, it has been labelled \emph{and} printed). |
| 688 |
\end{options} |
| 689 |
|
| 690 |
\section{The Counter Settings}\label{sec:counter-settings} |
| 691 |
The default setting for main labels is arabic numbering which is the most |
| 692 |
common use case for compound labels. There are however cases when you might |
| 693 |
want a different numbering. The numbering also is not reset in a document. I |
| 694 |
have heard of cases where this might be desirable, though. This section will |
| 695 |
tell you how you can achieve those things. |
| 696 |
|
| 697 |
\subsection{Change the Numbering}\label{sec:change-numbering} |
| 698 |
|
| 699 |
The counter representation used for the main and the sublabels can be changed |
| 700 |
using the following options: |
| 701 |
\begin{options} |
| 702 |
\keychoice{counter-format}{arabic,alph,Alph,roman,Roman,greek,Greek}% |
| 703 |
\Module{general}\Default{arabic} |
| 704 |
The format of the number associated with the main compounds. |
| 705 |
\keychoice{sub-counter-format}{arabic,alph,Alph,roman,Roman,greek,Greek}% |
| 706 |
\Module{general}\Default{alph} |
| 707 |
The format of the number associated with the sub compounds. |
| 708 |
\end{options} |
| 709 |
|
| 710 |
Those options can be set globally with \cs{setchemnum} or localized for the |
| 711 |
single compounds. |
| 712 |
\begin{example}[side-by-side] |
| 713 |
\cmpd[counter-format=Alph]{Alpha} and |
| 714 |
\cmpd[counter-format=greek]{greek} |
| 715 |
\end{example} |
| 716 |
|
| 717 |
While it may not be necessary very often to change the default setting one |
| 718 |
could image cases where it makes sense, \eg, Greek sublabels for the anomers |
| 719 |
of a carbohydrate. |
| 720 |
\begin{example} |
| 721 |
% this example uses the `chemfig' package |
| 722 |
\definesubmol{r}{(-[4]H)(-[0]OH)} |
| 723 |
\definesubmol{l}{(-[0]H)(-[4]HO)} |
| 724 |
\labelcmpd[sub-counter-format=greek]{glucose.{alpha,beta}} |
| 725 |
\labelcmpd{glucose.chain} |
| 726 |
\centering |
| 727 |
\schemestart |
| 728 |
\small\chemfig{ |
| 729 |
?(-[:-170]HO) |
| 730 |
-[:-50](-[:170]HO) |
| 731 |
-[:10](-[:-55,0.7]OH) |
| 732 |
-[:-10](-[6,0.8]OH) |
| 733 |
-[:130]O-[:-170]?(-[:150,0.7]-[2,0.7]OH) |
| 734 |
} |
| 735 |
\arrow(alpha--chain){<=>} |
| 736 |
\small\chemfig{[6]O=^[5]-!r-!l-!r-!r--[7]OH} |
| 737 |
\arrow(--beta){<=>} |
| 738 |
\small\chemfig{ |
| 739 |
?(-[:-170]HO) |
| 740 |
-[:-50](-[:170]HO) |
| 741 |
-[:10](-[:-55,0.7]OH) |
| 742 |
-[:-10](-[:10]OH)(-[6,,,,draw=none]\vphantom{OH}) |
| 743 |
-[:130]O-[:-170]?(-[:150,0.7]-[2,0.7]OH) |
| 744 |
} |
| 745 |
\arrow(@chain--chainlabel){0}[-90,.2] \cmpd{glucose.chain} |
| 746 |
\arrow(@chainlabel--){0}[,2.5] \cmpd{glucose.beta} |
| 747 |
\arrow(@chainlabel--){0}[180,2.3] \cmpd{glucose.alpha} |
| 748 |
\schemestop |
| 749 |
\end{example} |
| 750 |
|
| 751 |
Should it ever be necessary to use another kind of counter representations |
| 752 |
than the ones already provided they can be added with this command: |
| 753 |
\begin{commands} |
| 754 |
\command{newcmpdcounterformat}[\marg{name}\marg{code}] |
| 755 |
Makes the label format \meta{name} known to \chemnum. \meta{code} |
| 756 |
needs to end with a command that takes an integer number as mandatory |
| 757 |
argument and should return a formatted version of it. |
| 758 |
\end{commands} |
| 759 |
The \code{arabic} and \code{alph} counter settings for example could have been |
| 760 |
defined like this: |
| 761 |
\begin{sourcecode} |
| 762 |
\newcmpdcounterformat{arabic}{\@arabic} |
| 763 |
\newcmpdcounterformat{alph} {\@alph} |
| 764 |
\end{sourcecode} |
| 765 |
This is actually not true: since \chemnum\ is written in expl3 the |
| 766 |
corresponding \cs*{int\_to\_\meta{\ldots}} functions have been used. |
| 767 |
|
| 768 |
Although the name of the command suggests otherwise it can be used to |
| 769 |
overwrite the default definitions. |
| 770 |
|
| 771 |
\subsection{Reset the Numbering}\label{sec:reset-numbering} |
| 772 |
|
| 773 |
There are cases when it actually might make sense to reset the counting of the |
| 774 |
compound labels. For this you can use this command: |
| 775 |
\begin{commands} |
| 776 |
\command{resetcmpd}[\oarg{integer}]\Default{1} |
| 777 |
Reset the numbering for main compound labels to start with \meta{integer} |
| 778 |
again. This is the same as |
| 779 |
\cs*{setcounter}\Marg{cmpdmain}\Marg{$\text{\meta{integer}}-1$} which |
| 780 |
means the change is global! |
| 781 |
\end{commands} |
| 782 |
|
| 783 |
Be careful, though. You might end up with the same number for different |
| 784 |
compounds: |
| 785 |
\begin{example} |
| 786 |
\resetcmpd The numbering starts with 1 again: \cmpd{h,i,j}, but: |
| 787 |
two compounds with the same label: \cmpd{a,h} |
| 788 |
\end{example} |
| 789 |
|
| 790 |
\section{Formatting Labels}\label{sec:formatting-labels} |
| 791 |
|
| 792 |
As you will have noticed by now labels are typeset with a bold face with the |
| 793 |
default setting of \chemnum. This can be changed: |
| 794 |
\begin{options} |
| 795 |
\keyval{format}{formatting commands}\Module{both (l)}\Default{\cs*{bfseries}} |
| 796 |
The default format of the labels. |
| 797 |
\end{options} |
| 798 |
|
| 799 |
This options works in two ways: it sets the default format that is picked up |
| 800 |
by a compound label when it is defined. When you change it later already |
| 801 |
defined labels dont change: |
| 802 |
\begin{example}[side-by-side] |
| 803 |
\setchemnum{format=\itshape} |
| 804 |
\cmpd{a,b} and \cmpd{new} |
| 805 |
\end{example} |
| 806 |
|
| 807 |
If it is applied directly to the \cs{cmpd} command it changes the formatting |
| 808 |
for this usage of the command only, regardless if the label is new or not: |
| 809 |
\begin{example}[side-by-side] |
| 810 |
\cmpd[format=\itshape]{a,b} vs |
| 811 |
\cmpd{a,b} |
| 812 |
\end{example} |
| 813 |
|
| 814 |
There is more that you can do. Maybe you want to enclose labels in |
| 815 |
parentheses? |
| 816 |
\begin{example} |
| 817 |
\cmpd[pre-label-code=(,post-label-code=)]{x, y, z.one } |
| 818 |
\end{example} |
| 819 |
Please note that these options only have an effect for \emph{newly defined} |
| 820 |
labels since they belong to a label's properties. |
| 821 |
|
| 822 |
Other options are the customization of the list separators: |
| 823 |
\begin{options} |
| 824 |
\keyval{list-sep-two}{code}% |
| 825 |
\Module{general}\Default{\visualizespaces{\GetTranslation{chemnum-sep-two}}} |
| 826 |
The output separator between labels in a list that contains of two items. |
| 827 |
\keyval{list-sep-more}{code}\Module{general}\Default{\visualizespaces{, }} |
| 828 |
The output separator between labels in a list that contains of more than |
| 829 |
two items. |
| 830 |
\keyval{list-sep-last-two}{code}% |
| 831 |
\Module{general}\Default{\visualizespaces{\GetTranslation{chemnum-sep-last-two}}} |
| 832 |
The output separator between the last two labels in a list that contains |
| 833 |
of more than two items. |
| 834 |
\end{options} |
| 835 |
|
| 836 |
\begin{example} |
| 837 |
\setchemnum{list-sep-two=;,list-sep-more=;,list-sep-last-two=;} |
| 838 |
\cmpd{a, b, c, d} |
| 839 |
\end{example} |
| 840 |
|
| 841 |
In the default settings these separators are language dependent. Setting them |
| 842 |
explicitly will overwrite the language sensitivity. If you only want to adapt |
| 843 |
the separators to your language have a look at |
| 844 |
section~\ref{sec:lang-depend-sett}. |
| 845 |
|
| 846 |
\section{Replacing Tags in \ac{eps} or \ac{ps} Files}\label{sec:replacing-tags-eps-ps} |
| 847 |
|
| 848 |
Although it is quite possible to create reaction schemes within \LaTeX\ |
| 849 |
directly -- for example with the \pkg{chemfig} package~\cite{pkg:chemfig} -- |
| 850 |
many people prefer to use a program such as \textsc{ChemDraw} for it. In |
| 851 |
order to be able to use the labels with such schemes as well the following |
| 852 |
method is usually used: |
| 853 |
\begin{itemize} |
| 854 |
\item Create the scheme and place temporary tags like \code{TMP1}, |
| 855 |
\code{TMP2} and so on where you want the compound labels to be. |
| 856 |
\item Export the scheme as \ac{eps} or \ac{ps} figure \emph{where you make |
| 857 |
sure that the tags are embedded as text strings}. If the tags are not |
| 858 |
present as text strings they cannot be replaced. This is a common source |
| 859 |
of user problems. |
| 860 |
\item Include the \ac{eps} with \cs*{includegraphics}. Right before that |
| 861 |
use \cs{replacecmpd} once for every temporary tag. |
| 862 |
\end{itemize} |
| 863 |
\emph{For the actual replacement please make sure that you compile with |
| 864 |
\code{shell-escape} enabled. If you compile with \code{pdflatex} you |
| 865 |
probably also need \pkg{auto-pst-pdf}~\cite{pkg:auto-pst-pdf} loaded. In |
| 866 |
subsequent runs load it with option \code{off} when you turned off |
| 867 |
\code{shell-escape}.} |
| 868 |
|
| 869 |
\begin{commands} |
| 870 |
\command{replacecmpd}[\code{+}\oarg{options}\marg{\ac{id}}] |
| 871 |
Replaces a tag in the following \ac{eps} file. This command doesn't have |
| 872 |
an optional star otherwise the syntax is the same as with \cs{cmpd}. |
| 873 |
\end{commands} |
| 874 |
|
| 875 |
Figure~\ref{fig:scheme-tmp-tags} shows a scheme with temporary tags. It is |
| 876 |
produced with the following code where the class \cls{standalone} has been |
| 877 |
used to get the figure only: |
| 878 |
\begin{example}[compile,exe-with={--shell-escape},runs=1,float=htbp,caption={A scheme with |
| 879 |
temporary tags.\label{fig:scheme-tmp-tags}}] |
| 880 |
% code for figure 1 |
| 881 |
\documentclass{standalone} |
| 882 |
\usepackage{graphicx,auto-pst-pdf} |
| 883 |
\begin{document} |
| 884 |
\includegraphics{scheme-tmp.ps} |
| 885 |
\end{document} |
| 886 |
\end{example} |
| 887 |
|
| 888 |
The tags now can be replaced with labels. The result is shown in |
| 889 |
figure~\ref{fig:scheme-tmp-tags-replaced}. |
| 890 |
\begin{example}[compile,exe-with={--shell-escape},runs=1,float=htbp,caption={A scheme with |
| 891 |
temporary tags replaced with labels.\label{fig:scheme-tmp-tags-replaced}}] |
| 892 |
% code for figure 2 -- compiled with shell-escape enabled |
| 893 |
\documentclass{standalone} |
| 894 |
\usepackage{graphicx,auto-pst-pdf,chemnum} |
| 895 |
\begin{document} |
| 896 |
\replacecmpd{Alc}% replaces TMP1 |
| 897 |
\replacecmpd{EtherBr}% replaces TMP2 |
| 898 |
\includegraphics{scheme-tmp.ps} |
| 899 |
\end{document} |
| 900 |
\end{example} |
| 901 |
|
| 902 |
The replacement is done with the help of the \pkg{psfrag} |
| 903 |
package~\cite{pkg:psfrag} and its \cs{psfrag} command. For details on this |
| 904 |
package and its command I refer to its documentation. |
| 905 |
|
| 906 |
Although the examples don't do it the usage of \cs{replacecmpd} and the |
| 907 |
corresponding graphic file should be placed inside a group (probably a |
| 908 |
\env*{figure} or a \env*{scheme} environment) in order to keep the stepping of |
| 909 |
the tag number local: this allows to use the same tags \code{TMP1}, |
| 910 |
\code{TMP2}, \ldots, in the next figure again. |
| 911 |
|
| 912 |
As you can see the labels are printed sans serif. This setting can of course |
| 913 |
be changed. The complete list of options is this: |
| 914 |
\begin{options} |
| 915 |
\keybool{replace-auto}\Module{general}\Default{true} |
| 916 |
When set to true this adds an incremented integer to the replacement tag. |
| 917 |
\keyval{replace-tag}{text}\Module{general}\Default{TMP} |
| 918 |
The default replacement tag. |
| 919 |
\keyval{replace-tag-nr}{int}\Module{general}\Default{1} |
| 920 |
The\sinceversion{1.1} next number used by \cs{replacecmpd} when the |
| 921 |
default tag is used. |
| 922 |
\keyval{tag}{text}\Module{replace}\Default{TMP\meta{number}} |
| 923 |
The local replacement tag. \meta{number} is incremented by one at each |
| 924 |
use and starts with \code{1}. The starting number can be changed with the |
| 925 |
option \option{replace-tag-nr}. The increment happens locally. |
| 926 |
\keyval{replace-style}{code}\Module{general}\Default{\cs*{sffamily}} |
| 927 |
Additional \TeX\ code that it placed before the \cs{cmpd} command in the |
| 928 |
replacement. |
| 929 |
\keyval{style}{code}\Module{replace}\Default{\cs*{sffamily}} |
| 930 |
Local additional \TeX\ code that it placed before the \cs{cmpd} command in |
| 931 |
the replacement. |
| 932 |
\keychoice{replace-pos}{\marg{\TeX\ pos}\marg{\ac{ps} |
| 933 |
pos}}\Module{general}\Default{bb} |
| 934 |
Options for \pkg{psfrag}'s \cs{psfrag}. |
| 935 |
\keychoice{pos}{\marg{\TeX\ pos}\marg{\ac{ps} |
| 936 |
pos}}\Module{replace}\Default{bb} |
| 937 |
Local options for \pkg{psfrag}'s \cs{psfrag}. |
| 938 |
\end{options} |
| 939 |
|
| 940 |
If you have a scheme with arbitrary tabs like in |
| 941 |
figure~\ref{fig:scheme-bla-tags} you can specify the \option{tag} option to |
| 942 |
\cs{replacecmpd}. Figure~\ref{fig:scheme-bla-tags-replaced} demonstrates |
| 943 |
this. It also demonstrates that you can of course use sublabels in the |
| 944 |
\cs{replacecmpd} command. |
| 945 |
|
| 946 |
\begin{example}[compile,exe-with={--shell-escape},runs=1,float=htbp,caption={A scheme with |
| 947 |
arbitrary tags.\label{fig:scheme-bla-tags}}] |
| 948 |
% code for figure 3 |
| 949 |
\documentclass{standalone} |
| 950 |
\usepackage{graphicx,auto-pst-pdf} |
| 951 |
\begin{document} |
| 952 |
\includegraphics{scheme-bla.ps} |
| 953 |
\end{document} |
| 954 |
\end{example} |
| 955 |
|
| 956 |
If you don't want to use \code{TMP\meta{number}} as temporary tags but for |
| 957 |
example \code{temp\meta{number}} you can change this with following option: |
| 958 |
\begin{sourcecode} |
| 959 |
\setchemnum{replace-tag=temp} |
| 960 |
\end{sourcecode} |
| 961 |
|
| 962 |
The options \option{pos} and \option{replace-pos} refer to \cs{psfrag}'s |
| 963 |
optional arguments which determine the positioning of the \TeX\ box with |
| 964 |
respect to the \ac{ps} box that is replaced. This is described in |
| 965 |
\pkg{psfrag}'s documentation. |
| 966 |
|
| 967 |
\begin{example}[compile,exe-with={--shell-escape},runs=1,float=htbp,caption={A scheme with |
| 968 |
arbitrary tags replaced with labels.\label{fig:scheme-bla-tags-replaced}}] |
| 969 |
% code for figure 4 -- compiled with shell-escape enabled |
| 970 |
\documentclass{standalone} |
| 971 |
\usepackage{graphicx,auto-pst-pdf,chemnum} |
| 972 |
\begin{document} |
| 973 |
\setchemnum{replace-style=\itshape} |
| 974 |
\replacecmpd[tag=blah]{main}% replaces blah |
| 975 |
\replacecmpd[tag=blub]{main.sub}% replaces blub |
| 976 |
\includegraphics{scheme-bla.ps} |
| 977 |
\end{document} |
| 978 |
\end{example} |
| 979 |
|
| 980 |
\section{Changing the Input Markers}\label{sec:chang-input-mark} |
| 981 |
|
| 982 |
In \chemnum's labels there are two markers (or three, actually) that can't be |
| 983 |
part of a label name: the comma \code{,} and the dot \code{.}. You can change |
| 984 |
them with options: |
| 985 |
|
| 986 |
\begin{options} |
| 987 |
\keyval{list-label-sep}{token}\Module{general}\Default{,} |
| 988 |
The marker that is used to split an input list of main labels. |
| 989 |
\keyval{sub-list-label-sep}{token}\Module{general}\Default{,} |
| 990 |
The marker that is used to split an input list of sublabels. |
| 991 |
\keyval{main-sub-sep}{token}\Module{general}\Default{.} |
| 992 |
The marker that divides sublabels from main labels. |
| 993 |
\end{options} |
| 994 |
|
| 995 |
\begin{example}[side-by-side] |
| 996 |
\setchemnum{ |
| 997 |
main-sub-sep = ! , |
| 998 |
list-label-sep = ; |
| 999 |
} |
| 1000 |
\cmpd{a; b; c; e; g!two} \par |
| 1001 |
\cmpd{q!one,two,three,four,five} |
| 1002 |
\end{example} |
| 1003 |
|
| 1004 |
\section{Language Dependent Settings}\label{sec:lang-depend-sett} |
| 1005 |
|
| 1006 |
A few settings of \chemnum\ depend on the language you chose with |
| 1007 |
\pkg{babel}~\cite{pkg:babel} or \pkg{polyglossia}~\cite{pkg:polyglossia}. |
| 1008 |
Those regard the list separators. The language dependent strings are |
| 1009 |
translated with the help of the \pkg{translations}~\cite{pkg:translations} |
| 1010 |
package. This package provides the means to define translations for strings |
| 1011 |
associated with identification keys. \chemnum\ defines two strings. The |
| 1012 |
available languages and the corresponding translations of the two strings are |
| 1013 |
listed in table~\ref{tab:languages}. Note that both the comma or a leading |
| 1014 |
space as well as a trailing space are part of the translations. To make this |
| 1015 |
obvious the relevant parts of the table are typeset in monotype and spaces are |
| 1016 |
represented by \code{\textvisiblespace}. |
| 1017 |
|
| 1018 |
If you find your language missing or the translation to your language to be |
| 1019 |
wrong please write me an email and I'll add your language or fix the wrong |
| 1020 |
translation. |
| 1021 |
|
| 1022 |
\begin{table}[htbp] |
| 1023 |
\newcommand*\showlanguageentry[1]{% |
| 1024 |
#1 |
| 1025 |
& \visualizespaces{\GetTranslationFor{#1}{chemnum-sep-two}} |
| 1026 |
& \visualizespaces{\GetTranslationFor{#1}{chemnum-sep-last-two}} |
| 1027 |
} |
| 1028 |
\centering |
| 1029 |
\caption{Available languages} |
| 1030 |
\label{tab:languages} |
| 1031 |
\begin{tabular}{l>{\ttfamily}l>{\ttfamily}l} |
| 1032 |
\toprule |
| 1033 |
\bfseries Language & |
| 1034 |
\bfseries chemnum-sep-two & |
| 1035 |
\bfseries chemnum-sep-last-two \\ |
| 1036 |
\midrule |
| 1037 |
\showlanguageentry{English} \\ |
| 1038 |
\showlanguageentry{American} \\ |
| 1039 |
\showlanguageentry{German} \\ |
| 1040 |
\showlanguageentry{French} \\ |
| 1041 |
\showlanguageentry{Spanish} \\ |
| 1042 |
\showlanguageentry{Italian} \\ |
| 1043 |
\showlanguageentry{Catalan} \\ |
| 1044 |
\showlanguageentry{Portuguese} \\ |
| 1045 |
\showlanguageentry{Dutch} \\ |
| 1046 |
\showlanguageentry{Danish} \\ |
| 1047 |
\showlanguageentry{Swedish} \\ |
| 1048 |
\showlanguageentry{Finnish} \\ |
| 1049 |
\showlanguageentry{Norwegian} \\ |
| 1050 |
\bottomrule |
| 1051 |
\end{tabular} |
| 1052 |
\end{table} |
| 1053 |
|
| 1054 |
\section{Debugging Information}\label{sec:debugg-inform} |
| 1055 |
|
| 1056 |
If you want information on the labels you have defined you can exploit the |
| 1057 |
following options: |
| 1058 |
\begin{options} |
| 1059 |
\keychoice{log}{\default{true},false,silent,verbose}\Module{general}\Default{false} |
| 1060 |
Determines how the declaration of the labels will be logged. \code{false} |
| 1061 |
means that no information is written to the \code{.log} file. \code{true} |
| 1062 |
means that basic information is written to the \code{.log} file when a |
| 1063 |
label or a sublabel is declared. \code{silent} is an alias of |
| 1064 |
\code{true}. \code{verbose} means that detailed information is written to |
| 1065 |
the \code{.log} file when a label or a sublabel is declared. |
| 1066 |
\keychoice{show-keys}{\default{true},false,def,ref}\Module{general}\Default{false} |
| 1067 |
This option will write visual hints when a label is defined (choices |
| 1068 |
\code{true} or \code{def}) or when a label is referenced (choices |
| 1069 |
\code{true} or \code{ref}). |
| 1070 |
\end{options} |
| 1071 |
|
| 1072 |
The option \option{log} will write information on a label to the \code{log} |
| 1073 |
file when a label is defined. Depending on the choice (\code{true}, its alias |
| 1074 |
\code{silent}, or \code{verbose}) this will be only the main information or |
| 1075 |
detailed information including label properties. The following code shows an |
| 1076 |
example when \keyis{log}{verbose}: |
| 1077 |
\begin{sourcecode} |
| 1078 |
................................................. |
| 1079 |
. chemnum info: defined new compound: |
| 1080 |
. ID = a |
| 1081 |
. internal number = 1 |
| 1082 |
. label = 1 |
| 1083 |
. pre label code = ( |
| 1084 |
. post label code = ) |
| 1085 |
. post main label code = |
| 1086 |
. format = \bfseries |
| 1087 |
................................................. |
| 1088 |
\end{sourcecode} |
| 1089 |
|
| 1090 |
The \option{show-keys} writes some visual information to the document itself: |
| 1091 |
\begin{example} |
| 1092 |
\setchemnum{show-keys} |
| 1093 |
\cmpd{a} and a bit later \cmpd{b}. |
| 1094 |
\end{example} |
| 1095 |
The last example shows the information when a label is referenced. If a label |
| 1096 |
is newly declared information is written to the margin like for this label |
| 1097 |
with the \ac{id} \code{showkey}: \setchemnum{show-keys}\cmpd{showkey} that |
| 1098 |
again is referencend here: \cmpd{showkey}. |
| 1099 |
|
| 1100 |
The option activates four commands: |
| 1101 |
\begin{commands} |
| 1102 |
\command{cmpdshowdef}[\marg{\ac{id}}] |
| 1103 |
Internal command used to display \meta{\ac{id}} of a newly defined compound |
| 1104 |
label when the option \option{show-keys} is used. The command is |
| 1105 |
described in section~\ref{sec:debugg-inform}. |
| 1106 |
\command{cmpdshowref}[\marg{\ac{id}}] |
| 1107 |
Internal command used to display \meta{\ac{id}} of a referencing compound |
| 1108 |
label when the option \option{show-keys} is used. The command is |
| 1109 |
described in section~\ref{sec:debugg-inform}. |
| 1110 |
\command{subcmpdshowdef}[\marg{main \ac{id}}\marg{sub \ac{id}}] |
| 1111 |
Internal command used to display \meta{main \ac{id}} and \meta{sub |
| 1112 |
\ac{id}} of a newly defined subcompound label when the option |
| 1113 |
\option{show-keys} is used. The command is described in |
| 1114 |
section~\ref{sec:debugg-inform}. |
| 1115 |
\command{subcmpdshowref}[\marg{main \ac{id}}\marg{sub \ac{id}}] |
| 1116 |
Internal command used to display \meta{main \ac{id}} and \meta{sub |
| 1117 |
\ac{id}} of a referencing subcompound label when the option |
| 1118 |
\option{show-keys} is used. The command is described in |
| 1119 |
section~\ref{sec:debugg-inform}. |
| 1120 |
\end{commands} |
| 1121 |
This means you can customize the appearance of the information by redefining |
| 1122 |
those commands. The ones that show the definition use a \cs*{marginpar} in |
| 1123 |
their default definition. This may cause them to disappear if issued |
| 1124 |
somewhere \cs*{marginpar} cannot be used. The following shows an equivalent |
| 1125 |
definition with \cs*{marginnote} from the \pkg{marginnote} |
| 1126 |
package~\cite{pkg:marginnote}. (This definition has another drawback: it |
| 1127 |
several \cs*{marginnote}s can print over one another if issued in the same |
| 1128 |
line.) |
| 1129 |
|
| 1130 |
\begin{example} |
| 1131 |
\renewcommand*\cmpdshowdef[1]{% /needs/ one mandatory argument |
| 1132 |
\marginnote{\fbox{\normalfont\ttfamily#1}}} |
| 1133 |
\renewcommand*\subcmpdshowdef[2]{% /needs/ two mandatory arguments |
| 1134 |
\marginnote{\fbox{\normalfont\ttfamily#2 (#1)}}} |
| 1135 |
a\cmpdshowdef{foo}\par |
| 1136 |
b\cmpdshowref{foo}\par |
| 1137 |
c\subcmpdshowdef{foo}{bar}\par |
| 1138 |
d\subcmpdshowref{foo}{bar} |
| 1139 |
\end{example} |
| 1140 |
|
| 1141 |
Actually there are two other commands you could redefine -- all four of the |
| 1142 |
above commands are defined in terms of them: |
| 1143 |
\begin{sourcecode} |
| 1144 |
\NewDocumentCommand\cmpdshowdef{m}{\chemnumshowdef{#1}} |
| 1145 |
\NewDocumentCommand\cmpdshowref{m}{\chemnumshowref{#1}} |
| 1146 |
\NewDocumentCommand\subcmpdshowdef{mm}{\chemnumshowdef{#2 (#1)}} |
| 1147 |
\NewDocumentCommand\subcmpdshowref{mm}{\chemnumshowref{#2}} |
| 1148 |
\end{sourcecode} |
| 1149 |
|
| 1150 |
\section{From Version~0 to Version~1}\label{sec:news} |
| 1151 |
The \chemnum\ package has been my first attempt to create a comprehensive |
| 1152 |
labeling package for chemical compounds. However, it had and has more than |
| 1153 |
one weakness and its code was -- to be frank -- a mess. Version~1 is now a |
| 1154 |
complete re-write of \chemnum\ where I tried to achieve several points: |
| 1155 |
\begin{itemize} |
| 1156 |
\item A cleaner code internally. |
| 1157 |
\item A cleaner user interface, \ie, more user macros for different tasks, a |
| 1158 |
unified naming of the commands and a less redundant naming of the |
| 1159 |
options. |
| 1160 |
\item Extended functionality such as sorting and compressing of sublabel |
| 1161 |
lists and sorting and merging of main label lists. |
| 1162 |
\end{itemize} |
| 1163 |
|
| 1164 |
Although the syntax seems more or less the same at first sight quite a number |
| 1165 |
of changes have been made that make version~1 incompatible with version~0. |
| 1166 |
While I thought a while about maintaining backwards compatibility version~0 |
| 1167 |
was known to be in an experimental stage where everything was allowed to be |
| 1168 |
changed at any time. So users \emph{could} know there was a risk. I have a |
| 1169 |
feeling that many users nevertheless didn't realize this and may be bothered |
| 1170 |
by this incompatibility. So I am well aware that the update will |
| 1171 |
inconvenience some users. However, since version~0 won't be updated any more |
| 1172 |
it made more sense to make a breaking update once. |
| 1173 |
|
| 1174 |
The same is not true for version~1. The syntax and commands described in this |
| 1175 |
manual will not be changed as easily and from this version on I will take care |
| 1176 |
of backwards compatibility. |
| 1177 |
|
| 1178 |
For those people wanting to keep older versions: they are are still available |
| 1179 |
from websites such as \website{ctanhg.scharrer-online.de} or |
| 1180 |
\securewebsite{bitbucket.org/cgnieder/chemnum}. You can also email me for an |
| 1181 |
older version. |
| 1182 |
|
| 1183 |
Many commands have got a new name! The most important ones are: |
| 1184 |
\begin{itemize} |
| 1185 |
\item \cs*{cmpdref}; this is now called \cs{replacecmpd}. |
| 1186 |
\item \cs*{cmpdinit}; this is now called \cs{initcmpd}. |
| 1187 |
\item \cs*{cmpdreset}; this is now called \cs{resetcmpd}. |
| 1188 |
\item \cs*{cmpdsetup}; this is now called \cs{setchemnum}. |
| 1189 |
\end{itemize} |
| 1190 |
However, there are many more changes. Basically all options have new names |
| 1191 |
and often do their thing slightly different from the way things have been |
| 1192 |
before. |
| 1193 |
|
| 1194 |
Please note that this overall change does not mean that version~1 is version~0 |
| 1195 |
declared stable. It is very likely that version~1 will now have quite a |
| 1196 |
number of bugs to be fixed and probably missing features, too. So I'd be very |
| 1197 |
glad to receive feedback either on \chemnum's homepage |
| 1198 |
\securewebsite{github.com/cgnieder/chemnum} or via email to |
| 1199 |
\email{[email protected]}. |
| 1200 |
|
| 1201 |
\end{document} |