# How to access the value of a biblatex package option/key

Is it possible to access a value which is given as a bibliography option. For example if I have

\usepackage[somekey=foobar]{biblatex}


can I get the value (foobar) of somekey as a macro like \KV@<family>@somekey. I tried to find it out and had a look at biblatex.sty there i found the \define@key macro which is from keyval.sty as I know now. My search ended with the macro \KV@blx@opt@pre@autocite{#1} with which I could change the value but not get it.

As you can guess I’d like to get the value of the autocite option.

## Update

Maybe Joseph is right, so here is want I want: I want to be able to change the behavior of a macro according to the autocite option. The macro is \quodecite (see biblatex: Handling secondary ("quoted in") citations) an since this is defined via \DeclareMultiCiteCommand I can’t use \DeclareAutoCiteCommand I guess. I could have asked Audrex this in the other question but I thought that I can solve it myself which leads to the question if I can access a key value …

## Update 2

At biblatex: Handling secondary ("quoted in") citations Audrey suggested to build a extra command for the other autocite options, but I’d like to have an automatic solution.

This is the a part code to create the \quotecite command:

\DeclareMultiCiteCommand{\quotecite}[\cbx@qcwrapper]{\cbx@quotecite}{\cbx@qcdelim}

\newrobustcmd{\cbx@qcwrapper}[1]{%
\global\toggletrue{cbx@isquote}%
\mkbibfootnote{#1}%
\global\togglefalse{cbx@isquote}%
\global\togglefalse{cbx@iflastibid}%
\global\togglefalse{cbx@ifquoteepost}%
\global\togglefalse{cbx@ifquoterpost}}


As on can imagine—and my tests proofed that—the output format (plain, footnote, …) of \quotecite could easily be change by replacing \mkbibfootnote{#1} by \mkbibparens{#1} for example. So my idea is to implement a conditional that takes care about the value of autocite and for that I need the value of the option.
Something like the following but in real LaTeX certainly would solve the problem I guess.

\newrobustcmd{\cbx@qcwrapper}[1]{%
\global\toggletrue{cbx@isquote}%
if (autocite=footnote)
\mkbibfootnote{#1}%
else if (autocite=parens)
\mkbibparens{#1}
else if (autocite=plain)
#1
else
#1
warning: unkown option of autocite for \quotecite
end if
end if
end if
\global\togglefalse{cbx@isquote}%
\global\togglefalse{cbx@iflastibid}%
\global\togglefalse{cbx@ifquoteepost}%
\global\togglefalse{cbx@ifquoterpost}}

• There is no guarantee that any particular option will store its value. More generally, you are trying to access the internals of a package, and one which is well-written enough to make this unnecessary in most cases. Perhaps you might explain the wider context of the request. – Joseph Wright Sep 11 '11 at 20:50
• Not quite what I meant... \quotecite is tailored for verbose-ibid. verbose-ibid, like all the verbose styles, is intended for footnote citations. So I'm not sure why anyone would use anything other than autocite=footnote. Inline versions of \quotecite (regardless of autocite) might come in handy. My quibbling aside, I think the general question is still useful. – Audrey Sep 12 '11 at 1:29
• @Joseph: For the moment I’m going to provide an extra command for inline citing but as Audrey said the question is still interesting. – Tobi Sep 12 '11 at 15:15

The \autocite command depends on the autocite option setting and various citation commands. The latter is determined (in part) by the citestyle option. In biblatex.sty you can see how these options are handled. The value for citestyle is stored explicitly:

\define@key{blx@opt@ldt}{citestyle}{%
\def\blx@cbxfile{#1}}


But the value for autocite isn't; it is instead used to identify a control sequence name using some commands from the biblatex and etoolbox packages.

\DeclareBibliographyOption{autocite}{%
\ifcsundef{blx@acite@#1}
{\blx@error
{Autocite command '#1' undefined}
{The autocite command '#1' has not been defined by
the\MessageBreak selected citation style}}
{\letcs\autocite{blx@acite@#1}%
\letcs\autocites{blx@macite@#1}}}


The control sequences blx@acite@plain, blx@macite@plain, blx@acite@inline, etc. are defined in biblatex.def by:

\DeclareAutoCiteCommand{plain}{\cite}{\cites}
\DeclareAutoCiteCommand{inline}{\parencite}{\parencites}
\DeclareAutoCiteCommand{footnote}[f]{\smartcite}{\smartcites}
\DeclareAutoCiteCommand{superscript}[l]{\supercite}{\supercites}


Below is a very simple example of how you could create a format that depends on the autocite and citestyle options. It uses some commands from etoolbox and is constructed assuming the above generic definitions. These can later be redefined and expanded with further use of \DeclareAutoCiteCommand. So the test here isn't particularly comprehensive or robust to changes in the citation style.

\documentclass{article}
\usepackage[style=authoryear,autocite=footnote]{biblatex}
\bibliography{biblatex-examples}

\makeatletter
\newrobustcmd{\mkbibautoformat}[1]{%
\cslet{cbx@autocite}{\autocite}%
\ifcsequal{cbx@autocite}{blx@acite@inline}
{\ifboolexpr{ test {\ifdefstring{\blx@bbxfile}{numeric}}
or test {\ifdefstring{\blx@bbxfile}{alphabetic}} }
{\mkbibbrackets{#1}}
{\mkbibparens{#1}}}
{\ifcsequal{cbx@autocite}{blx@acite@footnote}
{\iffootnote
{\ifboolexpr{ test {\ifdefstring{\blx@bbxfile}{numeric}}
or test {\ifdefstring{\blx@bbxfile}{alphabetic}} }
{\mkbibbrackets{#1}}
{\mkbibparens{#1}}}
{\mkbibfootnote{#1}}}
{\ifcsequal{cbx@autocite}{blx@acite@superscript}
{\mkbibsuperscript{#1}}
{#1}}}}
\makeatother

\DeclareCiteCommand{\autociteyear}[\mkbibautoformat]
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printfield{year}}
{\multicitedelim}
{\usebibmacro{postnote}}

\begin{document}
\null\vfill
\footnote{\autociteyear{companion}\autocite{companion}}
\end{document}