biblatex 中带有 abnt-numeric 样式的方括号

biblatex 中带有 abnt-numeric 样式的方括号

我在自定义 biblatex 中的 abnt-numeric 样式时遇到了一些问题。我几乎已经设置好了所有需要设置的内容,但我想在引用和参考书目中的数字周围使用方括号。

\documentclass[12pt,
    article,
    english,
    a4paper,
    oneside,
    ]{abntex2}
\usepackage[backend=biber,style=abnt-numeric,isbn=false,doi=false,url=false,maxnames=100,sorting=none]{biblatex}
\addbibresource{library.bib}
\begin{document}
I want this citation to show with square brackets instead of parenthesis \cite{Vergnano2015}, as well as this one \textcite{Ericson2005}.

I also want the bibliography numbers, in the "REFERENCES" section, around square brackets.
\printbibliography[title=REFERENCES]
\end{document}

其中“library.bib”包含:

@book{Ericson2005,
address = {Hoboken, NJ, USA},
author = {Ericson, Clifton A.},
doi = {10.1002/0471739421},
file = {:C$\backslash$:/Users/Andre/Google Drive/UFABC/IC2/Artigos e livros leitura/Selecionados para SIMEA 2018/Ericson, 2005 - Hazard Analysis Techniques for System Safety.pdf:pdf},
isbn = {9780471739425},
month = {jul},
publisher = {John Wiley {\&} Sons, Inc.},
title = {{Hazard Analysis Techniques for System Safety}},
url = {http://doi.wiley.com/10.1002/0471739421},
year = {2005}
}
@article{Vergnano2015,
author = {Vergnano, Alberto and Berselli, Giovanni and Pellicciari, Marcello},
doi = {10.1007/s12008-015-0295-y},
file = {:C$\backslash$:/Users/Andre/Google Drive/UFABC/IC2/Artigos e livros/Vergnano, 2015 - Parametric virtual concepts in the early design of mechanical systems{\_} a case study application.pdf:pdf},
issn = {19552505 19552513},
journal = {International Journal on Interactive Design and Manufacturing},
keywords = {CAD based simulation,Design process,Vibrating screen,Virtual concepts,Virtual prototyping,virtual prototype},
mendeley-tags = {virtual prototype},
pages = {1--10},
title = {{Parametric virtual concepts in the early design of mechanical systems: a case study application}},
year = {2015}
}

有人能帮我一下吗?提前谢谢了!

答案1

由于的实现\textcite有点……在数字样式中(尤其是numeric-comp)冗长,改变它的代码量比人们预期的要大。

\documentclass[12pt,
    article,
    english,
    a4paper,
    oneside,
    ]{abntex2}
\usepackage[
  backend=biber,
  style=abnt-numeric,
  isbn=false,
  doi=false,
  url=false,
  maxnames=100,
  sorting=none,
]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareCiteCommand{\cite}[\mkbibbrackets]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}%
  {\iftoggle{comp}{}{\multicitedelim}}%
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}}%

\DeclareCiteCommand{\parencite}[\mkbibbrackets]%
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}%
  {\iftoggle{comp}{}{\multicitedelim}}%
  {\usebibmacro{cite:dump}%
\usebibmacro{postnote}}%

\makeatletter
  \renewbibmacro*{textcite}{% >>>3
    \iftoggle{comp}{%
      \iffieldequals{namehash}{\cbx@lasthash}%
        {\usebibmacro{cite:comp}}%
        {\usebibmacro{cite:dump}%
        \ifbool{cbx:parens}%
          {\printtext{\bibclosebracket}\global\boolfalse{cbx:parens}}%
          {}%
        \iffirstcitekey%
          {}%
          {\textcitedelim}%
        \usebibmacro{cite:init}%
        \printtext[bibhyperref]{%
          \ifnameundef{labelname}%
            {\printfield[citetitle]{labeltitle}}%
            {\printnames{labelname}}%
        }
        \setunit*{\printdelim{namelabeldelim}}%
        \printtext{\bibopenbracket}\global\booltrue{cbx:parens}%
        \ifnumequal{\value{citecount}}{1}%
          {\usebibmacro{prenote}}%
          {}%
        \usebibmacro{cite:comp}%
        \stepcounter{textcitecount}%
        \savefield{namehash}{\cbx@lasthash}}%
    }{%
      \iffieldequals{namehash}{\cbx@lasthash}%
            {\setunit{\multicitedelim}}%
            {\printtext[bibhyperref]{%
              \ifnameundef{labelname}%
                {\printfield[citetitle]{labeltitle}}%
                {\printnames{labelname}
             }}%
            \setunit*{\printdelim{namelabeldelim}}%
            \printtext{\bibopenbracket}\global\booltrue{cbx:parens}%
            \stepcounter{textcitecount}%
            \savefield{namehash}{\cbx@lasthash}}%
          \ifnumequal{\value{citecount}}{1}%
            {\usebibmacro{prenote}}%
            {}%
          \usebibmacro{cite}%
          \setunit{%
            \ifbool{cbx:parens}%
              {\bibclosebracket\global\boolfalse{cbx:parens}}%
              {}%
            \textcitedelim}%
    }%
}%

  \renewbibmacro*{textcite:postnote}{%
    \usebibmacro{postnote}%
    \ifthenelse{\value{multicitecount}=\value{multicitetotal}}%
      {\setunit{}%
      \printtext{%
        \ifbool{cbx:parens}%
          {\bibclosebracket\global\boolfalse{cbx:parens}}%
          {}}}%
      {\setunit{%
        \ifbool{cbx:parens}%
          {\bibclosebracket\global\boolfalse{cbx:parens}}%
          {}%
        \textcitedelim}}}%

  \DeclareCiteCommand{\cbx@textcite}%
    {\iftoggle{comp}{\usebibmacro{cite:init}}{\usebibmacro{textcite:init}}}%
    {\usebibmacro{citeindex}%
    \usebibmacro{textcite}}%
    {}%
    {\iftoggle{comp}{%
      \usebibmacro{cite:dump}%
          \usebibmacro{postnote}%
          \ifbool{cbx:parens}%
            {\bibclosebracket\global\boolfalse{cbx:parens}}%
            {}%
    }{%
      \usebibmacro{textcite:postnote}%
}}%
\makeatother

\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}

\begin{document}
I want this citation to show with square brackets instead of parenthesis \cite{sigfridsson},
as well as this one \textcite{worman}.

\printbibliography
\end{document}

这是用和/abnt-numeric.cbx替换\mkbibparens的代码。\mkbibbrackets\bibopenparen\bibcloseparen\bibopenbracket\bibclosebracket

在此处输入图片描述

相关内容