![使用 biblatex 和 backref=true 時將章節中的頁面進行分組](https://rvso.com/image/298812/%E4%BD%BF%E7%94%A8%20biblatex%20%E5%92%8C%20backref%3Dtrue%20%E6%99%82%E5%B0%87%E7%AB%A0%E7%AF%80%E4%B8%AD%E7%9A%84%E9%A0%81%E9%9D%A2%E9%80%B2%E8%A1%8C%E5%88%86%E7%B5%84.png)
我曾經etoolbox
在每個未加星號的章節中重置頁計數器,並且已更改\thepage
為列印章節號和頁碼:
\pretocmd{\@chapter}{\setcounter{page}{1}}{}{}
\renewcommand*{\thepage}{\thechapter-\arabic{page}}
除此之外,我還用來biblatex
列印部分參考書目(如果需要,在章節中)和全局參考書目(作為chapter*
最後的)。當一章的幾頁和不同章節中引用參考文獻時,backref
由於所選的頁碼格式(請參閱 MWE),該選項會列印出相當難看的結果。我想:
當使用該選項列印頁面時,將
biblatex
頁面分組為反向引用中的章節。[heading=bibliography]
使
biblatex
僅顯示反向引用中的清單頁(不含章節號),然後[heading=subbibliography]
使用選項來列印它。
在 MWE 的 backref 中,[ODO95]
我們顯示以下 backref:
在
page I
:[cit. on chapters 1 (pp. 1, 3), 2 (p. 1)]
在
page 1-3
:[cit. on pp. 1, 3]
;在
page 2-1
:[cit. on p. 1]
。
當對任何章節進行引用時,全域參考書目中的反向引用也應該顯示頁面。假設我們取消 MWE 中後面三行的註釋\begin{document}
,則 backrefpage I
將為[cit. on chapters 1 (pp. 1, 3), 2 (p. 1); and page i]
.
微量元素:
\documentclass[a4paper,titlepage,10pt,twoside,openright]{report}
\usepackage[backend=biber,style=ieee-alphabetic,natbib=true,backref=true]{biblatex}
\addbibresource{IEEEfull.bib}
\addbibresource{IEEEexample.bib}
\usepackage{lipsum}
\usepackage{etoolbox}
\makeatletter
\pretocmd{\@chapter}{\setcounter{page}{1}}{}{}
\makeatother
\begin{document}
%\renewcommand*{\thepage}{\roman{page}}
%\cite{IEEEexample:articledualmonths}
%\clearpage
\renewcommand*{\thepage}{\thechapter-\arabic{page}}
\chapter{Introduction}
\begin{refsegment}
\cite{IEEEexample:articledualmonths} \lipsum[1-10] \cite{IEEEexample:articledualmonths}
\printbibliography[segment=\therefsegment,heading=subbibliography]
\end{refsegment}
\chapter{Second chapter}
\begin{refsegment}
\cite{IEEEexample:articledualmonths}
\cite{IEEEexample:IEEEwebsite}
\nocite{IEEEexample:book_typical,IEEEexample:article_typical}
\printbibliography[segment=\therefsegment,heading=subbibliography]
\end{refsegment}
\cleardoublepage
\setcounter{page}{1}
\renewcommand*{\thepage}{\Roman{page}}
\printbibliography[heading=bibliography]
\end{document}
我讀過一些關於使用biblatex
[格式化反向引用的問題A,乙],但他們的目標不是改變清單的“內容”,只是改變格式。但是,我將其中一個答案作為實現這種格式的參考:
\newbibmacro*{pageref}{\iflistundef{pageref}{}
{\finentrypunct\addspace\renewcommand\finentrypunct{}%
\printtext[parens]{%
\ifnumgreater{\value{pageref}}{1}%
{\bibstring{backrefpages}\ppspace}%
{\bibstring{backrefpage}\ppspace}%
\printlist[pageref][-\value{listtotal}]{pageref}}}}
我相信內容是用 來顯示的\printlist[pageref][-\value{listtotal}]{pageref}
。我\DeclareListFormat
在 的文檔中讀到了有關它和相關的內容biblatex
。我覺得我應該聲明一種新的清單格式,但我不知道如何做,也不知道如何將內容輸入pageref
或從中讀取內容。
我問了另一個問題了解如何在[heading=subbibliography]
使用時僅顯示段內的反向引用,而不是顯示整個文件中的出現。
然而,如果\DeclareListFormat
必須描述一個新的答案,則可以合併兩個答案。
答案1
這很可能不是最好的形式,但它以問題所建議的形式起作用。雙項是仿製藥。
程式碼是註解。請讀一下。
微量元素:
\documentclass[a4paper,titlepage,10pt,twoside,openright]{report}
\begin{filecontents}{IEEEexample.bib}
@inBook{Wolff1962,
Title = {Philosophia prima sive Ontologia},
Author = {Wolff, Christian von},
Editor = {Jean Ecole},
Publisher = {Olms},
Address = {Hildesheim},
Year = {1962},
Part = {Abt. 2: Lateinische Schriften},
Maintitle = {Gesammelte Werke},
Volume = {3},
langid = {german}
}
@inBook{other1999,
Title = {The title in english},
Author = {Last, Name},
Editor = {Editor Name},
Publisher = {Springer},
Address = {New York},
Year = {1999},
Part = {1},
Maintitle = {The Maintitle},
Volume = {3},
}
@techreport{Natarajan2011,
author = {Natarajan, Nagarajan and Singh-Blom, Ulf Martin and Tewari, Ambuj and Woods, John O and Dhillon, Inderjit S and Marcotte, Edward M},
file = {:Users/jwoods/Downloads/Papers/Natarajan2011.pdf:pdf},
journal = {UTCS Technical Report},
title = {{Predicting gene\textendash disease associations using multiple species data.}},
volume = {TR-11-37},
year = {2011},
type = {techreport},
keywords = {Technical Report}}
@phdthesis{thesis000,
author = {Author Name},
title = {Title of the thesis},
type= {phdthesis},
year = {2011}}
\end{filecontents}
\usepackage[backend=biber,style=ieee-alphabetic,natbib=true,backref=true]{biblatex}
\addbibresource{IEEEexample.bib}
\usepackage{lipsum}
\makeatletter
\pretocmd{\@chapter}{\setcounter{page}{1}}{}{}
\makeatother
\DeclareListParser*{\forpageref}{-} %A parser for the newpage X-x X:chapter and x:the real page
\newcounter{cbcrfpg}% Counter for how many times is cited by chapter
\providetoggle{chorpg}% True: Chapter part (X). False: Page part (x) (chapter or page)
\providetoggle{ifbrefcchap}% if backref is into currentchapter
\togglefalse{ifbrefcchap}%
\newcounter{lastchap}% It is used in the whole bibliograpy. save the last chapter.
\setcounter{lastchap}{0}
\newcommand{\onlycurrentchapter}[1]{%
\iftoggle{chorpg}% %If is chapter part. (X)
{\ifnumequal{#1}{\value{chapter}} % if chapter part is equal to current chapter.
{\toggletrue{ifbrefcchap}% % True the backref into currentpage
\togglefalse{chorpg}}% % The next part will be page part (x)
{\togglefalse{ifbrefcchap}}% % else: False the backref into currentpage
}
{\iftoggle{ifbrefcchap} %If is page part and backref into currentpage
{\stepcounter{cbcrfpg}% % +1 counter of how many times is cited by chapter
\listgadd{\mylistofpages}{#1}}% % Add the page into a internal list.
{}}}
\DeclareListFormat{selectitemsforprint}{% A format for manage every element of backref list.
\toggletrue{chorpg}% This is used for select only the elements into current
\forpageref{\onlycurrentchapter}{#1}} % chapter.
\DeclareListFormat{printallitems}{% A format for manage every element of backref list.
\toggletrue{chorpg}% % This is used to classify the backref by chapters and print the
\forpageref{\printallitems}{#1}%% of the n-1 of total chapters (n).
}
\newcommand{\printallitems}[1]{%
\iftoggle{chorpg}% %If chapter part (X)
{\ifnumequal{\value{lastchap}}{#1}% %If the last chapter is equal to current chapter **
{}% %nothing
{\ifnumequal{\value{cbcrfpg}}{0} %if the last chapter is different to current chapter and
{} % if counter is zero: Nothing
{\printtext{\addspace\thelastchap\addspace}% % if different to zero: Prints!! 1. The chapter numbers
\usebibmacro{printitems}{parens}{pages}{page}% % And the items: it means page of the backref.
\setcounter{cbcrfpg}{0}\undef{\mylistofpages}}% % And restart the list of pages and counter
}%seimprimen
\setcounter{lastchap}{#1}% %Save the last chapter**
}
{\stepcounter{cbcrfpg}\listgadd{\mylistofpages}{#1}}% %If is page part: +1 counter and add to list of pages.
\togglefalse{chorpg}}%
%**(into backref list: exaple [1-1, 1-2] equals chapters)
\renewbibmacro*{pageref}{\iflistundef{pageref}{} %The new pageref bibmacro
{\setcounter{cbcrfpg}{0}\undef{\mylistofpages}\setcounter{lastchap}{0} % start list of pages, cunters and last chapter
\printunit{\adddot\space} % Print a dot
\ifnumequal{\value{refsegment}}{0} % If refsegment is zero, this means global bibliography
{\printtext[brackets]{\printtext{cite on \chaptername}% % Print the part: cite on chapter
\printlist[printallitems][-\value{listtotal}]{pageref}% % Find and Print the backref of all n-1 chapters
\printtext{\addspace\thelastchap\addspace}% % Print the backref of only n chapter***
\usebibmacro{printitems}{parens}{pages}{page}% %*** (not print fortwo below line)
}}
{\printlist[selectitemsforprint]{pageref} % If refsegment different to zero, is a internal bibliography
\usebibmacro{printitems}{brackets}{backrefpages}{backrefpage}}%
}}
\newbibmacro*{printitems}[3]{%
\printtext[#1]{% % Print into brackets
\ifnumgreater{\value{cbcrfpg}}{1}% % If counter greater to 1
{\bibstring{#2}} %Print cite #2 bibstring
{\bibstring{#3}} % else: %Print cite #2 bibstring
\forlistloop{\printtext\newunit}{\mylistofpages}}} %Print the listofpages items.using \printtext{\newunit\thepagepart}
\begin{document}
\renewcommand*{\thepage}{\thechapter-\arabic{page}}
\chapter{Introduction}
\begin{refsegment}
\cite{Wolff1962} \lipsum[1-10]
\cite{Wolff1962}
\printbibliography[segment=\therefsegment,heading=subbibliography]
\end{refsegment}
\chapter{Second chapter}
\begin{refsegment}
\cite{Wolff1962}
\cite{other1999}
\nocite{Natarajan2011,thesis000}
\printbibliography[segment=\therefsegment,heading=subbibliography]
\end{refsegment}
\cleardoublepage
\setcounter{page}{1}
\renewcommand*{\thepage}{\Roman{page}}
\printbibliography[heading=bibliography]
\end{document}
圖片
page 1-3
。
page 2-1
。
page I
。