I was wondering how some commands manage to take #1
as an argument when used, not when declared.
For instance, biblatex's \DeclareFieldFormat
can be used like this:
\DeclareFieldFormat {postnote} {#1}
I have taken a look at biblatex1.sty
(lines 3480--3506, v2.3, revison 28161) but couldn't figure out how it can do that. Where is the trick?
This is what I want to achieve:
\foo {bar} {\textbf{#1}}
I want it to typeset bar in bold face; that is, to typeset whatever is given in the first argument in whatever format is given in the second one.
From biblatex1.sty
:
%---CUT---
\newrobustcmd*{\DeclareFieldFormat}{%
\@ifstar
{\blx@defformat\blx@defplainformat{ffd}*}
{\blx@defformat\blx@defplainformat{ffd}{}}}
%---CUT---
% {<macro>}{<class>}{<*>}
\def\blx@defformat#1#2#3{%
\@ifnextchar[%]
{\blx@defformat@i{#1}{#2}{#3}}
{\blx@defformat@i{#1}{#2}{#3}[*]}}
% {<macro>}{<class>}{<*>}[<entrytype>]{<name>}
\def\blx@defformat@i#1#2#3[#4]#5{%
\notblank{#3}
{\blx@resetformat{#2}{#5}}
{}%
\def\blx@defformat@a{#2}%
\def\blx@defformat@b{#4}%
\blx@xsanitizeafter{\def\blx@defformat@c}{#5}%
\afterassignment\blx@defformat@ii
#1}
%---CUT---
biblatex
tag: the issue is noting to do withbiblatex
.