defbibenvironment 使用字母代替数字

defbibenvironment 使用字母代替数字

我想在论文末尾打印一份出版物清单。我找到了以下解决方案在 stackexchange 上:在“真正的”参考书目之后,我把

\defbibenvironment{mypubs}
 {\list
 {}
 {\setlength{\leftmargin}{\bibhang}%
  \setlength{\itemindent}{-\leftmargin}%
  \setlength{\itemsep}{\bibitemsep}%
  \setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}

\begin{refsection}[mypubs.bib]
        \nocite{keyA,keyB,keyC}  
        \printbibliography[env=mypubs,title=List of Publications]
\end{refsection}

这将创建一个单独的参考书目,并删除出版物前面的 [1]、[2]、[3]、...。这很接近但不是我想要的。我需要如何更改 bibenvironment 才能将 [A]、[B]、[C]... 放在出版物前面,而不是 [1]、[2]、[3]...?

答案1

如果你不打算引用你自己的出版物(这似乎是因为你把它们限制在了 arefsection中),你可以使用enumerate修改后的enumitem

\usepackage{enumitem}

\defbibenvironment{mypubs}
  {\enumerate[label={[\Alph*]}]
     {}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endenumerate}
  {\item}

总共

\documentclass{article}
\usepackage{enumitem}
\usepackage[style=numeric,backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\defbibenvironment{mypubs}
  {\enumerate[label={[\Alph*]}]
     {}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endenumerate}
  {\item}

\begin{document}
\cite{sigfridsson}
\printbibliography

\begin{refsection}[biblatex-examples.bib]
  \nocite{knuth:ct:a,knuth:ct:b,knuth:ct:c}  
  \printbibliography[env=mypubs,title=List of Publications]
\end{refsection}
\end{document}

或者,您可以用关键词标记您的条目。然后,您可以随时更改引用格式。

\documentclass{article}
\usepackage{enumitem}
\usepackage[style=numeric,backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{bronto,
  author   = {Anne Elk},
  title    = {Towards a Unified Theory on Brontosauruses},
  date     = {1972-11-16},
  url      = {http://example.edu/~elk/bronto.pdf},
  urldate  = {2015-09-07},
  keywords = {mine},
}
@online{tric,
  title    = {A Theory on Triceratops},
  author   = {Anne Elk},
  date     = {1972-11-16},
  url      = {https://example.edu/~elk/tric.html#page11},
  urldate  = {2015-09-07},
  keywords = {mine},
}
\end{filecontents*}
\addbibresource{biblatex-examples.bib}

\makeatletter
\newrobustcmd*{\mknumAlph}[1]{%
  \begingroup
  \blx@tempcnta=#1\relax
  \ifnum\blx@tempcnta>702 %
  \else
    \ifnum\blx@tempcnta>26 %
      \advance\blx@tempcnta\m@ne
      \divide\blx@tempcnta26\relax
      \blx@numalph\blx@tempcnta
      \multiply\blx@tempcnta26\relax
      \blx@tempcnta=\numexpr#1-\blx@tempcnta\relax
    \fi
  \fi
  \blx@numAlph\blx@tempcnta
  \endgroup}
\def\blx@numAlph#1{%
  \ifcase#1\relax\blx@warning@entry{Value out of range}\number#1\or
  A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
  N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\else
  \blx@warning@entry{Value out of range}\number#1\fi}
\makeatother

\DeclareFieldFormat{labelnumber}{\ifkeyword{mine}{\mknumAlph{#1}}{#1}}

\begin{document}
\cite{sigfridsson}
\printbibliography

\begin{refsection}[\jobname.bib]
  \nocite{*}  
  \printbibliography[title=List of Publications]
\end{refsection}
\end{document}

相关内容