1

The code below produces the following ugly hyperref link in the contents outline displayed on pdf viewers (where it says orgf65efce in the upper left).

\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}

ugly hyperref contents outline

How can I fix this (preferably keeping the link as it is)?

1
  • Do you mean to have the title of the section link to part of text body?
    – B Hos
    Oct 15, 2022 at 0:10

2 Answers 2

1

I did misunderstand your question initially.

Unless you meant to link the title of the section to the text. Try this:

\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}
1
  • I'm not sure I have correctly explained the question / you have understood fully. The problem is where it says orgf65efce in the upper left contents outline. Oct 15, 2022 at 0:01
1

The standard command of hyperref to split the code between the text and the bookmarks is \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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .