biblatex:标题和作者将被切换,并且后面会用换行符代替标点符号

biblatex:标题和作者将被切换,并且后面会用换行符代替标点符号

以下 MWE 解释了我想要获得的内容:

\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
%
\begin{filecontents*}{\jobname.bib}
@Book{            knuth1984,
  edition       = {1},
  title         = {The TeXbook},
  isbn          = {9780201134483},
  publisher     = {Addison Wesley},
  author        = {Knuth, Donald E.},
  date          = {1984-01-01}
}
\end{filecontents*}
%
\addbibresource{\jobname.bib}
\nocite{*}
%
\begin{document}
\begin{itemize}
\item \verb|\fullcite{knuth1984}| gives:\par
  \fullcite{knuth1984}
\item I'd like to give:

  \citetitle{knuth1984}\\
  Donald E. Knuth\\
  1st ed. Addison Wesley, Jan. 1, 1984. \textsc{isbn}: 9780201134483
\end{itemize}
\end{document}

也就是说,我想要\fullcite

  • 切换标题和作者:虽然我可以通过重新定义整个来实现这一点\DeclareBibliographyDriver{book},但我想用xpatch's实现相同的结果\xpatchbibdriver,但我的所有尝试都失败了,
  • 用换行符替换标题和作者后的标点符号。使用\renewcommand*{\newunitpunct}{\newline},我可以替换全部单位标点用换行符表示,但我只希望将其用于标题和作者。

对于后一点,我的所有尝试\newbibmacro* titlemaintitle+title等等都失败了,例如:

\xpatchbibmacro{maintitle+title}{%
  \newunit
}{%
  \setunit{\par\nobreak}
}{success}{failure}
%
\xpatchbibmacro{title}{%
  \newunit
}{%
  \setunit{\par\nobreak}
}{success}{failure}

因此我的问题是:我该如何修补biblatex的默认样式以获得所需的结果?

答案1

这里是:

\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
%
\usepackage{xpatch}

\xpatchbibdriver{book}{%
 \usebibmacro{author/editor+others/translator+others}%
 \setunit{\labelnamepunct}\newblock
 \usebibmacro{maintitle+title}%
 \newunit
 }
 {%
 \usebibmacro{maintitle+title}
 \newline\nopunct\newblock
 \usebibmacro{author/editor+others/translator+others}%
 \setunit{\labelnamepunct}
 }{}{}


 \xpatchbibdriver{book}{%
 \newunit\newblock
 \printfield{edition}%
 }{%
 \newline\nopunct\newblock
 \printfield{edition}%
 }{}{}

\begin{filecontents*}{\jobname.bib}
@Book{ knuth1984,
 edition = {1},
  title = {The TeXbook},
  isbn = {9780201134483},
  publisher = {Addison Wesley},
  author = {Knuth, Donald E.},
  date = {1984-01-01}
}
\end{filecontents*}
%
\addbibresource{\jobname.bib}
\nocite{*}
%
\begin{document}

\begin{itemize}
\item \verb|\fullcite{knuth1984}| gives:\par
  \fullcite{knuth1984}
\item I'd like to give:

  \citetitle{knuth1984}\\
  Donald E. Knuth\\
  1st ed. Addison Wesley, Jan. 1, 1984. \textsc{isbn}: 9780201134483
\end{itemize}

\end{document} 

在此处输入图片描述

相关内容