2

I don't want the readers jumping on text by mistakenly clicking on author names or figure/table numbers. So I want to disable hyperref but still keep the bookmark sidebar in the pdf file. Bookmarks are kind of like toc and help the reader jump on references or appendices whenever they want.

So I want a combination of "nohyperref" and "bookmarks=true", but i don't know how to get it done.

Thanks.

\documentclass[a4paper, 12pt]{article}
\usepackage{lscape}
\usepackage[margin=1in]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\definecolor{light-gray}{gray}{0.8}
\usepackage{soul} 
\sethlcolor{light-gray}
\usepackage{tipa}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{color}
\usepackage{afterpage}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{amsfonts}
\usepackage{amscd}
\usepackage{longtable}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{eucal}
\usepackage{hhline}
\usepackage{natbib}
\usepackage{setspace}
\usepackage{mathpazo}
\usepackage{calc}
\usepackage{booktabs}
\usepackage{mathtools}
\usepackage{eurosym}
\usepackage{stmaryrd}
\usepackage{float}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{positioning}
\usepackage{dcolumn}
\usetikzlibrary{shadows,shadings,shapes,decorations.pathreplacing}
\usepackage{times}
\usetikzlibrary{shapes.geometric}
\usepackage[nokeyprefix]{refstyle}
\usepackage{varioref}
\usepackage{xr-hyper}
\usepackage[bookmarks=true]{hyperref}
\usepackage{filecontents}
\begin{filecontents*}{References.bib}
@article{cite1,
title={Nothing special},
author={Nobody, Noboditch},
year={1988}
}
\end{filecontents*}

\begin{document}


\section{Introduction}
 \onehalfspacing
 \citep[see, e.g.,][]{cite1}


\section*{}
\addcontentsline{toc}{section}{References}

\bibliographystyle{agsm}
\bibliography{References}

\end{document}

So I want the links to citations be disabled but "introduction" and "References" to appear in bookmarks.

  • 2
    @Sebastiano there is a bookmark package... You already have +1 from me... but with this package I think your answer will fit his expectations – koleygr Sep 16 '18 at 21:05
  • @D_B Into your code you have \usepackage{amsmath} and \usepackage{mathtools}. The last package is strong and contains \usepackage{amsmath}. See this link tex.stackexchange.com/questions/43860/mathtools-vs-amsmath – Sebastiano Sep 16 '18 at 21:12
  • 2
    Your long list of packages seems quite likely copied from some friend's template; don't do like this, use only the packages you really need. For instance, it's very dubious to load both mathpazo (for Palatino in text and math) and times (for Times New Roman in text): you end up with Times for text and Palatino for math, a very awkward combination. – egreg Sep 16 '18 at 21:18
  • 1
    You might use the hidelinks option. – egreg Sep 16 '18 at 21:23
  • 1
    hidelinks hides only the blue borders but doesn't disable the links. – D_B Sep 16 '18 at 21:24
3

There is no in-built option to disable the links apart from the draft option. But these also disables the anchors and so bookmarks no longer have a target.

You could try to execute only a part of the commands used by the draft option. Be aware that while it works in the minimal example it could be that in larger documents you get errors because of some side-effect - hyperref is a rather complicated beast.

\documentclass{article}

