Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make introcite settabel on per-entry basis #13

Closed
denismaier opened this issue Oct 27, 2018 · 4 comments
Closed

Make introcite settabel on per-entry basis #13

denismaier opened this issue Oct 27, 2018 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@denismaier
Copy link

Sometimes I want to have the shorthand in the bibliography. In biblatex-dw I can use the option shorthandinbib that prints shorthands at the beginning of the respective entry. I thought I could use introcite for this, but it seems that this option is not usable for single entries. Would it be an option to make introcite settable on a per-entry basis?

@moewew
Copy link
Owner

moewew commented Oct 28, 2018

Thank you for that suggestion.

introcite=label must apply to a bibliography in its entirety, so that value does not really lend itself to entry- or type-specific options. introcite=plain on the other hand has no such issue, so that could be implemented. I'll see what I can come up with.

For what it's worth, it is not too complicated to steal the code for shorthandinbib from biblatex-dw, so it might turn out that you don't have any need for introcite at all.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\addbibresource{biblatex-examples.bib}

\DeclareFieldFormat{shorthandinbib}{\mkbibbrackets{#1}}
\newcommand*{\shorthandinbibpunct}{\addspace}
\renewbibmacro*{begentry}{%
  \ifboolexpr{test {\ifcsstring{blx@delimcontext}{bib}}
              and not test {\ifcitation}}
    {\iffieldundef{shorthand}
      {}
      {\printfield[shorthandinbib]{shorthand}%
       \printunit*{\shorthandinbibpunct}}}
    {}}

\begin{document}
\cite{sigfridsson,kant:kpv}
\printbibliography
\end{document}

In this case I would say that the shorthandinbib is nicer than introcite, because it does what you want: You want the shorthand displayed in the bibliography, you do not want the citation label shown for some entries.

biblatex offers \printbiblist{shorthand} to resolve shorthands.

@moewew moewew added the enhancement New feature or request label Oct 28, 2018
@denismaier
Copy link
Author

Absolutely, shorthandinbib is much nicer. Would it be an option to add this to the extended standard styles? I know that I could use the code from biblatex-dw in my preamble, but I would prefer a cleaner preamble, and I also think that this might be a very useful extension.

(I guess you are aware of that, but I want to add that the code in biblatex-dw is actually a bit more complete. The code in your example will output all shorthands in the bibliography. In biblatex-dw it is possible to enableshorthandinbib for individual entries only or for all entries with shorthands. Also biblatex-dw checks whether we are in the bibliography or in the list of shorthands. Obviously, we wouldn't want the shorthand printed twice in the list of shorthands.)

moewew added a commit that referenced this issue Nov 4, 2018
- Enable introcite per type and per entry. introcite=label is only
  available globally since it needs bibliography environment
  definitions.
- Simplify the setup for options on all three levels.
@moewew
Copy link
Owner

moewew commented Nov 4, 2018

2b0a7df enables introcite on a per-entry and per-type level. As mentioned above only introcite=plain can be guaranteed to work in those situations, so introcite=label issues a warning when used at those levels.

I'm a bit on the fence whether or not I should implement something like biblatex-dw's shorthandinbib. Despite the details you rightfully pointed out I still believe that for the most part it is easy to recreate what that option does with a few lines of code, so I don't think that it warrants inclusion in biblatex-ext. On the other hand I don't quite like the solution biblatex-dw took for dealing with the 'detail' of not printing the shorthand twice in the list of shorthands, but I have nothing better to offer myself.

@moewew
Copy link
Owner

moewew commented Nov 29, 2018

v0.6 allows you to set introcite on a per-entry basis. As mentioned before, only introcite=plain makes sense on a per-entry basis, since introcite=label needs support of the bibliography environment.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=ext-authoryear, backend=biber]{biblatex}

\DeclareFieldFormat{bbx@introcite}{\mkbibbold{#1}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{sigfridsson,
  author  = {Sigfridsson, Emma and Ryde, Ulf},
  title   = {Comparison of methods for deriving atomic charges from the
             electrostatic potential and moments},
  journal = {Journal of Computational Chemistry},
  year    = 1998,
  volume  = 19,
  number  = 4,
  pages   = {377-395},
  doi     = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
@misc{elk,
  author   = {Anne Elk},
  title    = {A Theory on Brontosauruses},
  url      = {http://www.example.edu/~elk/bronto.pdf},
  year     = {2016},
  options  = {introcite=plain},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\cite{sigfridsson,elk}
\printbibliography
\end{document}

If there still is interest in something similar to shorthandinbib I suggest you open a new issue about that, so we can discuss this in more detail. I'm still not sure how much I like the idea of implementing it, but at least we then have a place for discussions.

@moewew moewew closed this as completed Nov 29, 2018
@moewew moewew added this to the v0.6 milestone Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants