biblatex icon indicating copy to clipboard operation
biblatex copied to clipboard

Allow user to evaluate ExecuteBibliographyOptions in DeclareCiteCommand

Open tobiasBora opened this issue 4 years ago • 2 comments

I'm trying to redefine fullcite to include doi, giveninits=false... Unfortunately, I can't use \ExecuteBibliographyOptions{style=trad-alpha,doi=false,giveninits=false} inside \DeclareCiteCommand, and I'm forced to dig into the source and type things like \settoggle{abx@bool@giveninits}{false} \settoggle{bbx:doi}{true}, which is really ugly. Also, I can't find how to change the style, I tried \def\blx@opt@eldt@style{ieee} but it does nothing. Similarly, I may also need to change the value of maxnames and many more options.

Note that I may have missed an option, in that case I'm curious to learn about it.

MWE

\documentclass[options]{article}
\usepackage[
 style=trad-alpha,
 doi=false,
 giveninits=true, % Bob Foo --> B. Foo
 isbn=false,
 url=false,
 eprint=false,
 sortcites=false, % \cite{B,A,C}: [A,B,C] --> [B,A,C]
]{biblatex}
\parindent=0pt
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Mer89_WhatWrongThis,
  title = {What's {{Wrong}} with This {{Pillow}}?},
  author = {Mermin, N. David},
  year = {1989},
  month = apr,
  volume = {42},
  pages = {9--11},
  publisher = {{American Institute of Physics}},
  issn = {0031-9228},
  doi = {10.1063/1.2810963},
  journal = {Physics Today},
  number = {4}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\makeatletter
\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {%
    % Does not work:
    % \ExecuteBibliographyOptions{style=ieee,giveninits=false,doi=true,url=true,eprint=true}
    \def\blx@opt@eldt@style{ieee}% <--- does nothing.
    \settoggle{abx@bool@giveninits}{false}% Fake giveninits=false, but Whoo, looks super dirty
    \settoggle{bbx:doi}{true}% Fake doi=true, but Whoo, looks super dirty
    \settoggle{bbx:url}{true}% Fake url=true, but Whoo, looks super dirty
    \settoggle{bbx:eprint}{true}% Fake url=true, but Whoo, looks super dirty
    \settoggle{bbx:isbn}{true}% Fake url=true, but Whoo, looks super dirty
    \usedriver{}{\thefield{entrytype}}}%
  {\multicitedelim}%
  {\usebibmacro{postnote}}%
\makeatother

\begin{document}

Here I would like the doi, url, isbn, giveninits=false...
\begin{itemize}
\item \fullcite{Mer89_WhatWrongThis}
\end{itemize}

While here, I want short citations, without doi, url, isbn, and with giveninits=true:
\printbibliography

\end{document}

tobiasBora avatar Feb 28 '22 13:02 tobiasBora

It is an interesting suggestion to allow for (more) local execution of some options. But this definitely cannot work for all options. The style option for example is implemented in such a way that it can only be passed at loading time as it determines which style files are read. You cannot switch the style mid-document, much less mid-command.

At the moment, I see style options as a quick way to set things for end-users. If you begin writing your own commands and heavily modifying existing ones, you are sort of expected to go a bit deeper and implement things on a more basic level.

moewew avatar Feb 28 '22 21:02 moewew

Imho it would be nice to have some interface for local execution. And to have a list with the options for which such local execution actually works.

u-fischer avatar Mar 10 '22 10:03 u-fischer