I would like to write the result of "\cite{xyz}" to a file. The following MWE gives me
Forbidden control sequence found while scanning text of \write.
So I do not know how to do it.
\documentclass{article}
\begin{document}
\cite{Ab,Cd}
\newwrite\tempfile
\immediate\openout\tempfile=tmpfil.txt
\immediate\write\tempfile{2015} % this works fine
\immediate\write\tempfile{\cite{Cd}}
\immediate\closeout\tempfile
\begin{thebibliography}{1}
\bibitem{Ab} Author, title, 2016.
\bibitem{Cd} Common, Second, 2015.
\end{thebibliography}
\end{document}
The solution writes "\cite{Cd}" in the file.
I want "[2]" in the file instead.
– user117994 Nov 05 '16 at 13:40