8

I have a large .bib database in which lots of entries have shorthands fields defined.

When I want to limit the usage of those shorthands only to the most cited texts, I generaly create a copy of the bibliography database to the working directory and either delete the unwanted shorthands or change the field to something like XXXshorthand, in order to hide it from bibtex/biber.

Now I'd like to automate that process. I imagine two ways of accomplishing that:

  1. Somenthing like \includeonly command, that I can set at the preamble, adding the entries that are allowed to have shorthands (I don't know if it is possible or how to do it, but it would check if the bib entry is equal to the ones listed and if not add a \clearfield{shorthand} to them).

  2. A very different approach, but one that might be more general than that, is to check if a given entry is cited more than three or five times (something definable by the user) and if so allowing it to use its shorthands.

So the question is if it is possible and if so, how?

EDIT

Folowing @ienissei's comment, which pointed to an answer by @lockstep, I've able, so far to both ignore shorthandintro (which prints the string citedas —in english, "henceforth cited as..."— and the shorthand in the first citation) and to make subsequent citations (up to three) to ignore the shorthand and use the cite:short bibmacro.

Here's a MWE of what I did so far, drawn on the top of the one provided by the mentioned answer:

\documentclass{article}
\usepackage[style=verbose-trad3,citecounter=true]{biblatex}
\usepackage{filecontents}
  \begin{filecontents}{\jobname.bib}
      @misc{A01,
        author = {Author, A.},
        year = {2001},
        title = {Alpha},
        shorthand = {AL},
      }
      @misc{B02,
        author = {Buthor, B.},
        year = {2002},
        title = {Bravo},
        shorthand = {BR},
      }
  \end{filecontents}
\addbibresource{\jobname.bib}

% Command to tell how much citations activate the use of shorthands
  \newcommand{\shthreshold}[1]{\newcommand{\SHthreshold}{#1}}
  \shthreshold{3}

\renewbibmacro*{cite}{%
  \usebibmacro{cite:citepages}%
  \global\togglefalse{cbx:loccit}%
  \ifciteseen
    {\ifciteibid
       {\ifloccit
    {\usebibmacro{cite:ibid}}
    {\iffieldundef{shorthand}
       {\usebibmacro{cite:opcit}}
        {\ifnumgreater{\value{citecounter}}{\SHthreshold}%
        {\usebibmacro{cite:shorthand}}
        {\usebibmacro{cite:short}}}}}
       {\iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}}
    {\usebibmacro{cite:full}}}

\renewbibmacro*{cite:full}{%
  \usebibmacro{cite:full:citepages}%
  \printtext[bibhypertarget]{%
    \usedriver
      {\DeclareNameAlias{sortname}{default}}
      {\thefield{entrytype}}}%
  \ifnumgreater{\value{citecounter}}{\SHthreshold}{
    \usebibmacro{shorthandintro}}{}}

\begin{document}
\printshorthands
Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}. 
Some text \autocite{A01}. Some text \autocite{A01}. Some text \autocite{A01}. 
Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}. 
\printbibliography
\end{document}

It works perfectly well, except that it still prints the entry in the list of shorthands.

EDIT2: I change the code, because it wasn't working with entries witout shorthands. The problem was with the \iffieldundef{shorthand}.

2
  • 2
    There is a citecounter option that can be enabled in biblatex, which will create the appropriate counter and macro. Maybe this answer could help you.
    – ienissei
    Commented Mar 13, 2012 at 21:05
  • @ienissei It really helps! I've been able to both stop shorthandintro bibmacro (as done in that answer) and skip to a cite:short the few other citations. However, I have no idea how to remove the entry from the list of shorthands...
    – henrique
    Commented Mar 14, 2012 at 1:57

1 Answer 1

6

Define a suitable bibliography category and use it in \printshorthands. This is very similar to my answer to How to split bibliography into "works cited" and "works not cited"?.

\documentclass{article}

\usepackage[style=verbose-trad3,citecounter=true]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
  @misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
  shorthand = {AL},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
  shorthand = {BR},
}
\end{filecontents}

\addbibresource{\jobname.bib}

% Command to tell how much citations activate the use of shorthands
\newcommand{\shthreshold}[1]{\newcommand{\SHthreshold}{#1}}
\shthreshold{3}

\renewbibmacro*{cite}{%
  \usebibmacro{cite:citepages}%
  \global\togglefalse{cbx:loccit}%
  \ifciteseen
    {\ifciteibid
       {\ifloccit
    {\usebibmacro{cite:ibid}}
    {\iffieldundef{shorthand}
       {\usebibmacro{cite:opcit}}
        {\ifnumgreater{\value{citecounter}}{\SHthreshold}%
        {\usebibmacro{cite:shorthand}}
        {\usebibmacro{cite:short}}}}}
       {\iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}}
    {\usebibmacro{cite:full}}}

\renewbibmacro*{cite:full}{%
  \usebibmacro{cite:full:citepages}%
  \printtext[bibhypertarget]{%
    \usedriver
      {\DeclareNameAlias{sortname}{default}}
      {\thefield{entrytype}}}%
  \ifnumgreater{\value{citecounter}}{\SHthreshold}{
    \usebibmacro{shorthandintro}}{}}

\DeclareBibliographyCategory{allowshorthand}
\AtEveryCitekey{%
  \ifnumgreater{\value{citecounter}}{\SHthreshold}{%
    \addtocategory{allowshorthand}{\thefield{entrykey}}%
  }{%
  }%
}

\textheight=250pt% just for the example

\begin{document}

\printshorthands[category=allowshorthand]

Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}. 
Some text \autocite{A01}. Some text \autocite{A01}. Some text \autocite{A01}. 
Some text \autocite{B02}. Some text \autocite{B02}. Some text \autocite{B02}. 

\printbibliography

\end{document}

enter image description here

1
  • Great answer, hadn't thought of that. I will delete mine.
    – ienissei
    Commented Mar 14, 2012 at 7:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .