![带有 runin 标题的精简参考书目,如 titlesec](https://linux22.com/image/321473/%E5%B8%A6%E6%9C%89%20runin%20%E6%A0%87%E9%A2%98%E7%9A%84%E7%B2%BE%E7%AE%80%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%EF%BC%8C%E5%A6%82%20titlesec.png)
这是我正在处理的文档的 MWE,基于以下代码:这里,修改了一些titlesec
选项。我的目标是让参考文献标题像所有其他部分一样显示为连续标题。
\documentclass{article}
\usepackage[style=nature,backend=bibtex,maxnames=1,uniquelist=false]{biblatex}
\usepackage[colorlinks]{hyperref}
% Some field suppression via options
\ExecuteBibliographyOptions{isbn=false,url=false,doi=false,eprint=false}
% One-paragraph bibliography environment
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}}%
\ifentrytype{article}{% Suppress remaining fields/names/lists here
\clearfield{title}}{}}
{\setlength{\leftmargin}{0pt}%
\setlength{\topsep}{0pt}}%
\renewcommand*{\makelabel}[1]{##1}}
{\endlist}
{\mkbibitem}
% \mkbibitem just prints item label and non-breakable space
\makeatletter
\newcommand{\mkbibitem}{\@itemlabel\addnbspace}
\makeatother
% Add breakable space between bibliography items
\renewcommand*{\finentrypunct}{\addperiod\space}
% et al. string upright (nature style applies \mkbibemph)
\renewbibmacro*{name:andothers}{%
\ifboolexpr{
test {\ifnumequal{\value{listcount}}{\value{liststop}}}
and
test \ifmorenames
}
{\ifnumgreater{\value{liststop}}{1}{\finalandcomma}{}%
\andothersdelim
\bibstring{andothers}}
{}}
\addbibresource{biblatex-examples.bib}
\usepackage{titlesec}
\titlespacing{\section}{0pt}{3pt plus 3pt minus 3pt}{6pt plus 3pt minus 3pt}
\titlespacing{\subsection}{0pt}{0pt plus 0pt minus 0pt}{6pt plus 3pt minus 3pt}
\titlespacing{\subsubsection}{0pt}{0pt plus 0pt minus 0pt}{6pt plus 3pt minus 3pt}
\titleformat{\section}[runin]
{\normalfont\bfseries\large}
{\S\ \thesection.}{0.0cm}{}[:]
\titleformat{\subsection}[runin]
{\normalfont\bfseries\small}
{\S\ \thesubsection.}{0.0cm}{}[:]
\titleformat{\subsubsection}[runin]
{\normalfont\bfseries\small}
{\S\ \thesection.}{0.0cm}{}[.]
\titleformat{\bibliography}[runin]
{\normalfont\bfseries}
{\S\ \thebibliography.}{0.0cm}{}[:]
\begin{document}
\section*{Section title}
Filler text \parencite{bertram,glashow,aksin}.
\printbibliography
\section*{Section title}
Filler text.
\end{document}
正如您所看到的,我尝试应用一些 titlesec 选项来使其工作,但是没有成功。
答案1
在 中biblatex
,\printbibliography
开始一个列表,并且列表甚至连您的部分定义都会导致换行(您可以在命令itemize
后 使用进行检查\section
)。
我建议您使用以下重新定义环境bibliography
,它不启动列表,而只是一个普通的段落。
\defbibenvironment{bibliography}
{}
{\unspace}
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}}%
\addspace}
如果你想删除stitle
中的 s ,@article
更惯用的解决方案是
\AtEveryBibitem{%
\ifentrytype{article}
{\clearfield{title}}
{}%
}
平均能量损失
\documentclass{article}
\usepackage[style=nature,backend=bibtex,maxnames=1,uniquelist=false]{biblatex}
\usepackage[colorlinks]{hyperref}
\ExecuteBibliographyOptions{isbn=false,url=false,doi=false,eprint=false}
\defbibenvironment{bibliography}
{}
{\unspace}
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}}%
\addspace}
\AtEveryBibitem{%
\ifentrytype{article}
{\clearfield{title}}
{}%
}
\renewcommand*{\finentrypunct}{\addperiod\space}
\renewbibmacro*{name:andothers}{%
\ifboolexpr{
test {\ifnumequal{\value{listcount}}{\value{liststop}}}
and
test \ifmorenames
}
{\ifnumgreater{\value{liststop}}{1}{\finalandcomma}{}%
\andothersdelim
\bibstring{andothers}}
{}}
\addbibresource{biblatex-examples.bib}
\usepackage{titlesec}
\titlespacing{\section}{0pt}{3pt plus 3pt minus 3pt}{6pt plus 3pt minus 3pt}
\titleformat{\section}[runin]
{\normalfont\bfseries\large}
{\S\ \thesection.}{0.0cm}{}[:]
\begin{document}
\section*{Section title}
Filler text \parencite{bertram,glashow,aksin}.
\printbibliography
\end{document}