如何设置“智能引用命令”?

如何设置“智能引用命令”?

biblatex软件包附带了一堆示例文件。其中一个名为18-数字混合.tex。其中包含以下文本:

我们为在线参考文献定义了专用的引文命令,该命令使用数字标签而不是作者年份方案。除了定义专用命令外,还可以(通常更可取)构建智能引文命令,该命令能够根据条目类型(或其他标准)切换引文样式。

有人能提示我如何以最佳方式实现这种智能引用命令吗?

答案1

首先,我认为奥黛丽说得对,人们只能猜测上述文件的创建者所说的“智能引用命令”是什么意思。

Audrey 发布的链接帮助我提出了这个 MWE(请注意,我的例子是基于混合风格的想法,如18-数字混合.tex包的示例文件biblatex):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[
    style=alphabetic,
    labelnumber,
    defernumbers,
    backend=biber,
]{biblatex}
\addbibresource{test.bib}

\begin{filecontents}{test.bib}
@BOOK{Author2001,
  author = {Alastname1, Afirstname1},
  title = {Title},
  year = {2001},
}
@BOOK{Author2002,
  author = {Blastname1, Bfirstname1 and Blastname2, Bfirstname2},
  title = {Title},
  year = {2002},
}
@ONLINE{Online2001,
  author = {Olastname1, Ofirstname},
  title = {Test Website},
  year = {2001},
  url = {http://www.test.de},
  urldate = {2013-08-28},
}
@ONLINE{Online2002,
  author = {Olastname2, Ofirstname},
  title = {Test Website},
  year = {2002},
  url = {http://www.test.de},
  urldate = {2013-08-28},
}
\end{filecontents}

% Renew \cite command for entries of the type online
\renewbibmacro*{cite}{%
    \ifentrytype{online}{%
        \printtext[bibhyperref]{%
            \printfield{prefixnumber}%
            \printfield{labelnumber}}}{%
        \printtext[bibhyperref]{%
            \printfield{prefixnumber}%
            \printfield{labelalpha}%
            \printfield{extraalpha}}}}

% Setup "online" environment for sub-bibliography
\defbibenvironment{online}
    {\list{
        \printtext[labelnumberwidth]{%
            \iffieldundef{shorthand}{%
                \printfield{prefixnumber}\printfield{labelnumber}}{%
                \printfield{shorthand}}}}{%
            \setlength{\labelwidth}{\labelnumberwidth}%
            \setlength{\leftmargin}{\labelwidth}%
            \setlength{\labelsep}{\biblabelsep}%
            \addtolength{\leftmargin}{\labelsep}%
            \setlength{\itemsep}{\bibitemsep}%
            \setlength{\parsep}{\bibparsep}}%
    \renewcommand*{\makelabel}[1]{\hss##1}}
    {\endlist}
    {\item}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}


\begin{document}
Published source \cite{Author2002}. Online source \cite{Online2002}. Published source \cite{Author2001}. Online source \cite{Online2001}.

\printbibheading

\printbibliography[heading=subbibliography,title={Published Sources},nottype=online,omitnumbers]

\printbibliography[heading=subbibliography,title={Internet Sources},env=online,type=online,sorting=none]
\end{document}

平均能量损失

相关内容