The manual of hyperref says:
\url{URL}
Similar to \href{URL}{\nolinkurl{URL}}
. Depending on the driver \href also tries to detect the link type. Thus the result can be a url link, file link, ..
With the command url
you didn't specify the action run
or file
. All these methods are given in the documentation.
Yes, this is certainly possible using the hypertarget
and href
mechanism provided by the hyperref
package.
Let's say that fileA.tex
has
\documentclass{article}
\usepackage{lipsum}
\usepackage{hyperref}
\begin{document}
\lipsum
\hypertarget{fileAhypertarget}{Should come to this}
\end{document}
Then you can write fileB.tex
as
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{fileA.pdf#fileAhypertarget}{Let's go to file A!}
\end{document}
Note that not all pdf
viewers support this- for example evince
didn't give the correct behaviour, but acroread
did.
Update following the comments
The lipsum
package is used to generate sample text- you don't need it for most of your documents, but you'll see it used a lot here on tex exchange just to demonstrate MWEs.
You can automate the hypertarget
mechanism for each section in lots of ways- here's one way using the titlesec
package to help; note that I've commented out the showlabels
package, but you might like to use it during debugging, it's really helpful!
fileA.tex
\documentclass{article}
\usepackage{lipsum} % for sample text
\usepackage{titlesec} % to change headings
% very useful during debugging!
%\usepackage[left]{showlabels}
%\showlabels{hypertarget}
% usually load the hyperref package last,
% see this for reference http://tex.stackexchange.com/questions/1863/which-packages-should-be-loaded-after-hyperref-instead-of-before
\usepackage{hyperref}
% renew \section to set a hypertarget
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection}
{1pc}
{\hypertarget{myhypertarget\thesection}}
\begin{document}
\lipsum[1]
\section{First section}
\lipsum
\section{Second section}
\lipsum
\section{Third section}
\lipsum
\end{document}
fileB.tex
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{fileA.pdf#myhypertarget1}{Let's go to Section 1!}
\href{fileA.pdf#myhypertarget2}{Let's go to Section 2!}
\href{fileA.pdf#myhypertarget3}{Let's go to Section 3!}
\end{document}
Best Answer
According to pp. 17f. of the user guide of the
hyperref
package, the "starred" forms of the macros that create cross-reference call-outs --\ref*
,\pageref*
,\autoref*
, and\autopageref*
-- are "[f]or instances where you want a reference to use the correct counter, but not to create a link" [emphasis added]Thus,
\autoref
and\autoref*
both create a cross-reference call-out, but the latter call-out isn't made into a hyperlink.