单一缩写列表(首字母缩略词列表 + biblatex 简写列表)

单一缩写列表(首字母缩略词列表 + biblatex 简写列表)

在我的论文中我有两个缩写列表:1)某些表达的首字母缩写glossaries package(例如 APR = 年利率)和 2)通过biblatex package.bib 文件内的简写形式缩写法律文件(例如消费者保护法 = CPA)。

正如所料,如果我输入表达式\printbiblist{shorthand}\printglossary[type=\acronymtype,style=long]我就会得到两个缩写列表。

但是我想要一个单一的(统一的)包。考虑到我使用两个不同的包,可以这样做吗?

答案1

我认为您无法让两个非常不同的包以能够打印共享列表的方式协同工作。

但我们可以用 来伪造整个过程biblatex。我们将实现一个@acronym和一个@glossary类型。该功能非常有限地模仿了glossaries' 功能集。这个想法当然可以得到很大改进,因此这应该被视为一个概念证明。

我们需要一个新的数据模型(参见如何使用 BibLaTeX/Biber 创建全新的数据类型?

\ProvidesFile{fakeglossaries.dbx}[2016/02/24\space fake basic functionalities of the glossaries package using biblatex]
\DeclareDatamodelEntrytypes{glossary}
\DeclareDatamodelEntrytypes{acronym}
\DeclareDatamodelFields[type=field,datatype=literal]{
  name,
  plural,
  description,
  short,
  shortplural,
  long,
  longplural,
}

\DeclareDatamodelEntryfields[glossary]{
  name,
  plural,
  description,
}
\DeclareDatamodelEntryfields[acronym]{
  short,
  shortplural,
  long,
  longplural,
}

然后我们需要确保我们的新类型能够得到正确处理。

\ExecuteBibliographyOptions[glossary,acronym]{skipbib=true}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{acronym}
      \step[fieldsource=short]
      \step[fieldset=shorthand, origfieldval]
    }
    \map{
      \pertype{glossary}
      \step[fieldsource=name]
      \step[fieldset=shorthand, origfieldval]
    }
  }
}

它们没有出现在参考书目中,但却得到了shorthand,所以它们进入了 s 列表shorthand

输出控制

\DeclareFieldFormat[glossary]{name}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{plural}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{description}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareFieldFormat[acronym]{short}{\mkbibacro{#1}}
\DeclareFieldFormat[acronym]{long}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[acronym]{longplural}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareBibliographyDriver{acronym}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{long}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{glossary}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{description}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\newbibmacro{fakegls}{%
  \ifentrytype{glossary}
    {\printfield{name}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\printfield{short}}
          {\printfield{long}}}}}

\newbibmacro{fakeglspl}{%
  \ifentrytype{glossary}
    {\iffieldundef{plural}
       {\printfield{name}s}
       {\printfield{plural}}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\iffieldundef{shortplural}
             {\printfield{short}s}
             {\printfield{shortplural}}}
          {\iffieldundef{longplural}
            {\printfield{long}s}
            {\printfield{longplural}}}}}}

最后实现顶层命令

\DeclareCiteCommand{\fakegls}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakegls}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\fakeglspl}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakeglspl}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newrobustcmd*{\Fakegls}{\bibsentence\fakegls}
\newrobustcmd*{\Fakeglspl}{\bibsentence\fakeglspl}

平均能量损失

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage{filecontents}

\begin{filecontents}{fakeglossaries.dbx}
\ProvidesFile{fakeglossaries.dbx}[2016/02/24\space fake basic functionalities of the glossaries package using biblatex]
\DeclareDatamodelEntrytypes{glossary}
\DeclareDatamodelEntrytypes{acronym}
\DeclareDatamodelFields[type=field,datatype=literal]{
  name,
  plural,
  description,
  short,
  shortplural,
  long,
  longplural,
}

\DeclareDatamodelEntryfields[glossary]{
  name,
  plural,
  description,
}
\DeclareDatamodelEntryfields[acronym]{
  short,
  shortplural,
  long,
  longplural,
}
\end{filecontents}

\usepackage[style=authoryear,backend=biber,citetracker,datamodel=fakeglossaries]{biblatex}

\begin{filecontents}{\jobname.bib}
@glossary{potato,
  name        = {potato},
  plural      = {potatoes},
  description = {starchy tuber},
}
@glossary{cauliflower,
  name        = {cauliflower},
  description = {Cabbage with a College Education},
}
@acronym{dm,
  short      = {DM},
  long       = {diagonal matrix},
  longplural = {diagonal matrices},
}
@acronym{lkw,
  short      = {LKW},
  shortplural= {LKW},
  long       = {Lastkraftwagen},
  longplural = {Lastkraftwagen},
}
\end{filecontents}
\addbibresource{biblatex-examples.bib}
\addbibresource{\jobname.bib}

\ExecuteBibliographyOptions[glossary,acronym]{skipbib=true}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{acronym}
      \step[fieldsource=short]
      \step[fieldset=shorthand, origfieldval]
    }
    \map{
      \pertype{glossary}
      \step[fieldsource=name]
      \step[fieldset=shorthand, origfieldval]
    }
  }
}

\DeclareFieldFormat[glossary]{name}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{plural}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[glossary]{description}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareFieldFormat[acronym]{short}{\mkbibacro{#1}}
\DeclareFieldFormat[acronym]{long}{\ifcapital{\MakeCapital{#1}}{#1}}
\DeclareFieldFormat[acronym]{longplural}{\ifcapital{\MakeCapital{#1}}{#1}}

\DeclareBibliographyDriver{acronym}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{long}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{glossary}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{description}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\newbibmacro{fakegls}{%
  \ifentrytype{glossary}
    {\printfield{name}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\printfield{short}}
          {\printfield{long}}}}}

\newbibmacro{fakeglspl}{%
  \ifentrytype{glossary}
    {\iffieldundef{plural}
       {\printfield{name}s}
       {\printfield{plural}}}
    {\ifentrytype{acronym}
       {\ifciteseen
          {\iffieldundef{shortplural}
             {\printfield{short}s}
             {\printfield{shortplural}}}
          {\iffieldundef{longplural}
            {\printfield{long}s}
            {\printfield{longplural}}}}}}


\DeclareCiteCommand{\fakegls}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakegls}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\fakeglspl}
  {\usebibmacro{prenote}}
  {\usebibmacro{fakeglspl}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newrobustcmd*{\Fakegls}{\bibsentence\fakegls}
\newrobustcmd*{\Fakeglspl}{\bibsentence\fakeglspl}

\begin{document}
Lorem\footcite{sigfridsson,kant:kpv} ipsum

\Fakegls{potato}, \fakegls{dm}, \fakegls{dm}, \fakegls{lkw}, \fakegls{lkw}

\citereset \Fakeglspl{potato}, \fakeglspl{dm}, \fakeglspl{dm}, \fakeglspl{lkw}, \fakeglspl{lkw}

\printbiblist{shorthand}
\printbibliography
\end{document}

示例输出

相关内容