TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

(Part 1)

I'm trying to extract values or parameters from a predefined command to use in another command. Is this possible?

I'll add an example to clarify:

                \rfoot{\pbox{5cm}{\hyperlink{document.toc}{$\leftarrow$ Naar inhoudsopgave} \\ \hyperlink{appendix.a}{$\leftarrow$ Naar \textbf{\textcolor{blue}{R}} commando's} \\ \hyperlink{appendix.b}{$\leftarrow$ Naar begrippenlijst }}}%

Imagine I could extract say, rfoot value for reuse in another command?

(Part 2)

Is there any way to automate this over a range of commands, to only pick the very last declared object? (When choosing where to extract the value from)

share|improve this question
Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Henri Menke Apr 28 '14 at 8:30
fancyhdr stores the rfoot values in \f@ncyerf and \f@ncyorf. – Henri Menke Apr 28 '14 at 8:33
I didn't include an MWE because this question was not related to any specific packages or functionality thereof. How do I call these values back and how far do they go back? – 1010011010 Apr 28 '14 at 8:35
@Euryris there is no general mechanism, it relies on each command to have stored (or not) its arguments in internal macros. If you go \newcommand\foo[1]{....#1___} then when executing ...` tex has no record that it is in the expansion of \foo TeX is a macro expansion language, it just works by textual substitution of the tokens, there is no call stack. – David Carlisle Apr 28 '14 at 8:39
up vote 7 down vote accepted

For part 1 of your question, I looked up, which macros are used to store values in fancyhdr.sty. It reveals, that the content of \rfoot is stored in \f@ncyerf and \f@ncyorf.

\rfoot{Hello footer}
The \texttt{\string\rfoot} contains: \f@ncyorf

enter image description here

share|improve this answer

Save the needed value in an own macro:

\rfoot{Hello footer}

The \texttt{\textbackslash rfoot} contains: \LastRfoot
\rfoot{My new footer}
The \texttt{\textbackslash rfoot} contains: \LastRfoot
share|improve this answer
I guess this fails, if \rfoot was defined as \outer\def\rfoot. – Henri Menke Apr 29 '14 at 12:47

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.