2

I want to add a PDF title to the PDF bookmark using hyperref package. However it does not work.

bookmark

As shown in the picture, I want to add a title above the Introduction.

equation link

Moreover, I want to make the "equation (1)" a link as a whole, not just red 1, as shown in the above picture.

How could I achieve these? Many thanks.

Here is my MWE:

\documentclass[a4paper, 10pt]{article}

\usepackage{amsmath}

\usepackage[backend=biber, style=numeric]{biblatex}

\usepackage[bookmarksnumbered, pdftitle={A PDF Title?}]{hyperref}

\hypersetup{colorlinks=true, citecolor=cyan}

\begin{filecontents*}{\jobname.bib}

@article{Azeez2013,
author = {Azeez, O. S. and Isafiade, A. J. and Fraser, D. M.},

title = {Supply-based superstructure synthesis of heat and mass exchange networks},

        journal = {Computers \& Chemical Engineering},

        volume = {56},
        number = {7},
        pages = {184--201},
        year = {2013}
}\end{filecontents*}

\addbibresource{\jobname}

\title{A PDF title?}

\begin{document}

 \maketitle

\section{Introduction}

This is an example for illustrating the use Hyperref package~\cite{Azeez2013}.

\section{Problem Statement}

What is wrong?

\begin{equation}

\label{eq: mass balance}

\sum_{i} m_{in} = \sum_{j} m_{out}

\end{equation}

This equation~\eqref{eq: mass balance} shows the mass balance of the model.

\section*{Acknowledgements}

\addcontentsline{toc}{section}{Acknowledgements}%

Who would you like to thank?

\addcontentsline{toc}{section}{References}

\printbibliography

\end{document}
3
  • You're asking two completely different things in one question. As for the bookmark: What do you want to add there? The document title? Where should the bookmark point to if clicked?
    – user31729
    Aug 3, 2015 at 12:19
  • @ChristianHupfer Oh, I forget the document title. the bookmark should point to the document title.
    – Nick
    Aug 3, 2015 at 12:22
  • @ChristianHupfer Thanks, Christian. I add a title to the document.
    – Nick
    Aug 3, 2015 at 12:27

2 Answers 2

5

The additional bookmark can be done by \pdfbookmark:

\pdfbookmark[1]{My Title}{title}

The link including "equation" is more tricky, because \autoref does not put the number in parentheses. Manually it can be done by:

\hyperref[eq: mass balance]{equation~(\ref*{eq: mass balance})}

The star form of \ref sets a reference without link, because the link is already set by \hyperref.

Full example:

\documentclass[a4paper, 10pt]{article}

\usepackage{amsmath}

\usepackage[bookmarksnumbered, pdftitle={A PDF Title?}]{hyperref}
\hypersetup{colorlinks=true, citecolor=cyan}

\usepackage{bookmark}% faster updated boomkarks

\newcommand*{\myeqref}[2][equation]{%
  \hyperref[{#2}]{#1~(\ref*{#2})}%
}

\begin{document}
\pdfbookmark[1]{My Title}{title}% "1" = section level

\section{Introduction}

This is an example for illustrating the use Hyperref package.

\section{Problem Statement}

What is wrong?

\begin{equation}
  \label{eq: mass balance}
  \sum_{i} m_{in} = \sum_{j} m_{out}
\end{equation}

This \myeqref{eq: mass balance} shows the mass balance of the model.

\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements}%

Who would you like to thank?
\end{document}

Result

Bookmarks:

Bookmarks

Moving the target for the title closer to the title:

The bookmark command needs to be smuggled inside \maketitle. It depends on the used class, packages, definition of \maketitle, where to put the bookmark, to get the target closer to the title. In class article, the title argument starts in vertical mode, thus the bookmark can be placed here:

\title{%
  \pdfbookmark[1]{My Title}{title}%
  My Title%
}
...
\maketitle
5
  • Since the O.P. does not react or give feedback: +1 ;-)
    – user31729
    Aug 3, 2015 at 16:31
  • @ChristianHupfer When I click Introduction or Acknowledge in PDF bookmark, the corresponding section will appear in the right place. However, when I click A PDF Title or Reference, these two titles cannot appear. You need to scroll cursor up or down to find it. Any ideas to solve this problem? thanks.
    – Nick
    Aug 4, 2015 at 4:52
  • @Nick Your comment belongs to Christian's answer. There the target for the title is on the baseline of the title. In my answer I have added the target at the start of the document, assuming the title will follow. Aug 4, 2015 at 5:48
  • @HeikoOberdiek Yes, I actually try your case. But could we put the target on the title itself, just as the Introduction? When we click the title, it will appear right on the page, showing the title. Right now, when I click the title in the bookmark, it will go back to the title page, but not show the title.
    – Nick
    Aug 4, 2015 at 6:08
  • @Nick: You should unaccept my answer and accept Heiko Oberdiek's answer, since he solved the problem with the reference as well. I am sure he can shift the target to the title as well -- he seems to have some deep knowledge about hyperref ;-)
    – user31729
    Aug 4, 2015 at 7:05
2

This is the bookmark part of the question only...

Additions to the bookmarks can be done with \pdfbookmark, for example.

The relevant level should be given, here with article class level 0 is appropiate, if the title bookmark should be aligned with the rest, use level 1 then. Here I've done the solution with 0 however.

\pdfbookmark[0]{bookmarkentry}{label}

The label is some link mark, given in \title{} for example.

\documentclass[a4paper, 10pt]{article}

\usepackage{amsmath}

\usepackage[backend=biber, style=numeric]{biblatex}

\newcommand{\mydocumenttitle}{A PDF title}

\usepackage[bookmarksopen=true,bookmarksnumbered, pdftitle={\mydocumenttitle}]{hyperref}

\hypersetup{colorlinks=true, citecolor=cyan}

\begin{filecontents*}{\jobname.bib}
@article{Azeez2013,
  author = {Azeez, O. S. and Isafiade, A. J. and Fraser, D. M.},
  title = {Supply-based superstructure synthesis of heat and mass exchange networks},
  journal = {Computers \& Chemical Engineering},
  volume = {56},
  number = {7},
  pages = {184--201},
  year = {2013}
}
\end{filecontents*}

\addbibresource{\jobname}

\author{A. U. Thor}
\title{\hypertarget{title:link}{\mydocumenttitle}}

\begin{document}
\maketitle
\pdfbookmark[0]{A PDF title}{title:link}
\clearpage

\section{Introduction}

This is an example for illustrating the use Hyperref package~\cite{Azeez2013}.

\section{Problem Statement}

What is wrong?

\begin{equation}
\sum_{i} m_{in} = \sum_{j} m_{out}\label{eq: mass balance}
\end{equation}

This equation~\eqref{eq: mass balance} shows the mass balance of the model.

\section*{Acknowledgements}

\addcontentsline{toc}{section}{Acknowledgements}%

Who would you like to thank?

\addcontentsline{toc}{section}{References}

\printbibliography

\end{document}

enter image description here

You must log in to answer this question.

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