Note that this question concerns memoize version 1.1.2 (2024-01-21) and, perhaps, later.
memoize version 1.1.2 provides built-in support for automatic handling of \cite and \cites in memoized code when using Biblatex. I'm trying to use this to support a broader range of Biblatex citation macros.
So far I've got many such macros working using the built-in cite and cites styles. For example, his supports \autocite
auto=\autocite{cite},
I've got a few more at partially working by defining a cite field style which uses a custom outer handler.
auto/cite field/.style={run if memoizing, args=oomom, outer handler=\mmz@auto@citefield},
For example,
auto csname={citefield}{cite field},
auto csname={citelist}{cite field},
auto csname={citename}{cite field},
with outer handler
\NewDocumentCommand \mmz@auto@citefield { O{} O{} m O{} m}
{% purloined from memoize.sty & mangled
\xtoksapp\mmzCCMemo{%
\noexpand\nocite{#3}%
}%
\AdviceOriginal[#1][#2]{#3}[#4]{#5}%
}
However, the context-sensitivity doesn't work correctly so I need
auto csname={abx@missing}{abort},
and nothing is auto-regenerated if, say, the output of the citation command changes.
What would be the best way to define \mmz@auto@citefield?
MWE:
\documentclass{article}
\usepackage{memoize}
\usepackage{biblatex}
\bibliography{biblatex-examples}
\usepackage{tikz}
\makeatletter
\mmzset{%
prefix=memos/,
begindocument/before/.append style={%
auto=\autocite{cite},
auto csname={abx@missing}{abort},
auto/cite field/.style={run if memoizing, args=oomom, outer handler=\mmz@auto@citefield},
auto csname={citefield}{cite field},
auto csname={citelist}{cite field},
auto csname={citename}{cite field},
},
}
\NewDocumentCommand \mmz@auto@citefield { O{} O{} m O{} m}
{% purloined from memoize.sty & mangled
\xtoksapp\mmzCCMemo{%
\noexpand\nocite{#3}%
}%
\AdviceOriginal[#1][#2]{#3}[#4]{#5}%
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node [draw] {\autocite{westfahl:space}};
\end{tikzpicture}
\begin{tikzpicture}
\node [draw] {\citefield{westfahl:space}{booktitle}};
\end{tikzpicture}
\begin{tikzpicture}
\node [draw] {\citename{westfahl:space}{author}};
\end{tikzpicture}
\begin{tikzpicture}
\node [draw] {\citelist{westfahl:space}{location}};
\end{tikzpicture}
\printbibliography
\end{document}
externalize: more automated, more robust, faster, more secure and the author has not abandoned it. (Not that I know of, anyway.) – cfr Feb 18 '24 at 07:11