如何格式化 BibTeX 中的 DOI 字段?

如何格式化 BibTeX 中的 DOI 字段?

我想将单词格式化doi\textsc{DOI} 就像在现场url一样

如何实现这一点?

梅威瑟:

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@dataset{Thomas2021,
    doi = {10.17632/wj6s2d8xbg.2},
    year = {2021},
    publisher = {Mendeley Data},
    author = {S. Thomas},
    title = {Finite Periodic Topology Optimization with Oriented Unit-cells Data Set},
    note = {V2},
    url = {https://data.mendeley.com/datasets/wj6s2d8xbg/2},
    urldate = {2022-02-16},
}
\end{filecontents}


\documentclass{scrbook}


\usepackage{biblatex}
\addbibresource{mybib.bib}
\DeclareFieldFormat{doi}{%
    \textsc{DOI}\addcolon\space   % <--- This doesn't work
    \ifhyperref
        {\href{http://doi.org/\detokenize{#1}}{\detokenize{#1}}}
        \space
}
\usepackage{hyperref}


\begin{document}

\nocite{*}   % Even non-cited BibTeX entries will be shown
\printbibliography[title={Bibliography}]

\end{document}

答案1

使用小写字母来获得小型大写字母:

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@dataset{Thomas2021,
    doi = {10.17632/wj6s2d8xbg.2},
    year = {2021},
    publisher = {Mendeley Data},
    author = {S. Thomas},
    title = {Finite Periodic Topology Optimization with Oriented Unit-cells Data Set},
    note = {V2},
    url = {https://data.mendeley.com/datasets/wj6s2d8xbg/2},
    urldate = {2022-02-16},
}
\end{filecontents}


\documentclass{scrbook}


\usepackage{biblatex}
\addbibresource{mybib.bib}
\DeclareFieldFormat{doi}{%
    \textsc{doi}\addcolon\space   % <--- doi instead of DOI
    \ifhyperref
        {\href{http://doi.org/\detokenize{#1}}{\detokenize{#1}}}
        \space
}
\usepackage{hyperref}


\begin{document}

\nocite{*}   % Even non-cited BibTeX entries will be shown
\printbibliography[title={Bibliography}]

\end{document}

在此处输入图片描述

相关内容