cgnieder / chemnum Goto Github PK
View Code? Open in Web Editor NEWnumbering of chemical compounds with LaTeX2e
numbering of chemical compounds with LaTeX2e
I came across a problem using \cmpd+{}
to substitute sublabels inside a \psfrag
command. Interestingly, this is no problem using \replacecmpd{main.sub}
, however, using \cmpd+{main.sub}
outputs 2 questionmarks as the sublabel.
The whole thing works fine for mainlabels.
\documentclass{article}
\usepackage{graphicx}
\usepackage{auto-pst-pdf}
\usepackage{chemnum}
\begin{document}
Using chiral alcohol \cmpd+{cmpd1.1} to get chiral ether \cmpd+{cmpd1.2}.
\begin{figure}
\centering
\cmpd*{cmpd1.1}
\psfrag{TMP1}[Bc][Bc]{Chiral molecule \cmpd+{cmpd1.1}}
\replacecmpd[tag=TMP2]{cmpd1.2}
\includegraphics[scale=1]{scheme-tmp.ps}
\caption{Working here (\cmpd+{cmpd1.1}), however, not in psfrag. The second one (\cmpd+{cmpd1.2}) is working in both.}
\end{figure}
\end{document}
Would you have an idea why this is happening, or how to solve this?
Is it possible to implement more than one counter? I imagine the use case that I have the standard
counter for all compounds but can access additional counters for labelling compounds in catalytic cycles with roman numbers. That can be referenced and automatically (re-)labelled with chemnum
\documentclass{article}
\usepackage{chemnum}
\ExplSyntaxOn
\NewDocumentCommand \setcmpdlabel {mm}
{ \chemnum_compound_set_property:nnn {#1} {counter-representation} {#2} }
\ExplSyntaxOff
\newcommand*\defineEZcmpds[1]{%
\cmpd*{#1}\cmpd*{E#1}\cmpd*{Z#1}%
\setcmpdlabel{E#1}{\textit{E}-\cmpd{#1}}%
\setcmpdlabel{Z#1}{\textit{Z}-\cmpd{#1}}%
}
\begin{document}
% defining
\defineEZcmpds{azobenzene}
% and using
Compounds \cmpd{Eazobenzene} and \cmpd{Zazobenzene} are the two photoisomers
of \cmpd{azobenzene}.
\end{document}
Transparency notice: The problem was already described here.
I'm using the \setcmpdlabel
approach (initially proposed by the package author here) to generate custom labels of compounds. This works fine for me with one notable exception: I can't find a proper way to represent the custom labels within PDF bookmarks.
% arara: pdflatex
\documentclass{article}
\usepackage{chemnum}
\usepackage{chemformula}
\usepackage{hyperref}
\ExplSyntaxOn
\NewDocumentCommand \setcmpdlabel {mm}
{ \chemnum_compound_set_property:nnn {#1} {counter-representation} {#2} }
\ExplSyntaxOff
\cmpd*{Me2bdc}
\setcmpdlabel{Me2bdc}{\ch{Me2L^1}}
\cmpd*{H2bdc}
\setcmpdlabel{H2bdc}{\ch{H2L^1}}
\begin{document}
\section{About \texorpdfstring{\cmpd{Me2bdc}}{\cmpdplain{Me2bdc}}}
Lorem ipsum.
\section{About \texorpdfstring{\cmpd{H2bdc}}{\cmpdplain{H2bdc}}}
Lorem ipsum.
\end{document}
will produce:
The section titles will be numerical and not represent the user-defined compound label. Also tried to use \cmpdproperty{H2bdc}{counter-representation}
, unfortunately no success. Help is greatly appreciated! Thanks.
If a normal cmpd label is missing, two questionmarks are placed in the document, if a sublabel is missing, there is no indication.
MWE
\documentclass{report}
\usepackage{chemnum}
\begin{document}
Compound \cmpd{nicecmpd} had a nice color. Compound \cmpd+{2} has not been defined and I see two questionmarks, however, I'm not informed that the subcompound \cmpd+{nicecmpd.derivate1} does not exist. It could for example output "\cmpd+{nicecmpd}??".
\end{document}
I think it would be a nice enhancement to alter the output if a sublabel is missing.
The manual states:
Since the sublist is input with a comma in the default setting you have to put them into braces.
If you add a list of sublabels to a main label they will always be printed in the order the sublabels
have been declared and not in the order they’re input in the list:
But, the example in the manual (screenshot above) does print the labels in input order:
10a,b,c,d,e
vs10e,d,c,b,a
vs10c,d,a,e,b
Compilation of my documents shows the same behavior.
I would be very grateful for a fix!
\submaincmpdplain
and \subcmpdplain
are not working correctly, if sublables have been initiated with \initcmpd
:
MWE:
\documentclass{article}
\usepackage{chemnum}
\initcmpd{%
cmpd.{aa,bb},
cmpd.cc,
}
\begin{document}
\cmpd{cmpd.aa}, \submaincmpdplain{cmpd}{aa}.
\cmpd{cmpd.bb}, \submaincmpdplain{cmpd}{bb}.
\cmpd{cmpd.cc}, \submaincmpdplain{cmpd}{cc}.
\cmpd{cmpd.dd}, \submaincmpdplain{cmpd}{dd}.
\cmpd{cmpd.ee}, \submaincmpdplain{cmpd}{ee}.
\cmpd{cmpd.ff}, \submaincmpdplain{cmpd}{ff}.
\end{document}
Uncomment either line to prevent the document from compiling and reproduce the bug.
\documentclass{article}
\usepackage{chemmacros}
\chemsetup{formula=chemformula}
\usepackage[]{chemnum}
\begin{document}
\cmpd{a}
\cmpd{a.one}
\refcmpd{a}
\ch{\cmpd{a} -> c}
\ch{\refcmpd{a} -> c}
\refcmpd{a.one}
%\ch{\refcmpd{a.one} -> c} %If you uncomment this it stops compiling.
%\ch{\cmpd{a.one} -> c} %If you uncomment this it stops compiling.
\end{document}
Global formatting is not correctly applied when other options are set in \replacecmpd
, cf. https://tex.stackexchange.com/q/579784/
Recently I came across a paper (https://doi.org/10.1021/jacs.5b05593) which used subcounters in an interesting way: p and a were reserved for parallel and antiparallel ion pairs respectively, so compounds were numbered 1p, 1a, 2p, 2a and so forth. This seems like a reasonable feature to support, yet chemnum currently cannot support it. This is especially surprising as chemnum already lets us perform similar manipulations with main counters using \setcmpdlabel
. Would it be possible to add an analogous command for subcounters?
Is there a (wanted) reason why the sub-only
option does not work with the +
variant of \cmpd{...}
?
\documentclass{article}
\usepackage{graphicx}
\usepackage{chemnum}
\begin{document}
\cmpd*{main.sub} \cmpd[sub-only]{main.sub} \cmpd+[sub-only]{main.sub}
\end{document}
This code gives unexpectedly the main- and the sublabel for \cmpd+[sub-only]{main.sub}
.
It seems that it is an issue that has been discussed, but did not find any workaround and is supposed to compatible. When I load the hyperref
package, my code fails to compile with a Ghostscript error (in the line of Error: /typecheck in --div--; GPL Ghostscript 9.56.1: Unrecoverable error, exit code 1
). Without hyperref, no problem at all, everything works as expected. I have tried loading hyperref after, but it fails.
My MWE:
\documentclass{memoir}
% To insert eps files in straight with pdflatex
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[crop=off]{auto-pst-pdf}
% For auto numbering of compounds in Chemdraws and in the text
\usepackage{chemnum}
\begin{document}
\replacecmpd[tag=dcppPt]{dcppPt}
\replacecmpd[tag=dcppPt_CO2]{dcppPt_CO2}
\includegraphics{figures/schemes/test.eps}
\end{document}
I am using TexLive 2022, fully updated.
Thanks!
\documentclass{article}
\usepackage{chemnum}
\begin{document}
\cmpd{peroxo.meoh} \cmpd{peroxo.etoh} \cmpd{peroxo.ppn} \refcmpd{peroxo.{meoh,etoh,ppn}}
\end{document}
Gives the following error:
! Missing number, treated as zero.
<to be read again>
\__int_eval_end:
l.4 ...eroxo.ppn} \refcmpd{peroxo.{meoh,etoh,ppn}}
However, if you hit r, then run pdflatex again, it compiles fine.
minimal example:
\documentclass{article}
\usepackage{chemnum}
\begin{document}
\cmpd+{a.{a,b,c}}
\cmpd{a.{a,b,c}}
\end{document}
In the first sentence of chapter 9 of the English manual chemnum_en.pdf, it says rection instead of reaction.
As I posted on tex.stackexchange I would like to see the label keys I replaced in .eps figures using the \replacecmpd
command. If I use show-keys=true
it crashes the compilation, if I user show-keys=ref
it shows the newly defined keys in the figure, not the referenced ones actually. Also I have to use \replacecmpd+
for earlier defined labels, otherwise it gives the error: "Bad space factor (0)"
I saw that for newly defined labels the key is being put into the margin, maybe that is part of the problem? Just a guess from my side.
The eps is still in my dropbox, is there a way to put it here directly? (I am new to github and did manage to create a repository with tex and eps file, but have no idea how to link it here :D )
the code is as follows:
\documentclass[english,
10pt,
]{scrreprt}
\usepackage{chemmacros}
\usechemmodule{
spectroscopy,
scheme,
nomenclature,
mechanisms,
isotopes,
}
\setchemnum{
replace-tag={X},%X<#> used as template tag, better visualization in chemdraw file than TMP<#>
show-keys=ref,
}
\usepackage[runs=2]{auto-pst-pdf}
\begin{document}
Here the numbers are defined: \cmpd{Garner_02} and \cmpd{Garner_04}
\begin{scheme}[htb]
\centering
\replacecmpd{Boc-ser-OMe}
\replacecmpd+{Garner_02}
\replacecmpd+{Garner_04}
\replacecmpd{Garner_22}
\includegraphics[scale=0.7]{garner_rxn}
\caption{Synthesis of Garner's aldehyde~\cmpd+{Garner_04} and the corresponding Weinrebamide~\cmpd+{Garner_22}.}
\end{scheme}
Here they are referenced: \cmpd{Garner_02} and \cmpd{Garner_04}
\end{document}
I want to reference compounds, say 1-5, at the same time. Using \cmpd{1,2,3,4,5}
only results in the output 1, 2, 3, 4, and 5
because compress
and merge
only work with sublabels. Is there any workaround or brute force compress for main level labels?
There are cases where it might be very desirable to set the label-format
compound-wise on declaration of the respective compound. This question was discussed here previously. It was suggested to use grouping in order to restrict \bfseries\textsuperscript
to apply to only few of the compounds used within the document.
The example
\documentclass{article}
\usepackage{chemnum}
\usepackage{auto-pst-pdf}
\begin{document}
\begingroup
\setchemnum{format=\bfseries\textsuperscript}
\cmpd*[pre-label-code=\textbf{H\textsubscript{2}L}]{H2bdc}
\resetcmpd
\cmpd*[pre-label-code=\textbf{Me\textsubscript{2}L}]{Me2bdc}
\endgroup
\cmpd*{benzene}
\noindent This is about compounds \cmpd{H2bdc} and \cmpd{Me2bdc}.\\
Compound \cmpd{benzene} should not be typeset fancy
\begin{figure}[h]
\replacecmpd[tag=H2bdc]{H2bdc}
\replacecmpd[tag=Me2bdc]{Me2bdc}
\replacecmpd[tag=benzene]{benzene}
\includegraphics{./mwe.eps}
\end{figure}
\end{document}
will produce on calling pdflatex --shell-escape mwe.tex
:
While the rendering of compounds H2bdc
, Me2bdc
, and benzene
looks fine within text, the replacement within the eps file does not follow the desired style.
The eps example file was added to a zip archive and is available here: mwe.zip
chemnum requires a spesific version of expl3 from l3kernel, that is not available through CTAN.
Running MiKTeX 2.9, and updating with the built in tool I only get version 2013/03/14 of expl3.
Error message from console:
pdflatex.exe> LaTeX Warning: You have requested, on input line 6, version
pdflatex.exe> '2013/07/14' of package expl3,
pdflatex.exe> but only version
pdflatex.exe> '2013/03/14' v4469 L3 Experimental code bundle wrapper'
pdflatex.exe> is available.
...
pdflatex.exe> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
pdflatex.exe> !
pdflatex.exe> ! LaTeX error: "kernel/property-unknown"
pdflatex.exe> !
pdflatex.exe> ! The key property '.groups:n' is unknown.
pdflatex.exe> !
pdflatex.exe> ! See the LaTeX3 documentation for further information.
pdflatex.exe> !
pdflatex.exe> ! For immediate help type H .
pdflatex.exe> !...............................................
pdflatex.exe>
pdflatex.exe> l.450 }
Using chemnum 1.2c, I'm not able to globally alter the label-format
key. The example
\documentclass{article}
\usepackage{chemnum}
\begin{document}
\cmpd*[label-format=\bfseries\textsuperscript,pre-label-code=\textbf{Me\textsubscript{2}L}]{Me2bdc}
\cmpd{Me2bdc}
\end{document}
will produce
where the compound label 1 should be typeset in \textsuperscript
, I guess.
I've reported this issue on StackExchange including a (slightly extended) example before: https://tex.stackexchange.com/questions/527398/chemnum-label-format-not-affecting-cmpd-definition-globally
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.