Biber:帶有巨集 \textbf{} 的簡寫方式的排序方式不同

Biber:帶有巨集 \textbf{} 的簡寫方式的排序方式不同

.bib如果我將文件中的速記更改XYZ\textbf{X}YZ參考書目中的順序。

我怎麼能擁有一些以 a 開頭的速記\textbf(將某些字母加粗)而不扭曲排序順序?


微量元素

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[backend=biber,
        style=alphabetic,
        natbib=true,
        sorting=ynt,
        ]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{xei2016asdf,
Author = {Xei, A and A, B and B, C and C, D},
Title = {asdf is asdf},
Year = {2016},
}
@article{xei2017bob,
Author = {Xei, A and A, B and B, C and C, D},
Title = {bob is bob},
Year = {2017},
}
@article{xei2017bob2,
Author = {Xei, A and A, B and B, C and C, D},
Title = {bob is bob 2},
Year = {2017},
shorthand = {\textbf{X}ei+17},
sortshorthand = {Xei+17},
}
@article{xei2017alice,
Author = {Xei, A and A, B and B, C},
Title = {alice is alice},
Year = {2017},
}
@article{xei2018alice2,
Author = {Xei, A and A, B and B, C},
Title = {alice is alice 2},
Year = {2018},
shorthand = {\textbf{X}AB18},
sortshorthand = {XAB18},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\newrefcontext[sorting=anyvt]
\cite{xei2016asdf,xei2017bob,xei2017bob2,xei2017alice,xei2018alice2}

\printbibliography
\end{document}

參考書目中的結果: 在此輸入影像描述

但我仍然想要以下排序: 在此輸入影像描述


人們對所提出的解決方案感到好奇。如果有人考慮:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[backend=biber,
        style=alphabetic,
        ]{biblatex}

\DeclareSortingScheme{anyt}{
  \sort{
    \field{presort}
  }
  \sort{
    \field{sortshorthand}
    \field{labelalpha}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
}

\DeclareSortingScheme{anyvt}{
  \sort{
    \field{presort}
  }
  \sort{
    \field{sortshorthand}
    \field{labelalpha}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{xei2016asdf,
Author = {Xei, A and A, B and B, C and C, D},
Title = {asdf is asdf},
Year = {2016},
}
@article{xei2018bob,
Author = {Xei, A and A, B and B, C and C, D},
Title = {bob is bob},
Year = {2018},
}
@article{xei2017bob2,
Author = {Xei, A and A, B and B, C and C, D},
Title = {bbob is bob 2},
Year = {2017},
shorthand = {\textbf{X}ei+17},
sortshorthand = {Xei+17},
}
@article{xei2017alice,
Author = {Xei, A and A, B and B, C},
Title = {alice is alice},
Year = {2017},
}
@article{xei2018alice2,
Author = {Xei, A and A, B and B, C},
Title = {alice is alice 2},
Year = {2018},
shorthand = {\textbf{X}AB18},
sortshorthand = {XAB18},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\cite{xei2016asdf,xei2018bob,xei2017bob2,xei2017alice,xei2018alice2}

\printbibliography
\end{document}

我們得到在此輸入影像描述

與不帶簡寫的排序相比在此輸入影像描述

答案1

biblatex熟悉該領域sortshorthand。這biblatex文件解釋(§2.2.3特殊領域,p。 30):

[ sortshorthand] 與簡寫清單類似,sortkey但用於簡寫清單中。如果存在,biblatex則使用此欄位而不是shorthand對簡寫清單進行排序。如果速記欄位包含具有格式化命令(例如\emph或 )的速記,這非常有用\textbf

對於alphabetic排序方案anytanyvt biblatex不使用sortshorthand(因為這基本上意味著跟踪 alabelalpha和 asortlabelalpha將根據相同的規則構建,但優先考慮sort...字段)。

使用標準設定(如果後者存在則設定labelalpha為),在排序方案中加入before就足夠了。shorthand\field{sortshorthand}\field{labelalpha}

MWE 重新定義了兩種排序方案,但如果您只使用兩種排序方案中的一種,則可以放棄另一種。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[backend=biber,
        style=alphabetic,
        ]{biblatex}

\DeclareSortingTemplate{anyt}{
  \sort{
    \field{presort}
  }
  \sort{
    \field{sortshorthand}
    \field{labelalpha}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
}

\DeclareSortingTemplate{anyvt}{
  \sort{
    \field{presort}
  }
  \sort{
    \field{sortshorthand}
    \field{labelalpha}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{xei2016asdf,
Author = {Xei, A and A, B and B, C and C, D},
Title = {asdf is asdf},
Year = {2016},
}
@article{xei2017bob,
Author = {Xei, A and A, B and B, C and C, D},
Title = {bob is bob},
Year = {2017},
}
@article{xei2017bob2,
Author = {Xei, A and A, B and B, C and C, D},
Title = {bob is bob 2},
Year = {2017},
shorthand = {\textbf{X}ei+17},
sortshorthand = {Xei+17},
}
@article{xei2017alice,
Author = {Xei, A and A, B and B, C},
Title = {alice is alice},
Year = {2017},
}
@article{xei2018alice2,
Author = {Xei, A and A, B and B, C},
Title = {alice is alice 2},
Year = {2018},
shorthand = {\textbf{X}AB18},
sortshorthand = {XAB18},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\cite{xei2016asdf,xei2017bob,xei2017bob2,xei2017alice,xei2018alice2}

\printbibliography
\end{document}

排序順序 [XAB17]、[XAB18]、[Xei+16]、[Xei+17]、[Xei+17]

相關內容