
我正在嘗試使用排版出版物列表biblatex
,並希望將條目標題更改為句子大小寫(或大寫/小寫/標題大小寫)。我嘗試使用\DeclareFieldFormat{title}{\MakeSentenceCase{#1}}
但似乎不起作用。
微量元素:
%\RequirePackage{filecontents}
\begin{filecontents}{pub.bib}
@article{article1,
author={Author One and Author Two},
title={Title of Article One},
date= {2018},
}
@article{article2,
author={Author One and Author Two},
title={Title of article two},
date= {2017},
}
\end{filecontents}
\documentclass{article}
\usepackage[
backend=biber,
sorting=ynt,
giveninits=true,
maxbibnames=99,
]{biblatex}
\DeclareFieldFormat*{title}{\MakeCapital{#1}} % Change titles to sentence case
\addbibresource{pub.bib}
\begin{document}
\nocite{*}
\printbibliography[type=article, title={Publications}]
\end{document}
答案1
你應該用titlecase
它。
\DeclareFieldFormat*{titlecase}{\MakeSentenceCase{#1}}
完整的 MWE:
%\RequirePackage{filecontents}
\begin{filecontents}{pub.bib}
@article{article1,
author={Author One and Author Two},
title={Title of Article One},
date= {2018},
}
@article{article2,
author={Author One and Author Two},
title={Title of article two},
date= {2017},
}
\end{filecontents}
\documentclass{article}
\usepackage[
backend=biber,
sorting=ynt,
giveninits=true,
maxbibnames=99,
]{biblatex}
\DeclareFieldFormat*{titlecase}{\MakeSentenceCase{#1}} % Change titles to sentence case
\addbibresource{pub.bib}
\begin{document}
\nocite{*}
\printbibliography[type=article, title={Publications}]
\end{document}
更新:也許解釋為什麼應該使用titlecase
而不是title
在這裡可能有用。如果我們查看巨集的定義title
,biblatex.def
我們會發現以下內容:
\newbibmacro*{title}{%
\ifboolexpr{
test {\iffieldundef{title}}
and
test {\iffieldundef{subtitle}}
}
{}
{\printtext[title]{%
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}%
\newunit}%
\printfield{titleaddon}}
請注意,格式化指令[title]
適用於title + subtitle
列印指令。這是必要的,因為參考書目樣式的一個常見要求是一些常見條目類型的標題設置在引號之間,即“標題”和“副標題”都是一對引號。格式化指令[titlecase]
單獨應用於title
和subtitle
。這樣做的結果是,如果您嘗試套用\MakeSentenceCase
格式化title
指令,您將向其提供一系列\printfield
s 和標點符號指令,以及它們自己的單獨格式化指令[titlecase]
。正如您所注意到的,有些東西表現得不好。但是,即使這是一個經過淨化的字串,您也會得到不需要的副標題的小寫首字母(您將把它們一起輸入到\MakeSentenceCase
)。因此,簡而言之, the 的titlecase
存在正是為了使人們能夠單獨處理title
和subtitle
,並且這將是應用任何句子大小寫指令的適當範圍。