
私の文書の 1 つの参照セクションでは、参照がキーワードによってカテゴリにグループ化されています。次に、引用のカテゴリに基づいて各セクションの参考文献を印刷します。たとえば、キーワードを含む記事の参考文献 1 つとin
、キーワードを含む参考文献 1 つなどout
です。見た目を良くするために、このテキスト モックアップのように、参考文献に連続番号を付けます。
**In**
[1-1] a. “a”. In: a (a).
[1-2] c. “c”. In: c (c).
[1-3] e. “e”. In: e (e).
**Out**
[1-4] b. “b”. In: b (b).
[1-5] d. “d”. In: d (d).
したがって、私はdefernumbers
の を使用してbiblatex
エントリに連続して番号を付けます。問題は、これにより、すべての に対して番号が再び 1 から始まることになることです\printbibliography
。
全体defernumbers
にわたって有効にしたいと思います。\printbibliography
\refsection
ムウェ
\documentclass{article}
\pagestyle{empty}
\usepackage{filecontents}
\begin{filecontents*}{test.bib}
@article{a,
title = {a},
author = {a},
journal = {a},
year = {a},
keywords = {in}
}
@article{b,
title = {b},
author = {b},
journal = {b},
year = {b},
keywords = {out}
}
@article{c,
title = {c},
author = {c},
journal = {c},
year = {c},
keywords = {in}
}
@article{d,
title = {d},
author = {d},
journal = {d},
year = {d},
keywords = {out}
}
@article{e,
title = {e},
author = {e},
journal = {e},
year = {e},
keywords = {in}
}
\end{filecontents*}
\usepackage[
defernumbers=true,
citestyle=numeric,
]{biblatex}
\defbibheading{subbibliography}[\bibname]{%
\subsubsection*{#1}
}
\addbibresource{test.bib}
\begin{document}
\section{Testing biblatex}
\refsection
\cite{a,b,c,d,e}
\printbibliography[
title={In},
prefixnumbers={\thesection-},
heading=subbibliography,
keyword=in
]
\printbibliography[
title={Out},
prefixnumbers={\thesection-},
heading=subbibliography,
keyword=out
]
\endrefsection
\section{Testing biblatex}
\refsection
\cite{a,b,c,d,e}
\printbibliography[
title={In},
prefixnumbers={\thesection-},
heading=subbibliography,
keyword=in
]
\printbibliography[
title={Out},
prefixnumbers={\thesection-},
heading=subbibliography,
keyword=out
]
\endrefsection
\end{document}
出力
もちろん賞金もご用意しております!
答え1
この問題は、の固有の機能から生じますbiblatex
。その他の質問には、ラベルにプレフィックスを追加するためにを使用するとき適用されるbiblatex
暗黙の があります。 これはさまざまな方法で対処できますが、問題をわずかに変更するか、プレフィックスの処理/適用方法を変更するハックを通じてのみ対処できます。resetnumbers=true
prefixnumbers
この質問の目的は、各参考文献をセクション(または章など)ごとに細分化することなので、設定をprefixnumber
別の方法でグローバルに適用し、resetnumbers=true
各 に暗黙的に適用される を排除することが可能です\printbibliography
。そのためには、ラベルの印刷方法を再定義し、\thesection
次の形式に組み込みます。
\DeclareFieldFormat{labelnumber}{\mkbibsecnum{#1}}
\newrobustcmd{\mkbibsecnum}[1]{\thesection-#1\relax}
各ラベルは 1、2、3... として保存されますが、印刷されるときには、そのラベルが表示されるセクション番号でフォーマットされます。(注*: このようにプレフィックスを追加しているため、コマンドは引用と\printbibliography
同じsection
/に表示される必要があります。特に、この方法を使用して、複数のs を で分割してrefsection
最後に累積的な参考文献を印刷することはできません)。refsection
\printbibliography[section=1...]
refsection
この時点で、残っているのは、 を使用して適切なポイント (各 の最初の参考文献) で番号をリセットすることだけです\printbibliography[...resetnumbers=true]
。
結果
結果は次のようになります:
ムウェ
オリジナルの MWE よりもソリューションを効率的にするために、いくつか変更を加えました。
refsection=section
...=part
( 、なども可...=chapter
) は、各セクション内の参照のみを収集するために にグローバルに渡されます。これを必要に応じて/biblatex
に置き換えて、参考文献項目を手動で分割することができます。\newrefsection
\endrefsection
defernumbers=true
各サブ書誌を順番に並べ替えるために保持されます。
また、番号とrefsection
s の効果を強調するために、いくつかの引用をコメント アウトしました。
このソリューションを示す修正された MWE:
\documentclass{article}
\pagestyle{empty}
\usepackage{filecontents}
\begin{filecontents*}{test.bib}
@article{a,
title = {a},
author = {a},
journal = {a},
year = {a},
keywords = {in}
}
@article{b,
title = {b},
author = {b},
journal = {b},
year = {b},
keywords = {out}
}
@article{c,
title = {c},
author = {c},
journal = {c},
year = {c},
keywords = {in}
}
@article{d,
title = {d},
author = {d},
journal = {d},
year = {d},
keywords = {out}
}
@article{e,
title = {e},
author = {e},
journal = {e},
year = {e},
keywords = {in}
}
\end{filecontents*}
\usepackage[
defernumbers=true,
citestyle=numeric,
refsection=section % Each \section{...} starts a new refsection environment
]{biblatex}
% Format the labelnumber with \thesection prefix
\DeclareFieldFormat{labelnumber}{\mkbibsecnum{#1}}
\newrobustcmd{\mkbibsecnum}[1]{\thesection-#1\relax}
\defbibheading{subbibliography}[\bibname]{%
\subsubsection*{#1}
}
\addbibresource{test.bib}
\begin{document}
\section{Testing biblatex} % New refsection, too!
Cite a \cite{a};
Cite b \cite{b};
Cite c \cite{c};
\printbibliography[
title={In},
heading=subbibliography,
keyword=in,
resetnumbers=true % The first bibliography in each refsection needs its numbers manually reset
]
\printbibliography[
title={Out},
heading=subbibliography,
keyword=out
]
\section{Testing biblatex} % New refsection, too!
Cite b \cite{b};
Cite d \cite{d};
Cite e \cite{e}.
\printbibliography[
title={In},
heading=subbibliography,
keyword=in,
resetnumbers=true % The first bibliography in each refsection needs its numbers manually reset
]
\printbibliography[
title={Out},
heading=subbibliography,
keyword=out
]
\end{document}
*@Guido の解決策参考文献環境全体を再定義し、列挙シリーズ カウンターを使用して、特定のラベルのカウントを継続しますが、他のラベルのカウントは継続しません。これはこの問題には有効かもしれません (累積参考文献の問題も修正されます) が、OP が要求した方法でセクション番号を付けてコードをコンパイルすることはできませんでした。