I would like section and subsection to automatically create a hypertarget (for external url linking into the pdf) and a pdftooltip, that displays the url (so the url is discoverable)
\section{\pdftooltip{Common Pressed Meats}{\#Common-Pressed-Meats}}\hypertarget{Common-Pressed-Meats}{}
\hypertarget{Canned-Pressed-Spam}{\subsection{\pdftooltip{Canned \& Pressed Spam}{\#Canned-Pressed-Spam}}}
Either of these lines work for me, my question us how to redefine \section
and \subsection
so that \section{Common Pressed Meats}
will output one of the above, and to do the conversion from heading text (with symbols) to valid url without symbols,
[Damn they almost work - pdfbookmark ia "Common Pressed Meats#Common-Pressed-Meats"]
Here is MWE for pdflatex
\documentclass[english]{scrartcl}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=1,
breaklinks=true,pdfborder={0 0 1},backref=section,colorlinks=false]
{hyperref}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{pdfcomment}
\makeatother
\begin{document}
\section{\pdftooltip{Common Pressed Meats}{\#Common-Pressed-Meats}}\hypertarget{Common-Pressed-Meats}{}
The hypertarget is Common-Pressed-Meats or from the internet http://www.spam.com\#Common-Pressed-Meats
\hypertarget{Canned-Pressed-Spam}{\subsection{\pdftooltip{Canned \& Pressed Spam}{\#Canned-Pressed-Spam}}}
Invalid and special URL chars (i.e. most symbols) in the heading text
must be removed from the hypertarget and replaced with dash -
\hypertarget{Other-Pressed-Meats}{\section{\pdftooltip{Other Pressed Meats}{\#Other-Pressed-Meats}}}
The tooltip is over the heading text, and shows the hypertarget preceded
by \#
\end{document}
What am I trying to do and Why?
I have documentation, in pdf, on the net. It is detailed and typically 5-50 pages long. When dealing with technical queries part of the answer is in the documentation. I need to be able to send a link that goes directly to the part of the document that explains my point. The link (url from internet, or Named-Destination in pdf terminology) needs to be human meaningful, and my answer should still be useful in 3 months time when the document has been revised (which rules out "section.2.1.3". Me and any other users need to quickly an easily know what the url is when reading the pdf. This is why have tootip. Otherwise the named destinations are too difficult to be useful Note that I am not interested in using the hypertarget internally within the latex/pdf
\oldsection
call all bellow it and you may also include it inside an hyperlink. I will try to understand what you want to do and if possible I will write an answer.hyperref
already adds automatic hyper targets. It does not use a symbolic name for them but a section-leve-prefix, e.g.,subsection
followed by a dot and the section number, e.g.,subsection.3.6
in thehyperref
manualsection.1
etc. the number1
is replaced by the total section number (unless the section number is reset). The same is almost true for any other structure level counter,, where the higher levels are appended, i.e. subsection.1.1