LaTeX 中的超链接不正确
到目前为止,LaTeX 中的 hyperref
包已经自动正确链接了我报告中的所有项目。 但有一个没有正确链接,可能是因为我手动将其添加到目录中,如下所示:
\addcontentsline{toc}{chapter}{Bibliography}
如何修复此问题?
So far the hyperref
package in LaTeX has automatically linked all the items in my report correctly. But there is one that did not get linked properly, possibly because I manually added it to the table of contents like this:
\addcontentsline{toc}{chapter}{Bibliography}
How do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在
\addtocontentsline
之前或之后使用\phantomsection
宏。 这指示hyperref
在该点添加锚点。 另外,请考虑到您必须运行 LaTeX 多次才能使该锚点位于准确的位置。You have to use the
\phantomsection
macro just before or after the\addtocontentsline
. This instructshyperref
to add an anchor at that point. Also, take into account that you have to run LaTeX several times to make this anchor to be in the exact place.如果您使用标准 LaTeX 文档类,例如
report
,则可以使用 tocbibind 包,然后您将不需要\addcontentsline
命令,超链接应该可以正常工作。 从文档中:我还建议查看 memoir 课程,这也解决了这个问题。 它旨在替代标准的
report
和book
类,并提供大量用于自定义的选项和命令。If you're using a standard LaTeX document class, such as
report
, you can use the tocbibind package, and then you won't need the\addcontentsline
command and the hyperlinks should work correctly. From the documentation:I'd also suggest looking at the memoir class, which also solves this problem. It's intended to be a replacement for the standard
report
andbook
classes, and provides lots of options and commands for customisation.