I'm using ltxtable to use flexible width, tabularx, X columns in a long-table. I'm also using the chemschemex/fancylabel package to give me sweet sweet automatic numbering of my chemical structures.
However, if I include a table containing \fancylabel[<family>]{label} commands via the \LTXtable{<width>}{<file>} method the counter for the fancylabels doesn't increment. And so, all labels end up with the same number.
Including the same table, just with the X columns substituted for l columns, directly in the document or via an \input{} command gives the correct sequential numbering.
None of the inclusion method effects the numbering throughout the document, only that of the table. The table also recognises previously numbered structures and assigns the correct number to them, but then for the next structure fails to change the counter.
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{chemmacros}
\chemsetup{modules = nomenclature}
\let\etoolboxforlistloop\forlistloop % save the good meaning of \forlistloop
\usepackage{chemschemex}
\let\forlistloop\etoolboxforlistloop % restore the good meaning of \forlistloop
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{ltxtable}
\usepackage{collcell}
\usepackage{afterpage}
\begin{filecontents}{table.tex}
\begin{ThreePartTable}
\begin{TableNotes}
\item [a] A note.
\end{TableNotes}
\begin{longtable}[c]{%
@{}%
>{\bfseries}l<{}%
>{\collectcell\iupac}X<{\endcollectcell}% This is the column with the tabularx `X` column when using ltxtable
S%
@{}%
}
\caption{Caption!}\\
\multicolumn{2}{@{}l}{\textbf{Molecule}} & {\pKa}\\
\endfirsthead
\insertTableNotes
\endlastfoot
\multicolumn{2}{@{}l}{\emph{Pyridines}} \\
\fancylabel[CSX]{pyr} & pyridine & 5.23 \\
\fancylabel[CSX]{2me-pyr} & 2-methylpyridine & 5.97 \\
\multicolumn{2}{@{}l}{\emph{Diazines}} \\
\fancylabel[CSX]{pdz} & pyridazine & 2.24\tnote{a} \\
\multicolumn{2}{@{}l}{\emph{Phenols}} \\
\fancylabel[CSX]{phe} & phenol & 9.99 \\
\fancylabel[CSX]{23me-phe} & 2,3-dimethylphenol & 10.50 \\
\end{longtable}
\end{ThreePartTable}
\end{filecontents}
\begin{document}
This is a label: \fancylabel[CSX]{phe}\\
This is an image using chemschemex: \struct[text]{pyr}\\
This is the referenced number for pyridine: \structref{pyr}\\
% No sweet automatic numbering, but at least I get `X` columns.
\afterpage{\clearpage%
\LTXtable{\linewidth}{table.tex}
}
% Sweet sweet automatic numbering, but no lovely `X` columns.
% \afterpage{\clearpage%
% \begin{ThreePartTable}
% \begin{TableNotes}
% \item [a] A note.
% \end{TableNotes}
% \begin{longtable}[c]{%
% @{}%
% >{\bfseries}l<{}%
% >{\collectcell\iupac}l<{\endcollectcell}% This is the column with the tabularx `X` column when using ltxtable
% S%
% @{}%
% }
% \caption{Caption!}\\
% \multicolumn{2}{@{}l}{\textbf{Molecule}} & {\pKa}\\
% \endfirsthead
%
% \insertTableNotes
% \endlastfoot
%
% \multicolumn{2}{@{}l}{\emph{Pyridines}} \\
% \fancylabel[CSX]{pyr} & pyridine & 5.23 \\
% \fancylabel[CSX]{2me-pyr} & 2-methylpyridine & 5.97 \\
% \multicolumn{2}{@{}l}{\emph{Diazines}} \\
% \fancylabel[CSX]{pdz} & pyridazine & 2.24\tnote{a} \\
% \multicolumn{2}{@{}l}{\emph{Phenols}} \\
% \fancylabel[CSX]{phe} & phenol & 9.99 \\
% \fancylabel[CSX]{23me-phe} & 2,3-dimethylphenol & 10.50 \\
% \end{longtable}
% \end{ThreePartTable}
% }
\end{document}
Ideally I'd like to keep the autonumbering of my compounds. There are a few... If I have to remove a feature to get this to work it'll be the X columns. I'll replace the X column with a p{} column. I can determine the width of the p column with a prelininary run through where I include my tables with the \LTXtable{<width>}{<file>} command, get the width from thw .aux file, and then just use an \input command. I'd just rather not have to do this manually for a large document, with potentially many tables.
Aside
I know of the conflict between etoolbox and etextools (and so autonum and fancylabel) and have implemented the fix here. While the MWE doesn't include biblatex my full document does. I've tested the MWE with and without the fix and it makes no difference.



chemnumpackage? – cgnieder Sep 10 '17 at 12:25chemnum, but to be honest I hadn't seen how in-depth it went for numbering. I chosechemschemexrather thanchemnum,chemscheme, etc. as I wanted to do the auto-numbering in the schemes. All my previous attempts withchemnumetc. and theps-fragapproach failed (I'm using LuaLaTex and fontspec). So, I chosechemschemexto try making my schemes. It typesets figures and the numbers with tikz in matrices for auto-numbering and alignment (nopsfrag). The reason I'mfancylabelis because it was written as the slave label package forchemschemex. – tmgriffiths Sep 12 '17 at 02:37fancylabel. If I could re-writechemschemexto use chemnum instead I would do that. That in itself seems fairly simple as I'd just need to replace the fancyref calls inchemeschemex. What is more difficult is thatchemeschemexuses somefancyrefinternal macros to sort and parse comma-seperated sublabels. Unfortunately I don't know the expl3 syntax, and that'll be where I get stuck, I suspect. I'll read the chemnum documentation to see how I go. – tmgriffiths Sep 12 '17 at 02:38chemfiginstead. With awesome PSfrag replacement. (Provided I used version 15 or earlier of ChemDraw for OSX). I can use included images withchemfig, I had though you had to code your structures if you usedchemfig. It's amazing what you learn when you read the documentation... – tmgriffiths Oct 12 '17 at 02:58