我试图确保参考书目条目保持在页面边缘内。但令人恼火的是,我有时会收到这样的条目,其中 DOI 超出了边缘:
有人知道有什么好方法可以阻止这种情况发生吗?或者我的代码是否有问题(很有可能)?
这是我的代码(简化):
\documentclass[12pt]{book}
\usepackage[a4paper, tmargin={1.75in}, bmargin={1.5in}, lmargin={1.25in}, rmargin={1.25in}]{geometry}
\usepackage{setspace}
\onehalfspacing
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\usepackage{changepage}
\usepackage{caption}
\captionsetup{format=hang, justification=raggedright, singlelinecheck=false}
\renewcommand{\footnotesize}{\fontsize{12pt}{12pt}\selectfont}
\usepackage{booktabs}
\usepackage[
backend=biber,
style=authoryear,
]{biblatex}
\addbibresource{references.bib}
\usepackage[utf8]{inputenc}
\usepackage{pdflscape}
% \usepackage{showframe}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage[labelfont=bf]{caption}
\begin{document}
\printbibliography[heading=none]
\end{document}
非常感谢
答案1
我建议你加载网址包也是如此。其目的是指示 LaTeX 允许在 URL 字符串和 URL 类对象(例如可能出现在书目条目中的 DOI 字符串)内的任意位置根据需要出现换行符。
\documentclass[12pt]{book}
\begin{filecontents}[overwrite]{references.bib}
@article{stedman,
author = "Richard C. Stedman",
journal = "Environment and behavior",
title = "Toward a Social Psychology of Place:
Predicting Behavior from Place-Based
Cognitions, Attidude, and Identity",
year = 2002,
month = sep,
volume = 34,
number = 5,
pages = "561--581",
issn = "0013-9165",
doi = "10.1177/0013916502034005001",
}
\end{filecontents}
\usepackage[a4paper,
tmargin=1.75in, bmargin=1.5in,
lmargin=1.25in, rmargin=1.25in]%
{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{hyperref}
\hypersetup{colorlinks,allcolors=black}
\usepackage{changepage}
\usepackage{caption}
\captionsetup{labelfont=bf, format=hang,
justification=raggedright,
singlelinecheck=false}
% \usepackage[labelfont=bf]{caption}
%%\renewcommand{\footnotesize}{\fontsize{12pt}{12pt}\selectfont} % huh??
\renewcommand{\footnotesize}{\normalsize}
\usepackage{booktabs}
\usepackage[backend=biber,style=authoryear]{biblatex}
\addbibresource{references.bib}
%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage{pdflscape}
% \usepackage{showframe}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{xurl} % <-- new
\begin{document}
\renewcommand\familydefault\sfdefault\selectfont % mimic OP's screenshot
\nocite{*}
\printbibliography[heading=none]
\end{document}