我正在寫一篇論文,其中多次引用了多年來在多個日期發行的同名報紙/期刊。我試圖按期刊名稱將這些參考文獻分組在一起,以便同一期刊的參考書目條目靠近在一起,並與其他期刊的其他條目分開。
我廣泛地瀏覽了 biblatex 文檔,我能找到的唯一相關資訊是bibnamesep
和bibitemsep
長度暫存器。這些似乎正是我所需要的 - 具有相同標題的期刊的 bibitem 應該比非同名期刊的 bibitem 更接近。這裡唯一的挑戰是 bibnamesep 似乎使用名稱部分和唯一性模板來按作者姓名(而不是按標題)將作品分組在一起。
這是我的 MWE:
\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage[T1]{fontenc} % Specify font encoding
\usepackage[utf8]{inputenc} % Specify encoding (for example, UTF-8)
\usepackage[dashed=false,sorting=nyt,style=verbose,labeldateparts=true,uniquelist=true,uniquename=true,singletitle=true]{biblatex}
% Preamble - Here you can load packages and define settings
\usepackage[english]{babel}
\begin{filecontents*}[overwrite]{mwe.bib}
@periodical{TheSun:20220101,
title = {The Sun},
date = {2022-01-01}
}
@periodical{TheTimes:20220601,
title = {The Sun},
date = {2022-06-01}
}
@periodical{TheTimes:20220901,
title = {The Sun},
date = {2022-09-01}
}
@periodical{TheGuardian:20210217,
title = {The Guardian},
date = {2021-02-17}
}
@periodical{TheGuardian:20210311,
title = {The Guardian},
date = {2021-03-11}
}
@periodical{TheGuardian:20210410,
title = {The Guardian},
date = {2021-04-10}
}
@periodical{TheAlmanac:202302,
title = {The Almanac},
date = {2023-02}
}
@periodical{TheAlmanac:202303,
title = {The Almanac},
date = {2023-03}
}
@periodical{TheAlmanac:202304,
title = {The Almanac},
date = {2023-04}
}
\end{filecontents*}
\addbibresource{mwe.bib}
\DeclareSortingTemplate{TitleYear}{
\sort{
\field{title}
}
\sort{
\field{sortyear}
\field{year}
\literal{9999}
}
\sort{
\field{month}
}
\sort{
\field{day}
}
}
\begin{document}
\bibitemsep=1pt
\bibnamesep=30pt
\nocite{*}
\begin{refcontext}[sorting=TitleYear]
\printbibliography
\end{refcontext}
\end{document}
它包含 9 個@periodical
條目 - 3 個來自《太陽報》,3 個來自《衛報》,3 個來自《年鑑》。它使用排序範本按期刊標題對條目進行排序,並將\bibitemsep
和\bibnamesep
分別設為 1pt 和 30pt。這是我無法上班的地方:
正如您在上圖中所看到的,參考文獻之間的間距均為 30pt,而我希望“The Almanac”bibitems 為 1pt,但將“The Almanac”與“The Guardian”分開為 30pt。
答案1
\bibnamesep
僅適用於 中編碼的具有不同名稱的條目之間fullhash
。如果您想將其變更為title
,您可以嘗試(本地)重新定義設定分隔符號的相關內部巨集。
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[
style=verbose,
sorting=nyt,
dashed=false,
labeldateparts=true,
uniquelist=true,uniquename=true,
singletitle=true,
]{biblatex}
\makeatletter
\def\blx@namesep@title{%
\ifnum\c@instcount>\@ne
\blx@imc@iffieldequals{title}\blx@prevtitle
{}
{\addvspace{\bibnamesep}}%
\fi
\global\let\blx@prevtitle\abx@field@title}
\newcommand*{\NamesepByTitle}{\let\blx@namesep\blx@namesep@title}
\makeatother
\DeclareSortingTemplate{TitleYear}{
\sort{
\field{title}
}
\sort{
\field{sortyear}
\field{year}
\literal{9999}
}
\sort{
\field{month}
}
\sort{
\field{day}
}
}
\begin{filecontents*}[overwrite]{\jobname.bib}
@periodical{TheSun:20220101,
title = {The Sun},
date = {2022-01-01}
}
@periodical{TheTimes:20220601,
title = {The Sun},
date = {2022-06-01}
}
@periodical{TheTimes:20220901,
title = {The Sun},
date = {2022-09-01}
}
@periodical{TheGuardian:20210217,
title = {The Guardian},
date = {2021-02-17}
}
@periodical{TheGuardian:20210311,
title = {The Guardian},
date = {2021-03-11}
}
@periodical{TheGuardian:20210410,
title = {The Guardian},
date = {2021-04-10}
}
@periodical{TheAlmanac:202302,
title = {The Almanac},
date = {2023-02}
}
@periodical{TheAlmanac:202303,
title = {The Almanac},
date = {2023-03}
}
@periodical{TheAlmanac:202304,
title = {The Almanac},
date = {2023-04}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\bibitemsep=1pt
\bibnamesep=30pt
\nocite{*}
\begin{refcontext}[sorting=TitleYear]
\NamesepByTitle
\printbibliography
\end{refcontext}
\end{document}