This is a follow-up question to Numbering of compounds in the order it appears in the schemes (bpchem or similar)
I had the same problem of the author of the previous question and I tried the solution proposed by @Werner: it works almost perfectly. Anyway, there is a minor issue I would like to solve (but most of all I would like to understand why it doesn't work as I expect).
Here is my code:
\documentclass{article}
\usepackage[runs=2]{auto-pst-pdf}
\usepackage{bpchem}
\usepackage[tracking=bpchem]{chemstyle}
\usepackage[version=3]{mhchem}
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\LetLtxMacro\oldschemeref\schemeref
\DeclareRobustCommand{\schemeref}[2][]{%
\CNlabelnoref{#2}%
\oldschemeref[#1]{#2}%
}
\begin{document}
\begin{scheme}
\schemeref{comp1}
\schemeref{comp2}
\schemeref{comp3}
\includegraphics{scheme1}
\end{scheme}
Compound number \CNref{comp1}, compound number \CNref{comp2}.
\end{document}
It's almost the same code as the previos question, there is only a difference: the command \schemeref is used here without the optional argument [TMPX]. If I add the optional argument (which I don't need since my schemes have the standard label TMP1, TMP2, ecc...) everything works fine: the output pdf has correct compound numbering in the schemes and correct compound referencing in the test. If I drop the option argument the referencing in the text continues to work fine (the command \CNref is substituted with the number of the corresponding compound) but the labels TMP1, TMP2, ecc... in the schemes are no more substituted with the expected number! They are left as they are, TMP1, TMP2...
I was wondering why the redefinition of \schemeref doesn't handle properly the empty optional argument... No errors or warnings from Latex.
I am a new italian user of StackEschange, so forgive any mistake I made!
Thank you for any help.

\schemeref[TMP1]{comp1}works perfectly while\schemeref{comp1}doesn't? – Rackbox Jul 24 '15 at 20:41\schemeref[TMP1]{comp1}code everything works fine and referencing is ok! Can you provide an example of what you are saying? Thank you! – Rackbox Jul 25 '15 at 08:12#1is blank and if it is use\oldschemerefwithout optional argument, I guess. Otherwise you're probably telling\oldschemerefto replace an empty string instead of the default one… – cgnieder Jul 31 '15 at 15:17