我在写一篇很长的论文时遇到了 hyperref 问题。我必须经常引用一些参考文献,然后反向引用会变得比一行的宽度还要长。当这种情况发生时,我会遇到“Overfull \hbox”警告。人们很少在多页中引用一个参考文献,然而,这是我必须做的。当我继续工作时,反向引用编号(链接)会变长,并且不会分成多行,然后它就会成为一个问题(因为这个错误现在超出了页面边界)。我必须继续扩展我的文档页面(并且经常引用相同的参考文献)。有什么方法可以抑制警告,或者有命令强制将长反向引用分成多行?非常感谢!
这可能是 hyperref 的一个 bug。一般情况下,人们不会引用一个参考文献那么多次,但当你写长篇论文或书籍时,这是不可避免的。因此,如何创建多行 backref 很重要。
以下是带有参考书目的最小工作示例(MWEB)的链接:
https://drive.google.com/file/d/1lZeTHZnV8AuW-x23jPEhFE8KLXdz-YMp/view?usp=sharing
以下是代码:
%preamble
\documentclass[10pt,twoside]{book}
\usepackage{ifpdf}
\ifpdf
\usepackage[pdftex]{graphicx} %.pdf figures
%\usepackage[dvipdfm]{graphicx} \usepackage{bmpsize}
\else
\usepackage[dvips]{graphicx} %.eps figures
\fi
%Hyperlink or PDF labels and Colors
%\usepackage[dvips=true,bookmarks=true]{hyperref} %only for PDF generation
%If linktoc=all -> {hyperref}'s linkcolor on T.O.C. text and pagenumber
\usepackage[bookmarks=true, %only needed for PDF generation
colorlinks=true,linkcolor=blue,citecolor=magenta,urlcolor=cyan, %link/ref/url colors
linktoc=page,backref=page]{hyperref}
%%backref=page in hyperref: back references in bibliography to show pages# of cited reference
\hypersetup{breaklinks=true} % set automatically by hyperref?
%20210520 If you have problems with URLs and linebreaks you can add the option breaklinks to the hyperref package: \usepackage[breaklinks]{hyperref}.
%https://www.overleaf.com/learn/how-to/Understanding_underfull_and_overfull_box_warnings
%\def\backref#1{{\scriptsize [#1]}}
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{
\textcolor[rgb]{0,0,1} {\textsuperscript{
\ifcase #1 (Not cited.) \ % not cited
\or \{p.~#2.\} % cited once
\else \{pp.~#2.\} % cited multiple pages
\fi%
}
}
}
%Start main text
\begin{document}
This is a book \cite{Physics2018}.
\newpage
\chapter{First} \label{Ch1}
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\chapter{Second} \label{Ch2}
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\chapter{Third} \label{Ch3}
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\chapter{Fourth} \label{Ch4}
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\chapter{Fifth} \label{Ch5}
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
\newpage
See \cite{Physics2018}.
%References
\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,ref}
\end{document}
文件“ref.bib”包含以下内容:
@BOOK{Physics2018,
AUTHOR = "David Halliday and Robert Resnick and Jearl Walker",
TITLE = "Fundamentals of Physics",
PUBLISHER = "John Wiley \& Sons Ltd.",
YEAR = "2018",
edition = "11th",
ISBN = "ES8-1-119-30685-6",
}
答案1
您正在将整个 backref 列表放入\textsuperscript
:
\renewcommand*{\backrefalt}[4]{
\textcolor[rgb]{0,0,1} {\textsuperscript{ %<--------------------
\ifcase #1 (Not cited.) \ % not cited
\or \{p.~#2.\} % cited once
\else \{pp.~#2.\} % cited multiple pages
\fi%
}
}
}
\textsuperscript
创建一个框。如果您想要较小的字体大小,请使用例如\scriptsize
:
\renewcommand*{\backrefalt}[4]{%
\textcolor[rgb]{0,0,1} {\scriptsize
\ifcase #1 (Not cited.) \ % not cited
\or \{p.~#2.\} % cited once
\else \{pp.~#2.\} % cited multiple pages
\fi%
}}
然后给出