plk / biblatex

biblatex is a sophisticated bibliography system for LaTeX users. It has considerably more features than traditional bibtex and supports UTF-8
507 stars 115 forks source link

Allow user to evaluate ExecuteBibliographyOptions in DeclareCiteCommand #1209

Open tobiasBora opened 2 years ago

tobiasBora commented 2 years ago

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}
moewew commented 2 years ago

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.

u-fischer commented 2 years ago

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.