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 need to modify specific citation commands to use certain fields, and not others, depending on the type of reference being cited. Is there a way to do this using BibLaTeX (with a bibtex backend)?

Specifically, I would like to redefine

  • \citeyearpar for patents so that it prints just the patent number (and no parentheses), and
  • \citealp for patents so that it prints the patent number with the abbreviated country name associated with the patent type (from § 4.9.2.19 of the BibLaTeX documentation; e.g. "US") prepended (no space);

and I would like to define some additional (helper) citations including

  • \citepatass to print the assignee,
  • \citepatissue to print the issue date, and
  • \citepatlabel to a long identifying the issuing country, e.g. "U.S. Patent".

For a variety of reasons I need to limit the citation commands I use (primarily) to the natbib commands (e.g. \citep, \citet and all the others listed in § 3.6.9 of the BibLaTeX documentation). Generally I will be using the verbose style for both citations and my bibliography.

Additionally I'd like for citations of patents after the first to behave like the commands show the patent number rather than shortened verbose output.


\documentclass[nobib]{tufte-handout}
\RequirePackage{xpatch}     % For the patches below
\RequirePackage{hyphenat}   % See -- http://code.google.com/p/tufte-latex/issues/detail?id=60
\RequirePackage[
    backend=bibtex, 
    natbib=true, 
    bibstyle=verbose, citestyle=verbose,    % bibstyle extensively modifed below
    doi=true, url=true,                     % excluded from citations below
    citecounter=true, citetracker=true,
    block=space, 
    backref=true, backrefstyle=two,
    abbreviate=false            % Ideally, I'd like to abbreviate the patent locations, but nothing else
]{biblatex}

% For tufte-like behavior (I never use \cite itself); see -- http://tex.stackexchange.com/a/47763/7844
% Not directly related to the question but included for completeness
\let\citep\footcite 

% Some reordering and exclusions; see -- http://tex.stackexchange.com/q/46804/7844
% Not directly related to the question but included for completeness
\newbibmacro*{addendum+pubstate+pageref}{%
    \usebibmacro{addendum+pubstate}%
    \clearfield{addendum}%
    \clearfield{pubstate}%
    \setunit{\bibpagerefpunct}\newblock
    \usebibmacro{pageref}%
    \clearlist{pageref}%
    \setunit{\adddot\par\nobreak}}

\xpretobibmacro{doi+eprint+url}{\usebibmacro{addendum+pubstate+pageref}}{}{}
\xpretobibmacro{eprint}{\usebibmacro{addendum+pubstate+pageref}}{}{}
\xpretobibmacro{url+urldate}{\usebibmacro{addendum+pubstate+pageref}}{}{}


