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了解该领域sortshorthandbiblatex文档解释(§2.2.3特殊字段,第 30 页):

[ sortshorthand] 类似于sortkey但用于简写列表。如果存在,则在对简写列表进行排序时biblatex使用此字段而不是。shorthand如果简写字段包含带有格式化命令(例如\emph或 )的简写,则这很有用。\textbf

对于alphabetic排序方案anytanyvt biblatex不使用sortshorthand(因为这基本上意味着跟踪labelalphasortlabelalpha将根据相同规则构建的,但优先于sort...字段)。

使用标准设置(如果后者存在则设置labelalpha为),在排序方案之前添加就足够了。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]

相关内容