.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
排序方案anyt
和anyvt
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}