% Better patent numbers, from -- http://tex.stackexchange.com/a/45584/7844
% Not directly related to the question but included for completeness
\def\mkcommasep#1#2#3#4#5#6{#1#2#3,#4#5#6}
\DeclareFieldFormat[patent]{number}{\mkcommasep#1}

\begin{filecontents}{\jobname.bib}
@book{edisonbook1,
     author = {Edison, Thomas},
     title = {I'm too busy inventing to write books},
     year = {1920}}
@book{edisonbook2,
     author = {Edison, Thomas},
     title = {Another book I don't have the time to write},
     year = {1921}}
@patent{edisonpatant1,
    author = {Edison, Thomas},
    title = {My first great invention},
    type={patentus},location={countryus},
    month = jan, year = {1911},
    number = {266701}}
@patent{edisonpatant2,
    author = {Edison, Thomas},
    title = {A second fantastic invention}, 
    type={patentus},location={countryus},
    month = feb, year = {1912},
    number = {266702}}
@patent{edisonpatant3,
    author = {Edison, Thomas},
    title = {A third remarkable contraption},   
    type={patentus},location={countryus},
    month = mar, year = {1913},
    number = {266703},
    year = {1913}}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\subsection*{Some things that already work correctly}
This citation\citep{edisonpatant1} of an \citeauthor{edisonpatant1} patent works pretty much as desired. Note that I use \texttt{citep} to generate citations as footnotes. While other \texttt{natbib} citations commands do not.\footnote{This is necessary so that they can be used in footnotes. For example, citing \citealt{edisonpatant2} here embeds the verbose description; similarly for the author (\citeauthor{edisonpatant2}) or the year for a non-patent (\citeyear{edisonbook1})}. 
\subsection*{Basic patent-related citation changes}
I'd like to use at least one of the basic \texttt{natbib} macros that do not produce verbose output to print the  \textit{patent number}, in place of its default behavior. For example, instead of the year, for \texttt{citeyear}, instead of "\citeyear{edisonpatant1,edisonpatant2,edisonpatant3}" I want to have "266,701; 266,7021; 266,703". Additionally I'd like to co-opt another command (perhaps  \texttt{citealp}) to work similarly, but prepend the type string, e.g. US 266,701; US 266,7021; US 266,703". I realize that there are issues with combining such output with the normal behavior of these macros, and am happy to accept an error if patents are combined with non-patents in a single such macro invocation.
\subsection*{Patent behavior for subsequent citations}
Finally, I'd like for citations of patents after the first to behave like the commands above: they should show the patent number\footnote{US 266,701} rather than the normal shortened verbose output\citep{edisonpatant1}.
\subsection*{But wait, there's more}
While I'm at it (and only because perhaps it's easier to do in context of these modifications), I'd like to abbreviate \textit{only} the location in the bibliography (even with \texttt{abbreviate=false} in the options to \texttt{biblatex}), and omit location entirely from citations.
\printbibliography
\end{document}
share|improve this question
2  
Please provide a minimal example. –  Marco Daniel Mar 23 '12 at 15:32
    
@MarcoDaniel: MWE added. –  raxacoricofallapatorius Mar 23 '12 at 17:41
    
@raxacoricofallapatorius So you only use 6-digit patent numbers and indicate one country in the location list field? I'm busy ATM, but if this post goes without additional answers for a few days I'll try to post one for you. –  Audrey Mar 23 '12 at 17:51
    
@Audrey: I can't be sure what the constraints on the patent numbers might be, they could have arbitrary digits (or even letters); it's only currently that I assume 6 digits for the purpose of formatting US patent numbers. But yes, one "location", actually the "type" -- i.e the issuing country. The key thing is to this behavior be automatic for the relevant (co-opted) basic natbib macros. E.g. automatically invoking something like lockstep's suggested new macros below, when patents are supplied to, for example, \citealp. –  raxacoricofallapatorius Mar 23 '12 at 17:57
1  
@raxacoricofallapatorius I think I'll leave you with lockstep's answer as dedicated citation commands are probably the way to go. Your request for compact, sorted citations based on location and patent number can't be met without some style restrictions and biber. –  Audrey Mar 26 '12 at 14:02

1 Answer 1

up vote 4 down vote accepted

Citation commands should be able to cope with multiple keys in their mandatory argument, and those keys may be of different entry types. Also, the \citeyearpar command will wrap its output (the content of one or multiple year fields) into a single set of parentheses. Therefore I don't think it's a good idea (though it may be possible) to redefine \citeyearpar according to the entry type of one of its multiple keys. Instead, I suggest to define a \citenumber macro which resembles \citeyearpar, but prints the content of the number field(s) and omits the surrounding parentheses.

Your suggested redefinition of \citealp faces an additional obstacle: The country name strings of section 4.9.2.19 of the biblatex manual are used in the patent's location field, but this field is optional and (as a list field) allows multiple entries, so the output of a possible \citelocnumber macro may not be as pretty as you expect.

\documentclass{article}

\usepackage[style=verbose,backend=bibtex8,natbib=true]{biblatex}

\DeclareCiteCommand{\citepatnumber}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifentrytype{patent}{\printfield{number}}{\GenericError{}{Not a patent entry}{}{}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citepatlocnumber}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\printlist[][-\value{listtotal}]{location}%
   \ifentrytype{patent}{\printfield{number}}{\GenericError{}{Not a patent entry}{}{}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\addbibresource{biblatex-examples.bib}

\begin{document}

\citepatnumber{kowalik,almendro}

\citepatlocnumber{kowalik,almendro}

% Commenting the following in will raise a generic error
% \citepatnumber{knuth:ct:a}

\printbibliography

\end{document}

enter image description here

share|improve this answer
    
I see the problem. Is there a way to define the macros as you propose, and then detect, within, for example, \citeyearpar whether all of the arguments are patents, "switching" to your \citenumber if they are (and perhaps logging an error if the user attempts to combine patents and non-patents)? –  raxacoricofallapatorius Mar 23 '12 at 16:57
    
@raxacoricofallapatorius Right now, I have no idea. Maybe some one else (e.g., Audrey) will come up with something. –  lockstep Mar 23 '12 at 17:03
    
@raxacoricofallapatorius biblatex processes the entries in a citation list one at a time. So what you're asking for will require two passes through the list. It can be done - \textcite in the verbose styles is an example. Can you at least partly fulfill Marco's request for a MWE? Some concrete examples with a bib file would be helpful. –  Audrey Mar 23 '12 at 17:34
    
@Audrey: MWE added. –  raxacoricofallapatorius Mar 23 '12 at 17:42
1  
@raxacoricofallapatorius I added a generic error message. Requirements (3) and (4) are tricky, and I can't promise anything. –  lockstep Mar 23 '12 at 22:28

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.