我在 biblatex(使用 biber)中为 arXiv eprint 字段设置了自定义格式样式。但是,对于某些引文,这会导致内容超出页边距。例如,下面附加的 MWE 生成的参考书目将产生以下输出(使用 geometry 包显示页面尺寸):
如你所见,arXiv 标识符延伸到了页边距。它最终在第二点,而它可能应该在第一个连字符处断开。我尝试将\texttt
下面 MWE 中的调用替换为 tex.se 问题中定义的宏文本中的换行符但这也不起作用。换行符移到了斜线后面,但仍然在边距内。我怀疑这与(标记)扩展规则有关?
当我真正应该制作内容时,我花了太多时间尝试自己解决这个问题,所以我转向 tex.SE 寻求帮助 :-) 请在下面找到我的 MWE。
梅威瑟:
\RequirePackage{filecontents}
\begin{filecontents}{bib.bib}
@article{dummy,
author = {A. Author},
title = {Title},
note = {a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z},
}
@article{2010arXiv1010.0632D,
author = {{D'Agostini}, G.},
title = "{Improved iterative Bayesian unfolding}",
archivePrefix = "arXiv",
eprint = {1010.0632},
primaryClass = "physics.data-an",
year = 2010,
month = 10,
}
\end{filecontents}
\documentclass{scrbook}
\usepackage[showframe]{geometry}
\usepackage[
hyperref=true,
backend=biber,
style=numeric-comp, % Sort and compress
backref=true, % Print Backreferences
backrefstyle=three, % start combining pages after third page
sorting=none, % Do not sort!
firstinits=true, % First and Middle names as initials
maxbibnames=3, % Maximum number of authors to print in Bibliography
]{biblatex}
% Hide certain fields
\AtEveryBibitem{
\clearfield{issn}
\clearfield{month}
\ifentrytype{book}{}{
\clearfield{isbn}
}
}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{\textit{#1}}
\DeclareFieldFormat
{year}{\mkbibbold{#1}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{month}{\mkbibbold{#1}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{day}{\mkbibbold{#1}}
\DeclareFieldFormat
{date}{\mkbibbold{#1}}
\renewbibmacro{in:}{%
\ifentrytype{article}{%
}{%
\printtext{\bibstring{in}\intitlepunct}%
}%
}
\makeatletter
\DeclareFieldFormat{eprint:arxiv}{%
{\small\texttt{arXiv}\addcolon}\space%
\href{http://arxiv.org/\abx@arxivpath/#1}{%
\iffieldundef{eprintclass}{}{
\texttt{\thefield{eprintclass}/}%
}\nolinkurl{#1}%
}%
}%
\makeatother
%% links and hyperref
\usepackage{url}
%% hypertexnames=false is required(?) by autonum package but makes
%% pagerefs (e.g. backref etc.) point to the wrong page.
\usepackage[%linktocpage=true,
final,
pdftex,
bookmarks=true,
colorlinks]{hyperref}
\bibliography{bib}
\begin{document}
Test \cite{dummy} \cite{2010arXiv1010.0632D}
\printbibliography
\end{document}
答案1
也可\nolinkurl
用于钻头\thefield{eprintclass}/
\makeatletter
\DeclareFieldFormat{eprint:arxiv}{%
{\small\texttt{arXiv}\addcolon}\space%
\href{https://arxiv.org/\abx@arxivpath/#1}{%
\iffieldundef{eprintclass}
{}
{\nolinkurl{\thefield{eprintclass}/}}%
\nolinkurl{#1}}}
\makeatother
换行很难 在\texttt
,但\nolinkurl
做得很好。
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{dummy,
author = {A. Author},
title = {Title},
note = {a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z},
}
@article{2010arXiv1010.0632D,
author = {{D'Agostini}, G.},
title = "{Improved iterative Bayesian unfolding}",
archivePrefix = "arXiv",
eprint = {1010.0632},
primaryClass = "physics.data-an",
year = 2010,
month = 10,
}
\end{filecontents}
\documentclass{scrbook}
\usepackage[showframe]{geometry}
\usepackage[
hyperref=true,
backend=biber,
style=numeric-comp, % Sort and compress
backref=true, % Print Backreferences
backrefstyle=three, % start combining pages after third page
sorting=none, % Do not sort!
firstinits=true, % First and Middle names as initials
maxbibnames=3, % Maximum number of authors to print in Bibliography
]{biblatex}
% Hide certain fields
\AtEveryBibitem{
\clearfield{issn}
\clearfield{month}
\ifentrytype{book}{}{
\clearfield{isbn}
}
}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{\textit{#1}}
\DeclareFieldFormat
{year}{\mkbibbold{#1}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{month}{\mkbibbold{#1}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{day}{\mkbibbold{#1}}
\DeclareFieldFormat
{date}{\mkbibbold{#1}}
\renewbibmacro{in:}{%
\ifentrytype{article}{%
}{%
\printtext{\bibstring{in}\intitlepunct}%
}%
}
\makeatletter
\DeclareFieldFormat{eprint:arxiv}{%
{\small\texttt{arXiv}\addcolon}\space%
\href{https://arxiv.org/\abx@arxivpath/#1}{%
\iffieldundef{eprintclass}
{}
{\nolinkurl{\thefield{eprintclass}/}}%
\nolinkurl{#1}}}
\makeatother
%% links and hyperref
\usepackage{url}
%% hypertexnames=false is required(?) by autonum package but makes
%% pagerefs (e.g. backref etc.) point to the wrong page.
\usepackage[%linktocpage=true,
final,
pdftex,
bookmarks=true,
colorlinks]{hyperref}
\bibliography{\jobname}
\begin{document}
Test \cite{dummy} \cite{2010arXiv1010.0632D}
\printbibliography
\end{document}