私は論文のために biblatex と biber を使用しています。複数のサブエントリを持つためにセットを使用します。
1 つのセットの複数のサブエントリ (例: a と b) を参照する場合、[1a,b] のような出力を希望しますが、代わりに [1a,1b] が返されます。
これを解決する方法はありますか?また、[1a-c]のようなものはありますか?
\RequirePackage{filecontents}
\begin{filecontents}{test.bib}
@article{author1,
journal = {journal},
year = {1999},
author = {author1},
}
@article{author2,
journal = {journal},
year = {1999},
author = {author2},
}
@article{author3,
journal = {journal},
year = {1999},
author = {author3},
}
\end{filecontents}
\documentclass[12pt,a4paper, headinclude=true, titlepage=true,DIV=12,oneside,BCOR=1cm, numbers=noendperiod, toc=bib, chapterprefix=true]{scrreprt}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[backend=biber,citestyle=numeric-comp,bibstyle=chem-angew,mcite=true,subentry,pageranges=true,sorting=none,citetracker]{biblatex}
\addbibresource{my_refs.bib}
\usepackage[ngerman,KeepShorthandsActive]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\addbibresource{test.bib}
\begin{document}
Here I cite a reference with several subentries.\defbibentryset{set1}{author1,author2,author3}\supercite{set1} Somewhere later, I want to refer to some of the subentries.\supercite{author1,author2}
\printbibliography
\end{document}
答え1
アップデート
biblatex
3.15以降、スタイルにはサブエントリ参照も圧縮するオプション (デフォルトで有効)numeric-comp
が付属しています。subentrycomp
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[backend=biber, style=numeric-comp, subentry]{biblatex}
\begin{filecontents}{\jobname.bib}
@article{author1,
journal = {journal},
year = {1999},
author = {author1},
}
@article{author2,
journal = {journal},
year = {1999},
author = {author2},
}
@article{author3,
journal = {journal},
year = {1999},
author = {author3},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\supercite{sigfridsson}
Here I cite a reference with several subentries.\defbibentryset{set1}{author1,author2,author3}\supercite{set1} Somewhere later, I want to refer to some of the subentries.\supercite{author1,author3}
Lorem\supercite{author1,author2}
ipsum\supercite{author1,author2,author3}
ipsum\supercite{vizedom:related}
ipsum\supercite{author1,author2,author3}
ipsum\supercite{author1,author2,author3,vizedom:related,sigfridsson}
ipsum\supercite{author1,author2,author3,vizedom:related,sigfridsson}
ipsum\supercite{author1,author3,vizedom:related,sigfridsson}
ipsum\supercite{author1,author2,vizedom:related,sigfridsson}
ipsum\supercite{author1,vizedom:related,sigfridsson}
ipsum\supercite{author3,vizedom:related,sigfridsson}
ipsum\supercite{set1,vizedom:related,sigfridsson}
\printbibliography
\end{document}
「1a、b、c」のソリューションはそれほど複雑ではありません。cite:comp:inset
最後のものlabelnumber
が同じかどうかを確認するために、少しだけ再定義する必要があります。
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{author1,
journal = {journal},
year = {1999},
author = {author1},
}
@article{author2,
journal = {journal},
year = {1999},
author = {author2},
}
@article{author3,
journal = {journal},
year = {1999},
author = {author3},
}
\end{filecontents}
\documentclass[12pt,a4paper, headinclude=true, titlepage=true,DIV=12,oneside,BCOR=1cm, numbers=noendperiod, toc=bib, chapterprefix=true]{scrreprt}
\usepackage[ngerman,KeepShorthandsActive]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[backend=biber, citestyle=numeric-comp, bibstyle=chem-angew, mcite=true, subentry, pageranges=true, sorting=none, citetracker]{biblatex}
\addbibresource{\jobname.bib}
\makeatletter
\renewbibmacro*{cite:comp:inset}{%
\usebibmacro{cite:dump}%
\ifnumgreater{\value{cbx@tempcntb}}{-1}
{\multicitedelim}
{}%
\printtext[bibhyperref]{%
\iffieldequals{labelnumber}{\cbx@lastnumber}
{}
{\printfield{labelprefix}%
\printfield{labelnumber}}%
\printfield{entrysetcount}}%
\savefield{labelnumber}{\cbx@lastnumber}%
\setcounter{cbx@tempcntb}{-1}}
\makeatother
\begin{document}
Here I cite a reference with several subentries.\defbibentryset{set1}{author1,author2,author3}\supercite{set1} Somewhere later, I want to refer to some of the subentries.\supercite{author1,author2,author3}
\printbibliography
\end{document}
さらに作業すれば、「1a-c」も取得できます。次のソリューションは、エントリnumeric-comp
のマクロを再作成します@set
。このソリューションは、概念的な美しさよりも短いコードに最適化されています。
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{author1,
journal = {journal},
year = {1999},
author = {author1},
}
@article{author2,
journal = {journal},
year = {1999},
author = {author2},
}
@article{author3,
journal = {journal},
year = {1999},
author = {author3},
}
\end{filecontents}
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[backend=biber, citestyle=numeric-comp, bibstyle=chem-angew, mcite=true, subentry, pageranges=true, sorting=none, citetracker]{biblatex}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\makeatletter
% the first two counters are already defined in numeric-comp.cbx
% cbx@tempcnta % no. of labelnumbers we skipped
% cbx@tempcntb % 'predicted' labelnumber for current cite
\newcounter{cbx@tempcntc}% no. of entrysetcounts we skipped
\newcounter{cbx@tempcntd}% 'predicted' entrysetcount
\renewbibmacro*{cite:init}{%
\global\boolfalse{cbx:parens}%
\global\undef\cbx@lasthash
\global\undef\cbx@lastnumber
\global\undef\cbx@lastprefix
\global\undef\cbx@lastcount
\setcounter{cbx@tempcnta}{0}%
\setcounter{cbx@tempcntb}{-2}%
\setcounter{cbx@tempcntc}{0}%
\setcounter{cbx@tempcntd}{-1}}
\newcommand*{\cbx@iflabelnumberequalslast}{%
\iffieldequals{labelnumber}{\cbx@lastnumber}}
% \iffieldequals is false even if both are empty/undef
% so we need a special test for that case
% this test is optimised for performance and laziness
% rather than prettiness, not that it would matter a lot...
\newcommand*{\cbx@iflabelprefixequalslast}{%
\ifundef\cbx@lastprefix
{\iffieldundef{labelprefix}
{\@firstoftwo}
{\@secondoftwo}}
{\iffieldequals{labelprefix}{\cbx@lastprefix}
{\@firstoftwo}
{\@secondoftwo}}}
% \cbx@iflabelnumberequalslast and \cbx@iflabelprefixequalslast
\newcommand*{\cbx@iflabelequalslast}{%
\iffieldequals{labelnumber}{\cbx@lastnumber}
{\cbx@iflabelprefixequalslast
{\@firstoftwo}
{\@secondoftwo}}
{\@secondoftwo}}
\renewbibmacro*{cite:comp:inset}{%
\stepcounter{cbx@tempcntd}%
% the calls for false \cbx@iflabelequalslast
% are split between stuff that happens before
% the link and that happens within the link
\cbx@iflabelequalslast
{}
{\usebibmacro{cite:dump}%
\ifnumgreater{\value{cbx@tempcntb}}{-1}
{\multicitedelim}
{}}%
\printtext[bibhyperref]{%
\cbx@iflabelequalslast
{}
{\setcounter{cbx@tempcntd}{-1}%
\printfield{labelprefix}%
\printfield{labelnumber}%
\savefield{labelprefix}{\cbx@lastprefix}%
\savefield{labelnumber}{\cbx@lastnumber}}%
\ifnumequal{\thefield{entrysetcount}}{\value{cbx@tempcntd}}
{\savefield{entrykey}{\cbx@lastkey}%
\savefield{entrysetcount}{\cbx@lastcount}%
\stepcounter{cbx@tempcntc}}
{\usebibmacro{cite:dump}%
\ifnumgreater{\value{cbx@tempcntd}}{0}
{\multicitedelim}
{}%
\printfield{entrysetcount}}}%
\setcounter{cbx@tempcntd}{\thefield{entrysetcount}}%
\setcounter{cbx@tempcntb}{-1}}
\renewbibmacro*{cite:dump}{%
% dump subentry
\ifnumgreater{\value{cbx@tempcntc}}{0}
{\ifnumgreater{\value{cbx@tempcntc}}{1}
{\bibrangedash}
{\multicitedelim}%
\bibhyperref[\cbx@lastkey]{%
\printtext[entrysetcount]{\cbx@lastcount}}}
{}%
\setcounter{cbx@tempcntc}{0}%
% dump labelnumber (+labelprefix)
\ifnumgreater{\value{cbx@tempcnta}}{0}
{\ifnumgreater{\value{cbx@tempcnta}}{1}
{\bibrangedash}
{\multicitedelim}%
\bibhyperref[\cbx@lastkey]{%
\ifdef\cbx@lastprefix
{\printtext[labelprefix]{\cbx@lastprefix}}
{}%
\printtext[labelnumber]{\cbx@lastnumber}}%
\global\undef\cbx@lastprefix}
{}%
\setcounter{cbx@tempcnta}{0}}
\makeatother
\begin{document}
\supercite{sigfridsson}
Here I cite a reference with several subentries.\defbibentryset{set1}{author1,author2,author3}\supercite{set1} Somewhere later, I want to refer to some of the subentries.\supercite{author1,author3}
Lorem\supercite{author1,author2}
ipsum\supercite{author1,author2,author3}
ipsum\supercite{vizedom:related}
ipsum\supercite{author1,author2,author3}
ipsum\supercite{author1,author2,author3,vizedom:related,sigfridsson}
ipsum\supercite{author1,author2,author3,vizedom:related,sigfridsson}
ipsum\supercite{author1,author3,vizedom:related,sigfridsson}
ipsum\supercite{author1,author2,vizedom:related,sigfridsson}
ipsum\supercite{author1,vizedom:related,sigfridsson}
ipsum\supercite{author3,vizedom:related,sigfridsson}
ipsum\supercite{set1,vizedom:related,sigfridsson}
\printbibliography
\end{document}
編集以下の問題を修正しましたアンディWの質問Biblatex でセット メンバーの引用を圧縮する。