\usepackage{bookmark}%loads hyperref
\makeatletter
\gdef\hyper@link#1#2#3{#3\Hy@xspace@end}
\gdef\hyper@link#1#2#3{#3\Hy@xspace@end}%
\let\hyper@linkstart\@gobbletwo
\def\hyper@linkend{\Hy@xspace@end}%
%\def\hyper@linkurl#1#2{#1\Hy@xspace@end}   % url optional
%\def\hyper@linkfile#1#2#3{#1\Hy@xspace@end}%files optional
\def\hyper@link@[#1]#2#3#4{#4\Hy@xspace@end}%
\let\@fifthoffive\@secondoftwo  %unclear if needed
\let\@secondoffive\@secondoftwo %unclear if needed
\makeatother
\begin{document}
\tableofcontents
\section{First section}
\ref{test} is on page \pageref{test}

\url{https://tex.stackexchange.com/}
\newpage
\section{Second section}\label{test}

\end{document} 

enter image description here

  • For some reason \let\@secondoffive\@secondoftwo messed up my page number. Without it worked nicely. – Daniel May 6 at 10:44
2

Last Edit: We create bookmarks manually and using the previous methods. On my linux (okular and evince) bookmarks are in the sidebar and active, and all links in the document are inactive.

\documentclass[a4paper, 12pt]{article}
\usepackage{lscape}
\usepackage[margin=1in]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\definecolor{light-gray}{gray}{0.8}
\usepackage{soul} 
\sethlcolor{light-gray}
\usepackage{tipa}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{color}
\usepackage{afterpage}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{amsfonts}
\usepackage{amscd}
\usepackage{longtable}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{eucal}
\usepackage{hhline}
\usepackage{natbib}
\usepackage{setspace}
\usepackage{mathpazo}
\usepackage{calc}
\usepackage{booktabs}
\usepackage{mathtools}
\usepackage{eurosym}
\usepackage{stmaryrd}
\usepackage{float}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{positioning}
\usepackage{dcolumn}
\usetikzlibrary{shadows,shadings,shapes,decorations.pathreplacing}
\usepackage{times}
\usetikzlibrary{shapes.geometric}
\usepackage[nokeyprefix]{refstyle}
\usepackage{varioref}
\usepackage{xr}

\usepackage[depth=-1]{bookmark}

\hypersetup{draft}
\PassOptionsToPackage{draft}{bookmark}

\usepackage{filecontents}
\begin{filecontents*}{References.bib}
@article{cite1,
title={Nothing special},
author={Nobody, Noboditch},
year={1988}
}
\end{filecontents*}


\begin{document}

\section{Introduction}\bookmark[page=\thepage,level=0]{Introduction}

 \onehalfspacing
 \citep[see, e.g.,][]{cite1}
 This is a reference \ref{sec:test}
\lipsum[1-5]

\section{Test}\label{sec:test}\bookmark[page=\thepage,level=0]{Test}
\lipsum[1-5]
\includegraphics[width=\textwidth]{example-image-a}
\subsection{Test subsection}\bookmark[page=\thepage,level=1]{Test subsection}
\lipsum[1-3]
\section*{}
\addcontentsline{toc}{section}{References}

\bibliographystyle{agsm}
\bibliography{References}\bookmark[page=\thepage,level=0]{References}

\end{document}

First answer

Here is a solution with bookmark package. I removed hyperref as you don't really need it:

\documentclass[a4paper, 12pt,draft]{article}
\usepackage{lscape}
\usepackage[margin=1in]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\definecolor{light-gray}{gray}{0.8}
\usepackage{soul} 
\sethlcolor{light-gray}
\usepackage{tipa}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{color}
\usepackage{afterpage}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{amsfonts}
\usepackage{amscd}
\usepackage{longtable}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{eucal}
\usepackage{hhline}
\usepackage{natbib}
\usepackage{setspace}
\usepackage{mathpazo}
\usepackage{calc}
\usepackage{booktabs}
\usepackage{mathtools}
\usepackage{eurosym}
\usepackage{stmaryrd}
\usepackage{float}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{positioning}
\usepackage{dcolumn}
\usetikzlibrary{shadows,shadings,shapes,decorations.pathreplacing}
\usepackage{times}
\usetikzlibrary{shapes.geometric}
\usepackage[nokeyprefix]{refstyle}
\usepackage{varioref}
\usepackage{xr}
%\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}
\usepackage{filecontents}
\begin{filecontents*}{References.bib}
@article{cite1,
title={Nothing special},
author={Nobody, Noboditch},
year={1988}
}
\end{filecontents*}

\setlength\overfullrule{0pt}

\begin{document}


\section{Introduction}
 \onehalfspacing
 \citep[see, e.g.,][]{cite1}
 This is a reference \ref{sec:test}
\lipsum[1-5]

\section{Test}\label{sec:test}
\lipsum[1-3]
\includegraphics[width=\textwidth,draft=false]{example-image-a}
\section*{}
\addcontentsline{toc}{section}{References}

\bibliographystyle{agsm}
\bibliography{References}

\end{document}

Edit: added draft option in document class and checked... Also, I had to add [draft=false] option for the pictures and everything is fine. Test it.

Edit: Added \setlength\overfullrule{0pt} and changed \usepackage{hypre-xr} to \usepackage{xr} thanks to @blub.

Also from his comment, a better alternative (to avoid writing draft=false in every image) is to add the code:

 \makeatletter \lowercase{\Gin@boolkey{false}}{draft} \makeatother

in our preamble

  • The code gives some error that haven't figured out yet about a label or something... In your full example may be it is ok... But as MWE it has some problem even if compiles – koleygr Sep 16 '18 at 21:34
  • 1
    @koleygr "draft" removed bookmarks as well. Plus figures don't show. – D_B Sep 16 '18 at 22:00
  • 1
    To remove the black lines caused by the draft option, add \setlength\overfullrule{0pt} – aloneprism Sep 16 '18 at 22:30
  • 1
    @koleygr Strange, I don't get an error. I'll test again. Meanwhile to show images despite draft mode: \makeatletter \lowercase{\Gin@boolkey{false}}{draft} \makeatother – aloneprism Sep 16 '18 at 22:37
  • 1
    @koleygr Checked again and \setlength\overfullrule{0pt} works. Where did you place it? Without hyperref better change \usepackage{xr-hyper} to \usepackage{xr} – aloneprism Sep 16 '18 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.