在带有 Koma Script 的 LuaLaTeX 书籍文档中,我遇到了两个与 Hyperref 相关的问题(可能是一个):
样本
@online{Writ:Title,
author = {Writ, R.},
title = {Title},
date = {2005},
url = {http://www.blabliblabla.com/filefolder/folder_folder/folder/R._Schreib_AVery_-_LongTitle_That_Shoud_Have_A_Break.pdf},
urldate = {2017-08-15}}
链接包装.tex
\documentclass[a4paper,oneside,twocolumn]{scrbook}
\usepackage[ngerman]{babel}
\usepackage{blindtext}
\usepackage[backend=biber,style=apa]{biblatex}
\DeclareLanguageMapping{german}{german-apa}
\addbibresource{sampelbib.bib}
\usepackage[dvipsnames,svgnames,x11names,hyperref]{xcolor}
\PassOptionsToPackage{hyphens,obeyspaces,spaces}{url}
\usepackage[
breaklinks=true,
allbordercolors=Maroon,
ocgcolorlinks=true,
colorlinks=true,
anchorcolor=Maroon,
citecolor=Maroon,
filecolor=Maroon,
linkcolor=Maroon,
menucolor=Maroon,
runcolor=Maroon,
urlcolor=Maroon,
linktoc=all
]{hyperref}
\makeatletter
\g@addto@macro{\UrlBreaks}{\do\/\do\-\do\_}
\makeatother
\begin{document}
\chapter{A Chapter}
Some sample text from \textcite{Writ:Title} with a link to the Chapter \ref{Too Long Reference}. \nameref{Too Long Reference} \blindtext[1]
\chapter{Another Chapter With A Too Long Text For A Nice Reference}
\label{Too Long Reference}
\onecolumn
\printbibliography
\end{document}
我必须做哪些更改才能获得 URL 和章节链接?
答案1
ocgcolorlinks
包的选项hyperref
可防止链接绕过行和分页符。相反,请尝试ocgx2
具有改进ocgcolorlinks
实现的包。
不过,该apa
样式似乎存在与 URL 中的下划线相关的错误。将其替换为authoryear
将得到以下结果:
\documentclass[a4paper,oneside,twocolumn]{scrbook}
\usepackage[ngerman]{babel}
\usepackage{blindtext}
%\usepackage[backend=biber,style=apa]{biblatex}
\usepackage[backend=biber,style=authoryear]{biblatex}
%\DeclareLanguageMapping{german}{german-apa}
\addbibresource{sampelbib.bib}
\usepackage[dvipsnames,svgnames,x11names,hyperref]{xcolor}
\PassOptionsToPackage{hyphens,obeyspaces,spaces}{url}
\usepackage[
breaklinks=true,
allbordercolors=blue,
% ocgcolorlinks=true,
colorlinks=true,
anchorcolor=blue,
citecolor=blue,
filecolor=blue,
linkcolor=blue,
menucolor=blue,
runcolor=blue,
urlcolor=blue,
linktoc=all
]{hyperref}
\makeatletter
\g@addto@macro{\UrlBreaks}{\do\/\do\-\do\_}
\makeatother
\usepackage[ocgcolorlinks]{ocgx2}
\begin{document}
\chapter{A Chapter}
Some sample text from \textcite{Writ:Title} with a link to the Chapter \ref{Too Long Reference}. \nameref{Too Long Reference} \blindtext[1]
\chapter{Another Chapter With A Too Long Text For A Nice Reference}
\label{Too Long Reference}
\onecolumn
\printbibliography
\end{document}