# Convert .tex to .tex, but replace \ref{} with actual numbers

I use Pandoc a lot to go between .tex, .markdown, and .docx. Everything works well enough for me in the .tex to .docx conversion, but the table and section references show \ref{my_label} rather than the actual table or section number.

Is there a way to convert a .tex file with labels and references to a .tex file with all of those replaced?

Say my MWE is this.

\documentclass{article}

\begin{document}
\section{One} \label{sec:one}

I need to right some more in Section \ref{sec:one}.

\end{document}


Can I turn it into this?

\documentclass{article}

\begin{document}
\section{One} \label{sec:one}

I need to right some more in Section 1.

\end{document}

• Yo can do it manually but it is not recommended at all, you loose automation and increase the risk of mistakes. Perhaps the only thing you need is to compile a couple of times more the .tex file to get a pdf with references listed correctly. – Aradnix Aug 14 '14 at 19:28
• This is like 'I want to shoot myself into my foot', since at that point you will change your *.tex document, e.g. adding a section, an equation etc. all references change. – user31729 Aug 14 '14 at 19:48
• I agree this is an odd request. But this is easier than converting some people to LaTeX (usually impossible) and would allow me to generate a .docx that other could edit. If it can't be done, then it can't be done. – Richard Herron Aug 14 '14 at 20:14
• You might take a look at latex2rtf instead of Pandoc. I'm not sure of the full list of things you need support for, but I just used latex2rtf on a small test file and it does write the cross-references correctly. – Paul Gessler Aug 14 '14 at 20:50
• @PaulGessler -- Thanks. I've used latex2rtf before. In general I prefer Pandoc, but latex2rtf may be my best option for this. Thanks. – Richard Herron Aug 14 '14 at 21:42