Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}.

share|improve this question
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 Mar 13 '12 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 Mar 14 '12 at 1:57
add comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
    
Great answer, hadn't thought of that. I will delete mine. –  ienissei Mar 14 '12 at 7:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.