編輯

編輯

我正在嘗試使用 biblatex 產生兩個不同的參考書目。第一個應該只包含我的論文,按文本中出現的順序排序,並帶有一些特殊的前綴。第二個參考書目應包含一般參考文獻,按不同的順序排序(例如,名稱-標題-年份),並且沒有特殊前綴。

請注意,兩個參考書目不相交(即它們沒有共同的條目)。

我用這個MTW:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{ref.bib}
@ARTICLE{Pub1,
  author = {A. R},
  title = {My best paper},
  year = {2013},
  journal = C,
  keywords = {publication}
}

@ARTICLE{Pub2,
  author = {A. R},
  title = {My second best paper},
  year = {2013},
  journal = C,
  keywords = {publication}
}

@ARTICLE{Nopub1,
  author = {A. R},
  title = {Not my paper 1},
  year = {2012},
  journal = I,
  keywords = {general}
}

@ARTICLE{Nopub2,
  author = {A. R},
  title = {Not my paper 2},
  year = {2012},
  journal = I,
  keywords = {general}
}

\end{filecontents}

\usepackage[style=numeric, sorting=none, defernumbers=true, backend=biber]{biblatex}


\addbibresource{ref.bib}

\pagestyle{empty}

\begin{document}

This is my first publication : \cite{Pub1}

These are not my publications: \cite{Nopub1,Nopub2}

This is my second publication: \cite{Pub2}


\printbibliography[keyword=publication, prefixnumbers=R, title=My papers]

\begin{refcontext}[sorting=nty]
\printbibliography[notkeyword=publication, prefixnumbers=, title=Not my papers]
\end{refcontext}

\end{document}

輸出(pdflatex + biber + pdflatex + pdflatex 之後):

在此輸入影像描述

兩個參考書目都打印正確且順序良好,但引用第二個參考書目的文本引用是錯誤的(它們都是 [0])。我嘗試查看其他相關帖子,但沒有人提到這個具體問題。

謝謝!

答案1

我認為目前還沒有一個好的解決方案。但我會嘗試解釋一些背景。在您的範例中,所需的輸出看起來很明顯,因為您的兩個參考書目不重疊。但情況並非必須如此。在不同的引用上下文中,條目可以重複。那麼讓我們看看如果刪除過濾器會發生什麼:

\documentclass{article}

\usepackage[style=numeric, sorting=none,   backend=biber]{biblatex}

\addbibresource{ref.bib}

\pagestyle{empty}

\begin{document}

This is my first publication : \cite{Pub1}

These are not my publications: \cite{Nopub1,Nopub2}

This is my second publication: \cite{Pub2}

\printbibliography[title=Not my papers]

\newrefcontext[sorting=nty]
This is my first publication: \cite{Pub1}

These are not my publications: \cite{Nopub1,Nopub2}

This is my second publication: \cite{Pub2}

\printbibliography[prefixnumbers=R,title=My papers]

\end{document}

在此輸入影像描述

正如您所看到的,每個 bibentry 都有兩個標籤,biblatex 必須選擇使用哪一個。明智地,它對第一個區塊引用來自第一個(預設)refcontext 的標籤,對第二個區塊使用來自第二個區塊的標籤。

這解釋了為什麼你得到零:在第一個區塊中,引用沒有標籤,並且 biblatex 沒有機會猜測你想要來自另一個 refcontext 的標籤作為後備 - 畢竟可能有多個合適的標籤。

biblatex 將用於引用的標籤取決於 的當前值\blx@refcontext@sorting。因此,您可以透過執行下列操作在本機上強制 biblatex 使用另一個 refcontext 中的標籤

{
 \makeatletter\def\blx@refcontext@sorting{nty}
 These are not my publications: \cite{Nopub1,Nopub2}
} 

然後你可以得到這樣的東西:

在此輸入影像描述

但此解決方案不適用於混合引用,例如\cite{Nopub1,pub1}.以及“合乎邏輯”的解決方案

 \AtEveryCitekey{\ifkeyword{puplication}{}{\def\blx@refcontext@sorting{nty}}}

也不起作用,因為 refcontext 的程式碼是在 \AtEveryCitekey 啟動之前執行的。

編輯

你可以試試這個。但請注意:這是一個 hack,它很可能會混淆 biblatex。因此,請使用更多數據仔細測試和檢查。

\documentclass{article}

\usepackage[style=numeric, sorting=none, defernumbers,  backend=biber]{biblatex}

\addbibresource{ref.bib}

\pagestyle{empty}

\makeatletter
\AtEveryCitekey{\ifkeyword{publication}{}{\def\blx@refcontext@sorting{nty}%
   \csname blx@data@\the \c@refsection @\blx@refcontext@sorting @\abx@field@entrykey\endcsname}}
\makeatother
\begin{document}

This is my first publication : \cite{Pub1}

These are not my publications: \cite{Nopub1,Nopub2}

This is my second publication: \cite{Pub2}


\printbibliography[keyword=publication, prefixnumbers=R, title=My papers]

\begin{refcontext}[sorting=nty]
\printbibliography[notkeyword=publication, prefixnumbers=, title=Not my papers]
\end{refcontext}

\end{document}

答案2

refcontexts 是為這類事情引入的 - refcontexts 中的引用命令共享上下文,因此將“這些不是我的出版物:”引用放在同一個 refcontext 中。

\assignrefcontextentries[sorting=nty]{Nopub1,Nopub2}
\begin{document}

This is my first publication: \cite{Pub1}
These are not my publications: \cite{Nopub1,Nopub2}
This is my second publication: \cite{Pub2}

\printbibliography[keyword=publication, prefixnumbers=R, title=My papers]

\begin{refcontext}[sorting=nty]
\printbibliography[notkeyword=publication, title=Not my papers]
\end{refcontext}

\end{document}

這需要 biblatex 3.3

答案3

問題來自於使用不同的refcontext.如果刪除refcontext第二個周圍的環境printbibliography,您將獲得所需的輸出。

相關內容