下面的代码在 pdf 查看器上显示的内容大纲中生成了以下丑陋的超链接(位于orgf65efce
左上角)。
\documentclass[11pt]{article}
\usepackage{hyperref}
\title{Testing Ugly Hyperref Output in Contents Outline}
\author{@nazzacode}
\hypersetup{
pdflang={English}}
\begin{document}
\maketitle
\section{\hyperref[orgf65efce]{LOL} -- This link prints ugly in the contents outline}\label{sec:org014cb14}
Here is a link:
\label{orgf65efce}LOL : Laughing Out Loud
\medskip
\noindent Please help me fix this problem!
\end{document}
我该如何修复此问题(最好保持原有链接)?
答案1
我最初确实误解了你的问题。
除非你打算将章节标题链接到文本。试试这个:
\documentclass[11pt]{article}
\usepackage[colorlinks=true]{hyperref}
\title{Testing Ugly Hyperref Output in Contents Outline}
\author{@nazzacode}
\hypersetup{
pdflang={English}}
\begin{document}
\maketitle
\section{\label{orgf65efce}{LOL} -- This link prints ugly in the contents outline}
Here is a link:
\hyperref[orgf65efce]{LOL} : Laughing Out Loud
\medskip
\noindent Please help me fix this problem!
\end{document}
答案2
hyperref 将代码拆分为文本和书签之间的标准命令是\texorpdfstring
:
\documentclass[11pt]{article}
\usepackage{hyperref}
\title{Testing Ugly Hyperref Output in Contents Outline}
\author{@nazzacode}
\hypersetup{
pdflang={English}}
\begin{document}
\maketitle
\section{\texorpdfstring{\hyperref[orgf65efce]{LOL}}{LOL} -- This link prints ugly in the contents outline}\label{sec:org014cb14}
Here is a link:
\label{orgf65efce}LOL : Laughing Out Loud
\medskip
\noindent Please help me fix this problem!
\end{document}