答えはモーウェ質問に対してBiblatex: スタイルと並び順が異なる 2 つの書誌numeric-comp
ほぼ私が達成したいことです。文書内のエントリ数が多いため、ではなくスタイルを使用したいと思いますnumeric
。どうすればこれを実現できますか?
拡張 MWE:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{biblatextest1.bib}
@BOOK{BookA03,
author = {Author Aaa},
title = {Some Title},
publisher = {Some Publisher},
year = 2003,
}
@BOOK{BookB02,
author = {Author Bbb},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB09,
author = {Author Jjj},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB10,
author = {Author Kkk},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB11,
author = {Author Lll},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
\end{filecontents}
\begin{filecontents}{biblatextest2.bib}
@MISC{LinkC04,
author = {Author Ccc},
title = {Some Title},
year = 2004,
url = {www.test1.com/bild.jpg},
}
@MISC{LinkD01,
author = {Author Ddd},
title = {Some Title},
year = 2001,
url = {www.test2.com/bild.jpg},
}
@MISC{LinkD05,
author = {Author Eee},
title = {Some Title},
year = 2004,
url = {www.test3.com/bild.jpg},
}
@MISC{LinkD06,
author = {Author Fff},
title = {Some Title},
year = 2001,
url = {www.test4.com/bild.jpg},
}
@MISC{LinkD07,
author = {Author Ggg},
title = {Some Title},
year = 2004,
url = {www.test5.com/bild.jpg},
}
@MISC{LinkD08,
author = {Author Hhh},
title = {Some Title},
year = 2001,
url = {www.test6.com/bild.jpg},
}
\end{filecontents}
\usepackage[style = alphabetic, labelnumber, defernumbers = true, backend = biber]{biblatex}
\addbibresource{biblatextest1.bib}
\addbibresource{biblatextest2.bib}
\usepackage{hyperref}
%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{biblatextest1.bib}
\step[fieldset=KEYWORDS, fieldvalue=primary, append]
}
\map{
\perdatasource{biblatextest2.bib}
\step[fieldset=KEYWORDS, fieldvalue=secondary, append]
}
}
}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\renewbibmacro*{cite}{%
\printtext[bibhyperref]{%
\printfield{labelprefix}%
\ifkeyword{secondary}
{\printfield{labelnumber}}
{\printfield{labelalpha}%
\printfield{extraalpha}}}}
\defbibenvironment{bibliographyNUM}
{\list
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\assignrefcontextkeyws[sorting=none]{secondary}
\begin{document}
The first two citations \cite{LinkD07,LinkC04} and \cite{BookB10,BookB11,BookB02,BookB09}.
The others are \cite{LinkD08,LinkD01,LinkD05,LinkD06} and \cite{BookA03}.
\printbibliography[title=Bibliography, keyword=primary]
\newrefcontext[sorting=none]
\printbibliography[env=bibliographyNUM,title=References, keyword=secondary, resetnumbers]
\end{document}
ご協力をよろしくお願いいたします。
答え1
と に基づいて、フィールドに情報numeric-comp
を持ち込もうとすることで、何とか目的を達成できたと思います。この情報は によってネイティブに処理されるため、マクロ/コマンドを再定義する必要はありません。labelalpha
shorthand
numeric-comp
cite
最初はソースマップでこれを実行しようとしましたが、どういうわけかうまくいかなかったので、最終的には を使用しました\AtEveryCitekey
。
おそらく、ソートの調整はまだ必要になるでしょう。また、一次参考文献と二次参考文献の混在した引用は理想的とは言えないことにも気づくでしょう (この場合、何がソート引用を決定しているのかはわかりませんでした)。しかし、全体的な結果は妥当に見えます。
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{biblatextest1.bib}
@BOOK{BookA03,
author = {Author Aaa},
title = {Some Title},
publisher = {Some Publisher},
year = 2003,
}
@BOOK{BookB02,
author = {Author Bbb},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB09,
author = {Author Jjj},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB10,
author = {Author Kkk},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB11,
author = {Author Lll},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
\end{filecontents}
\begin{filecontents}{biblatextest2.bib}
@MISC{LinkC04,
author = {Author Ccc},
title = {Some Title},
year = 2004,
url = {www.test1.com/bild.jpg},
}
@MISC{LinkD01,
author = {Author Ddd},
title = {Some Title},
year = 2001,
url = {www.test2.com/bild.jpg},
}
@MISC{LinkD05,
author = {Author Eee},
title = {Some Title},
year = 2004,
url = {www.test3.com/bild.jpg},
}
@MISC{LinkD06,
author = {Author Fff},
title = {Some Title},
year = 2001,
url = {www.test4.com/bild.jpg},
}
@MISC{LinkD07,
author = {Author Ggg},
title = {Some Title},
year = 2004,
url = {www.test5.com/bild.jpg},
}
@MISC{LinkD08,
author = {Author Hhh},
title = {Some Title},
year = 2001,
url = {www.test6.com/bild.jpg},
}
\end{filecontents}
\usepackage[style = numeric-comp, labelalpha, defernumbers]{biblatex}
\addbibresource{biblatextest1.bib}
\addbibresource{biblatextest2.bib}
\usepackage{hyperref}
%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{biblatextest1.bib}
\step[fieldset=KEYWORDS, fieldvalue=primary]
}
\map{
\perdatasource{biblatextest2.bib}
\step[fieldset=KEYWORDS, fieldvalue=secondary]
}
}
}
\makeatletter
\newcommand*{\labelalphatoshorthand}{\csdef{abx@field@shorthand}{\strfield{labelprefix}\strfield{labelalpha}\strfield{extraalpha}}}
\makeatother
\AtEveryCitekey{\ifkeyword{primary}{\labelalphatoshorthand}{}}
\DeclareFieldFormat{labelalphawidth}{\mkbibbrackets{#1}}
\defbibenvironment{bibliographyALPHA}
{\list
{\printtext[labelalphawidth]{%
\printfield{labelprefix}%
\printfield{labelalpha}%
\printfield{extraalpha}}}
{\setlength{\labelwidth}{\labelalphawidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{##1\hss}}
{\endlist}
{\item}
\begin{document}
The first two citations \cite{LinkD07,LinkC04} and
\cite{BookB10,BookB11,BookB02,BookB09}.
Mixing both primary and secondary
\cite{LinkD08,LinkD01,LinkD05,LinkD06,BookB10,BookB11,BookB02,BookB09}.
The others are \cite{LinkD08,LinkD01,LinkD05,LinkD06,LinkD07}
and \cite{BookA03}.
\printbibliography[env=bibliographyALPHA, title=Bibliography, keyword=primary]
\newrefcontext
\printbibliography[title=References, keyword=secondary, resetnumbers]
\end{document}
話題から外れますが、手順append
から指示を削除したことにご注意くださいDeclareSourcemap
。追加するというアイデアは良いものです。しかし、キーワードを含むフィールドが 1 つありmykeyword
、primary
それに追加するとします。mykeywordprimary
は でもmykeyword
なく でもないためprimary
、参考文献を分離するためのキーワード ベースのメカニズムは失敗します (実際には参考文献のエントリが欠落します)。そのため、これを行うには、キーワードの間にカンマを含め、フィールドが空かどうかなどを処理する必要があります。