Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to write section numbers to a file with the newfile package. In details, this MWE basically tries to write to a .ref file with lines like A-B. The A and B are generated by \label and \ref commands: if \ref{A} is written in section 2 and \label{A} is defined in section 1, then we should write 2|1 in the file.

This example actually fails to expand the \ref command, probably due to the insertion of the hyperref package, which makes \ref robust. How can one avoid this?




%% Write SRC-DST of \ref to file

%% Redefine \autoref







The current content of the .ref file is

1|\ref {sec:three}
2|\ref {sec:one}
3|\ref {sec:two}

but I would like the expansion of the \ref to give:

share|improve this question
Check the answer here: tex.stackexchange.com/questions/85956/… –  g.kov Mar 22 '13 at 13:48
I already tried to make it works with this answer, but I did not succeed. I get commands \TheRealRef that are not expanded in the output file. –  wwjoze Mar 22 '13 at 16:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.