如何在 biblatex 中创建自定义样式?

如何在 biblatex 中创建自定义样式?

我在 Windows 11 上使用 texstudio。我必须在报告中使用ama样式。我已经有了样式bibliographyama这里。缺少的是数字引用,引用中的数字必须是上标。我想准备参考书目,例如带有上标数字引用。我无法使用ama.bst已经可用的bibtex,因为我必须在参考书目中划分,例如articleswebsources。请告诉我如何获得上标数字引用。我尝试通过组合执行以下操作,但出现错误。除了 matlab 之外,我不懂编码。

\documentclass[12pt,abstract = true,toc = flat,toc = bib]{scrreprt}
\usepackage[english]{babel}
\usepackage[hidelinks]{hyperref}
\usepackage{url}


\usepackage[backend=biber, style=authoryear, bibstyle=authortitle, maxcitenames=2, maxbibnames=99, isbn=false, natbib = true, firstinits=true, uniquename=false, uniquelist=false, terseinits,citestyle=numeric-comp,labeldateparts]{biblatex}
\addbibresource{example.bib}
\begin{filecontents}{example.bib}
    @article{baillie_deliver_2021,
        title = {A Long url},
        url = {https://www.hydrocarbonprocessing.com/magazine/2021/september-2021/catalysts/deliver-high-levels-of-sox-reduction-with-sox-reduction-additive},
        journal = {this url goes out of margin},
        author = {Test},
        month = march,
        year = {2022},
    },
    @article{responsetoukaraniancrisis,
        title = {BAPS Responds to Ukrainian Humanitarian Crisis, Poland},
        url = {https://www.baps.org/Photos/2022/Emergency-Response-in-Rzesz243w-Poland-24266.aspx?mid=226449},
        journal = {BAPS News UK and Europe},
        author = {BAPS},
        month = march,
        year = {2022}
    }
\DeclareNameAlias{sortname}{last-first}
\renewcommand*{\revsdnamepunct}{}
\newrobustcmd{\mkbibsubscript}[1]{%
    \unspace\allowhyphens\textsubscript{%
        \begingroup
        \protected\long\def\mkbibsuperscript##1{%
            \blx@warning{Nested superscript}%
            \mkbibbrackets{##1}}%
        #1\endgroup}}

\DeclareCiteCommand{\subcite}[\mkbibsubscript]
{\usebibmacro{cite:init}%
    \let\multicitedelim=\supercitedelim
    \iffieldundef{prenote}
    {}
    {\BibliographyWarning{Ignoring prenote argument}}%
    \iffieldundef{postnote}
    {}
    {\BibliographyWarning{Ignoring postnote argument}}}
{\usebibmacro{citeindex}%
    \usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}}
%
\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother

\DeclareFieldFormat[article,inbook,incollection,inproceedings,patent,thesis,unpublished]{title}{{#1\isdot}}
\renewbibmacro{in:}{}
\DeclareFieldFormat{pages}{#1}
\renewcommand*{\bibpagespunct}{\addcolon}

% Normal title font (remove italic)
\DeclareFieldFormat{journaltitle}{#1\addperiod}
\DeclareFieldFormat{booktitle}{{#1}}
\DeclareFieldFormat{title}{{#1}}

% Year after title
\renewbibmacro*{journal+issuetitle}{%
    \usebibmacro{journal}%
    \setunit*{\addspace}%
    \iffieldundef{series}
    {}
    {\newunit
        \printfield{series}%
        \setunit{\addspace}}%
    \usebibmacro{issue+date}%
    \setunit{\addsemicolon\addspace}%
    \usebibmacro{volume+number+eid}%
    \setunit{\addcolon\space}%
    \usebibmacro{issue}%
    \newunit%
}

\newrobustcmd{\mkbibsubscript}[1]{%
    \unspace\allowhyphens\textsubscript{%
        \begingroup
        \protected\long\def\mkbibsuperscript##1{%
            \blx@warning{Nested superscript}%
            \mkbibbrackets{##1}}%
        #1\endgroup}}

\DeclareCiteCommand{\subcite}[\mkbibsubscript]
{\usebibmacro{cite:init}%
    \let\multicitedelim=\supercitedelim
    \iffieldundef{prenote}
    {}
    {\BibliographyWarning{Ignoring prenote argument}}%
    \iffieldundef{postnote}
    {}
    {\BibliographyWarning{Ignoring postnote argument}}}
{\usebibmacro{citeindex}%
    \usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}}


% Print only the year
\renewbibmacro*{issue+date}{%
    \printfield{year}%
}

% Remove "and" from list of authors
\renewcommand*{\finalnamedelim}{\multinamedelim}    
\end{filecontents}
\begin{document}
    \supercite{responsetoukaraniancrisis}
    \nocite{*}
    \printbibliography
\end{document}

URL我需要以下内容:请从所有内容(如网络资源、书籍等)中删除,一词In:。期刊或网站的标题必须为斜体,但期刊标题和年份之间必须有句号和空格。如果 URL 太长而无法进入页边距,我如何防止 URL 从当前行开始并将其放在下一行。

我们可以通过回答中的问题轻松地bst在中创建自定义样式即文件。有没有类似的方法可以在中创建自定义样式?bibtexlatex makebstbiblatex

答案1

以下是使用 的数字 AMA 样式biblatex。请注意,如果您想将论文提交给期刊,则不太可能使用biblatex。大多数期刊使用经典的基于 BibTeX 的方法。接受 LaTeX 提交的期刊通常有模板或至少关于如何准备手稿的作者指南。biblatex可能仅在明确推荐的情况下才受支持。

我没有在这里讨论 URL 中断问题,因为这在其他地方已经讨论过了,例如biblatex 书目中的长 URL 的换行符?如何拆分过长的 URL并且更普遍地如何调整参考书目的断行?

\documentclass[12pt,abstract = true,toc = flat,toc = bib]{scrreprt}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage[
  backend=biber,
  natbib = true,
  style=ext-numeric-comp,
  sorting=none,
  minbibnames=3, maxbibnames=6,
  uniquename=false, uniquelist=false,
  giveninits=true, terseinits,
  articlein=false, innamebeforetitle=true,
  isbn=false,
  urldate=long, dateabbrev=false,
  autocite=superscript,
]{biblatex}
\usepackage[hidelinks]{hyperref}

\DeclareNameAlias{sortname}{family-given}

\DeclareNameAlias{author}{sortname}
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}

\renewcommand*{\revsdnamepunct}{}
\DeclareDelimAlias{finalnamedelim}{multinamedelim}

\DeclareFieldFormat
  [article,inbook,incollection,inproceedings,patent,thesis,unpublished]
  {title}{#1}

\renewbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\addspace}%
  \iffieldundef{series}
    {}
    {\newunit
     \printfield{series}%
     \setunit{\addspace}}%
  \usebibmacro{issue+date}%
  \setunit{\addsemicolon\addspace}%
  \usebibmacro{volume+number+eid}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}}

\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}
\renewcommand*{\volnumdelim}{}

\renewbibmacro*{issue+date}{%
  \usebibmacro{date}}

\renewbibmacro*{pubinstorg+location+date}[1]{%
  \printlist{location}%
  \iflistundef{#1}
    {\setunit*{\addsemicolon\space}}
    {\setunit*{\addcolon\space}}%
  \printlist{#1}%
  \setunit*{\addsemicolon\space}%
  \usebibmacro{date}%
  \newunit}

\renewcommand*{\bibpagespunct}{\addcolon}
\DeclareFieldFormat{pages}{#1}

\DeclareFieldFormat{doi}{%
  doi\addcolon\space
  \ifhyperref
    {\href{https://doi.org/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}

\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}
\newbibmacro*{url+urldate}{%
  \usebibmacro{url}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\addperiod\space}%
     \usebibmacro{urldate}}}

\DefineBibliographyStrings{english}{
  urlseen = {accessed},
}


\begin{filecontents}[force]{\jobname.bib}
@article{baillie_deliver_2021,
  title   = {A Long url},
  url     = {https://www.hydrocarbonprocessing.com/magazine/2021/september-2021/catalysts/deliver-high-levels-of-sox-reduction-with-sox-reduction-additive},
  urldate = {2022-03-12},
  journal = {this url goes out of margin},
  author  = {Test},
  year    = {2022},
}
@article{responsetoukaraniancrisis,
  title   = {BAPS Responds to Ukrainian Humanitarian Crisis, Poland},
  url     = {https://www.baps.org/Photos/2022/Emergency-Response-in-Rzesz243w-Poland-24266.aspx?mid=226449},
  journal = {BAPS News UK and Europe},
  author  = {BAPS},
  year    = {2022},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
  \autocite{responsetoukaraniancrisis,baillie_deliver_2021,
    sigfridsson,worman,nussbaum,companion,westfahl:space}
  \printbibliography
\end{document}

Sigfridsson E, Ryde U. 从电势和电势矩推导原子电荷的方法比较。《计算化学杂志》1998;19(4):377–395。doi: 10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P。

相关内容