.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特殊字段,第 30 页):
[
sortshorthand
] 类似于sortkey
但用于简写列表。如果存在,则在对简写列表进行排序时biblatex
使用此字段而不是。shorthand
如果简写字段包含带有格式化命令(例如\emph
或 )的简写,则这很有用。\textbf
对于alphabetic
排序方案anyt
和anyvt
biblatex
不使用sortshorthand
(因为这基本上意味着跟踪labelalpha
和sortlabelalpha
将根据相同规则构建的,但优先于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}