我需要修改特定的引用命令以使用某些字段,而不是其他字段,具体取决于所引用的参考文献类型。有没有办法使用 BibLaTeX(带后端bibtex
)来做到这一点?
具体来说,我想重新定义
\citeyearpar
对于专利,它只打印专利号(不打印括号),并且\citealp
用于专利,以便打印专利号以及与专利相关的缩写国家名称类型(来自 BibLaTeX 文档的 § 4.9.2.19;例如“US”)添加在前面(无空格);
我想定义一些额外的(辅助)引用,包括
\citepatass
打印受让人,\citepatissue
打印发行日期,以及\citepatlabel
详细标识颁发国家,例如“美国专利”。
由于各种原因,我需要将我使用的引用命令(主要)限制为命令natbib
(例如\citep
,\citet
以及 BibLaTeX 文档第 3.6.9 节中列出的所有其他命令)。通常,我将verbose
在引用和参考书目中使用该样式。
此外,我希望在第一个专利之后的专利引用表现得像命令显示专利编号而不是缩短的详细输出。
\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}
答案1
引用命令应该能够处理其强制参数中的多个键,并且这些键可能属于不同的条目类型。此外,该\citeyearpar
命令会将其输出(一个或多个字段的内容year
)包装到一组括号中。因此,我认为根据其多个键之一的条目类型进行重新定义不是一个好主意(尽管可能)\citeyearpar
。相反,我建议定义一个\citenumber
类似于的宏\citeyearpar
,但打印字段的内容number
并省略周围的括号。
您建议的重新定义\citealp
面临另一个障碍:biblatex
手册第 4.9.2.19 节的国家名称字符串用于专利location
字段,但该字段是可选的和(作为列表字段)允许多个条目,因此可能的宏的输出\citelocnumber
可能不像您期望的那样漂亮。
\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}