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.

(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:

\fancypagestyle{c.appendix.sep}{
                \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 }}}%
                \lfoot{\currentsection}
                \lhead{}
                \fancyhead[C]{}
}

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 at 8:30
    
fancyhdr stores the rfoot values in \f@ncyerf and \f@ncyorf. –  Henri Menke Apr 28 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 at 8:35
2  
@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 at 8:39
add comment

2 Answers 2

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.

\documentclass{article}
\usepackage{fancyhdr}
\rfoot{Hello footer}
\pagestyle{fancy}
\begin{document}
\makeatletter
The \texttt{\string\rfoot} contains: \f@ncyorf
\makeatother
\end{document}

enter image description here

share|improve this answer
add comment

Save the needed value in an own macro:

\documentclass{article}
\usepackage[a6paper]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\let\Rfoot\rfoot
\renewcommand\rfoot[1]{\def\LastRfoot{#1}\Rfoot{#1}}
\rfoot{Hello footer}

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

Your Answer

 
discard

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.