Biblatex,前缀数字的使用改变了所有子书目的缩进

Biblatex,前缀数字的使用改变了所有子书目的缩进

我的三个子书目有问题。我使用了两种样式:数字和字母。在其中一个子书目中,我想使用前缀数字。不幸的是,这也会影响其他两个子书目,因为边距会根据前缀数字的长度而移动。这是我的问题的 MWE。

  \documentclass[a4paper,oneside]{article}

  \usepackage{filecontents}
  \begin{filecontents*}{bib.bib}
  @Article{aksin,
    author       = {Aks{\i}n, {\"O}zge and T{\"u}rkmen, Hayati and Artok, Levent
                    and {\k{C}}etinkaya, Bekir and Ni, Chaoying and
                    B{\"u}y{\"u}kg{\"u}ng{\"o}r, Orhan and {\"O}zkal, Erhan},
    title        = {Effect of immobilization on catalytic characteristics of
                    saturated Pd-N-heterocyclic carbenes in Mizoroki-Heck
                    reactions},
    journaltitle = jomch,
    date         = 2006,
    volume       = 691,
    number       = 13,
    pages        = {3027-3036},
    indextitle   = {Effect of immobilization on catalytic characteristics},
  }

  @Article{angenendt,
    author       = {Angenendt, Arnold},
    title        = {In Honore Salvatoris~-- Vom Sinn und Unsinn der
                    Patrozinienkunde},
    journaltitle = {Revue d'Histoire Eccl{\'e}siastique},
    date         = 2002,
    volume       = 97,
    pages        = {431--456, 791--823},
    hyphenation  = {ngerman},
    indextitle   = {In Honore Salvatoris},
    shorttitle   = {In Honore Salvatoris},
    annotation   = {A German article in a French journal. Apart from that, a
                    typical \texttt{article} entry. Note the \texttt{indextitle}
                    field},
  }

  @Article{baez/article,
    author       = {Baez, John C. and Lauda, Aaron D.},
    title        = {Higher-Dimensional Algebra V: 2-Groups},
    journaltitle = {Theory and Applications of Categories},
    date         = 2004,
    volume       = 12,
    pages        = {423-491},
    version      = 3,
    eprint       = {math/0307200v3},
    eprinttype   = {arxiv},
    hyphenation  = {english},
    annotation   = {An \texttt{article} with \texttt{eprint} and
                    \texttt{eprinttype} fields. Note that the arXiv reference is
                    transformed into a clickable link if \texttt{hyperref} support
                    has been enabled.  Compare \texttt{baez\slash online}, which
                    is the same item given as an \texttt{online} entry},
  }
  \end{filecontents*}


  \usepackage[T1]{fontenc}

  \usepackage[polish,ngerman,english]{babel}
  \usepackage[babel,german=quotes]{csquotes}
  \usepackage[style=numeric,sorting=none,defernumbers,labelalpha,babel=other,backend=biber]{biblatex}
  \addbibresource{bib.bib}

  \DeclareBibliographyCategory{student_works}
  \DeclareBibliographyCategory{own_pubs}
  \addtocategory{student_works}{angenendt}
  \addtocategory{own_pubs}{baez/article}


  \DeclareCiteCommand{\cite}[\mkbibbrackets]
    {\usebibmacro{prenote}}
     {\ifcategory{student_works}
       {{\usebibmacro{citeindex}%
           \printtext[bibhyperref]{%
             \printfield{prefixnumber}%
             \printfield{labelalpha}}}}
       {{\usebibmacro{citeindex}%
           \printtext[bibhyperref]{%
             \printfield{prefixnumber}%
             \printfield{labelnumber}}}}}%
    {\multicitedelim}%
    {\usebibmacro{postnote}}%


  \defbibenvironment{student_works_env}
    {\list
       {\printtext[labelalphawidth]{%
        \printfield{prefixnumber}%
         \printfield{labelalpha}}}
       {\setlength{\labelwidth}{\labelalphawidth}%
        \setlength{\leftmargin}{\labelwidth}%
        \setlength{\labelsep}{\biblabelsep}%
        \addtolength{\leftmargin}{\labelsep}%
        \setlength{\itemsep}{\bibitemsep}%
        \setlength{\parsep}{\bibparsep}}%
        \renewcommand*{\makelabel}[1]{\hss##1}}
    {\endlist}
    {\item}
  \DeclareFieldFormat{labelalphawidth}{\mkbibbrackets{#1}}


  \begin{document}

  \cite{aksin}
  \cite{angenendt}
  \cite{baez/article}

  \printbibliography[notcategory=student_works,notcategory=own_pubs,heading=bibintoc]

  \printbibliography[title=Second Bib,category=student_works,heading=bibintoc,sorting=ynt,env=student_works_env]

  \printbibliography[title=Third Bib,category=own_pubs,heading=bibintoc,sorting=ynt,prefixnumbers={VERYLONGPREFIX--}]

  \end{document}

结果如下 在此处输入图片描述

我将不胜感激任何帮助!

答案1

biblatex3.11 引入了locallabelwdith计算标签宽度的选项,不是全局计算所有条目的标签宽度,而是分别计算每个条目的标签宽度\printbibliography。另请参阅重置不同书目中的标签和条目之间的间距

biblatex我们最终得到了针对 3.11 的代码。

\documentclass[a4paper,oneside]{article}
\usepackage[T1]{fontenc}
\usepackage[polish,ngerman,english]{babel}
\usepackage[babel,german=quotes]{csquotes}
\usepackage[style=numeric,sorting=none,defernumbers,labelalpha,backend=biber,locallabelwidth]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareBibliographyCategory{student_works}
\DeclareBibliographyCategory{own_pubs}
\addtocategory{student_works}{angenendt}
\addtocategory{own_pubs}{baez/article}


\DeclareCiteCommand{\cite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
   {\ifcategory{student_works}
     {\usebibmacro{citeindex}%
      \printtext[bibhyperref]{%
        \printfield{labelprefix}%
        \printfield{labelalpha}%
        \printfield{extraalpha}}}
     {\usebibmacro{citeindex}%
      \printtext[bibhyperref]{%
        \printfield{labelprefix}%
        \printfield{labelnumber}}}}%
  {\multicitedelim}%
  {\usebibmacro{postnote}}%


\defbibenvironment{student_works_env}
  {\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]{\hss##1}}
  {\endlist}
  {\item}
\DeclareFieldFormat{labelalphawidth}{\mkbibbrackets{#1}}


\begin{document}
\cite{aksin}
\cite{angenendt}
\cite{baez/article}

\printbibliography[notcategory=student_works,notcategory=own_pubs,heading=bibintoc]

\newrefcontext[sorting=ynt]
\printbibliography[title=Second Bib,category=student_works,heading=bibintoc,env=student_works_env]

\newrefcontext[sorting=ynt,labelprefix={VERYLONGPREFIX--}]
\printbibliography[title=Third Bib,category=own_pubs,heading=bibintoc]
\end{document}

所有参考书目的左边距都是不同的。

答案2

正如@Audrey 所说,设置\labelwidth不同\labelalphawidth\labelnumberwidth允许修复条目的缩进。

以下设置\labelwidth通常足以满足标准标签的要求,但在某些情况下可能需要手动调整:

输出

  \documentclass[a4paper,oneside]{article}

  \usepackage{filecontents}
  \begin{filecontents*}{bib.bib}
  @Article{aksin,
    author       = {Aks{\i}n, {\"O}zge and T{\"u}rkmen, Hayati and Artok, Levent
                    and {\k{C}}etinkaya, Bekir and Ni, Chaoying and
                    B{\"u}y{\"u}kg{\"u}ng{\"o}r, Orhan and {\"O}zkal, Erhan},
    title        = {Effect of immobilization on catalytic characteristics of
                    saturated Pd-N-heterocyclic carbenes in Mizoroki-Heck
                    reactions},
    journaltitle = jomch,
    date         = 2006,
    volume       = 691,
    number       = 13,
    pages        = {3027-3036},
    indextitle   = {Effect of immobilization on catalytic characteristics},
  }

  @Article{angenendt,
    author       = {Angenendt, Arnold},
    title        = {In Honore Salvatoris~-- Vom Sinn und Unsinn der
                    Patrozinienkunde},
    journaltitle = {Revue d'Histoire Eccl{\'e}siastique},
    date         = 2002,
    volume       = 97,
    pages        = {431--456, 791--823},
    hyphenation  = {ngerman},
    indextitle   = {In Honore Salvatoris},
    shorttitle   = {In Honore Salvatoris},
    annotation   = {A German article in a French journal. Apart from that, a
                    typical \texttt{article} entry. Note the \texttt{indextitle}
                    field},
  }

  @Article{baez/article,
    author       = {Baez, John C. and Lauda, Aaron D.},
    title        = {Higher-Dimensional Algebra V: 2-Groups},
    journaltitle = {Theory and Applications of Categories},
    date         = 2004,
    volume       = 12,
    pages        = {423-491},
    version      = 3,
    eprint       = {math/0307200v3},
    eprinttype   = {arxiv},
    hyphenation  = {english},
    annotation   = {An \texttt{article} with \texttt{eprint} and
                    \texttt{eprinttype} fields. Note that the arXiv reference is
                    transformed into a clickable link if \texttt{hyperref} support
                    has been enabled.  Compare \texttt{baez\slash online}, which
                    is the same item given as an \texttt{online} entry},
  }
  \end{filecontents*}


  \usepackage[T1]{fontenc}

  \usepackage[polish,ngerman,english]{babel}
  \usepackage[babel,german=quotes]{csquotes}
  \usepackage[style=numeric,sorting=none,defernumbers,labelalpha,babel=other,backend=biber]{biblatex}
  \addbibresource{bib.bib}

  \DeclareBibliographyCategory{student_works}
  \DeclareBibliographyCategory{own_pubs}
  \addtocategory{student_works}{angenendt}
  \addtocategory{own_pubs}{baez/article}


  \DeclareCiteCommand{\cite}[\mkbibbrackets]
    {\usebibmacro{prenote}}
     {\ifcategory{student_works}
       {{\usebibmacro{citeindex}%
           \printtext[bibhyperref]{%
             \printfield{prefixnumber}%
             \printfield{labelalpha}}}}
       {{\usebibmacro{citeindex}%
           \printtext[bibhyperref]{%
             \printfield{prefixnumber}%
             \printfield{labelnumber}}}}}%
    {\multicitedelim}%
    {\usebibmacro{postnote}}%


  \defbibenvironment{student_works_env}
    {\list
       {\printtext[labelalphawidth]{%
        \printfield{prefixnumber}%
         \printfield{labelalpha}}}
       {\settowidth{\labelwidth}{Www8888}%
        %\setlength{\labelwidth}{\labelalphawidth}%
        \setlength{\leftmargin}{\labelwidth}%
        \setlength{\labelsep}{\biblabelsep}%
        \addtolength{\leftmargin}{\labelsep}%
        \setlength{\itemsep}{\bibitemsep}%
        \setlength{\parsep}{\bibparsep}}%
        \renewcommand*{\makelabel}[1]{\hss##1}}
    {\endlist}
    {\item}
  \DeclareFieldFormat{labelalphawidth}{\mkbibbrackets{#1}}

    \defbibenvironment{bibnumeric}
        {\list
            {\printtext[labelnumberwidth]{%
                \printfield{prefixnumber}%
                \printfield{labelnumber}}}
            { \settowidth{\labelwidth}{8888}%
                %\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}


  \begin{document}

  \cite{aksin}
  \cite{angenendt}
  \cite{baez/article}

  \printbibliography[notcategory=student_works,notcategory=own_pubs,heading=bibintoc,env=bibnumeric]

  \printbibliography[title=Second Bib,category=student_works,heading=bibintoc,sorting=ynt,env=student_works_env]

  \printbibliography[title=Third Bib,category=own_pubs,heading=bibintoc,sorting=ynt,prefixnumbers={VERYLONGPREFIX--}]

  \end{document}

相关内容