我正在用 LaTeX 写论文。我使用 IEEE 样式来引用。我一直使用 \begin{refsection}\end{refsection} 来使用 biblatex 和 biber 为每个章节生成参考书目。
我可能会在每一章中引用一本教科书,但页码范围不同。如果我在 bib 文件中为每一章创建 Author2000 的重复条目并使用正确的页码,我可以获得所需的行为,但这似乎是错误的做法。我认为有一种方法可以使用 postnotes 并重新定义 \cite 命令来实现,但我无法从论坛或手册中找到一种简单的方法来做到这一点。
以下是 MWE:
\documentclass{report}
\begin{filecontents}{\jobname.bib}
@BOOK{Author2000,
author = {Some Author},
title = {Name of a Book},
year = {2000},
publisher = {Oxford University Press},
address = {Oxford},
}
\end{filecontents}
\usepackage[backend=biber,style=ieee]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\begin{refsection}
\chapter{Introduction}
{\textbackslash}cite[10]\{Author2000\} produces this: \cite[10]{Author2000}, but I would like something like [1] here. In the bibliography, I would like p. 10 to be appended after the reference in the bibliography.
\printbibliography
\end{refsection}
\chapter{Overview}
\begin{refsection}
{\textbackslash}cite[20-30]\{Author2000\} produces this: \cite[20-30]{Author2000}, but I would like something like [1] here. {\textbackslash}cite[40-50]\{Author2000\} produces this: \cite[40-50]{Author2000}, but I would like something like [1] here. In the bibliography, I would like pp. 20-30, 40-50 to be appended after the reference in the bibliography.
\printbibliography
\end{refsection}
\end{document}
答案1
这是一个解决方案,可以收集您的后记并在最后的参考书目中打印它们。
解决方案非常简单。它不会对页面引用进行排序,也不会尝试压缩它们或删除重复的页面。
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=ieee, autocite=plain]{biblatex}
\makeatletter
\renewbibmacro{postnote}{%
\iffieldundef{postnote}
{}
{\ifcsundef{jwcbx@postnotestorage@\the\value{refsection}%
@\thefield{entrykey}}
{\csxdef{jwcbx@postnotestorage@\the\value{refsection}%
@\thefield{entrykey}}{\expandonce\abx@field@postnote}}
{\csxappto{jwcbx@postnotestorage@\the\value{refsection}@%
\thefield{entrykey}}
{, \expandonce\abx@field@postnote}}}}
\newcommand*{\jwcbx@printpostnote}{\printtext[postnote]}
\renewbibmacro*{finentry}{%
\ifcsundef{jwcbx@postnotestorage@\the\value{refsection}@%
\thefield{entrykey}}
{}
{\expandafter\expandafter\expandafter
\jwcbx@printpostnote
\expandafter\expandafter\expandafter{%
\csname jwcbx@postnotestorage@\the\value{refsection}@%
\thefield{entrykey}\endcsname}}%
\finentry
}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\begin{refsection}
Lorem \autocite[380]{sigfridsson}
ipsum \autocite[381]{sigfridsson}
\printbibliography
\end{refsection}
\begin{refsection}
Lorem \autocite[380]{sigfridsson}
\printbibliography
\end{refsection}
\end{document}
答案2
作为临时解决方法,我通过在每章开头添加显示该参考文献页码范围的命令来使该行为能够正常工作。这是 MWE。如果我能找到一种方法让 \cite 的后记执行此操作,而不是让自定义命令 \bibnote 执行此操作,那就太好了:
% Credit to: https://tex.stackexchange.com/questions/612501/how-to-remove-unwanted-period-in-biblatex-reference-list-after-using-finentry?rq=1
\documentclass{report}
\begin{filecontents}{\jobname.bib}
@BOOK{Author2000,
author = {Some Author},
title = {Name of a Book},
year = {2000},
publisher = {Oxford University Press},
address = {Oxford},
}
\end{filecontents}
\usepackage[backend=biber,style=ieee, natbib=true]{biblatex}
\addbibresource{\jobname.bib}
\newcommand{\bibnote}[2]{\csdef{cbx@#1@bibnote}{#2}}
\renewbibmacro*{finentry}{%
\ifcsundef{cbx@\thefield{entrykey}@bibnote}
{}
{ {\csuse{cbx@\thefield{entrykey}@bibnote}}}%
\finentry
}
\begin{document}
\begin{refsection}
\bibnote{Author2000}{p. 10}
\chapter{Introduction}
{\textbackslash}cite[10]\{Author2000\} produces this: \cite[10]{Author2000}.
\printbibliography
\end{refsection}
\chapter{Overview}
\begin{refsection}
\bibnote{Author2000}{pp. 20-30, 40-50}
{\textbackslash}cite\{Author2000\} produces this: \cite{Author2000}. {\textbackslash}cite\{Author2000\} produces this: \cite{Author2000}.
\printbibliography
\end{refsection}
\end{document}