Hi bernardo_vasconcelos, AmberV, and nontroppo:
To: bernardo_vasconcelos: Thank you for your code. I am compiling directly to a LaTeX .tex file. I’ll have to have a look at your code to see if/how I can incorporate it into my Scrivener code.
To All: Please forgive me if I’ve strayed a bit too far from the traditional Scrivener code. (And feel free AmberV to delete this post if it crosses any red lines for this web site.)
I thought for those few of us who use Scrivener+LaTeX, I’d assemble an MWE (Minimum Working Example) to demonstrate how I use the LaTeX \hypertarget function in the hyperref package to make non-titled links between disparate paragraphs.
Please note that the following MWE should be fully stand-alone, e.g when using a standard LaTeX Typesetting app, it should be Typeset-able, right ‘out-of-the-box’. With my Scrivener+LaTeX setup, I can include any and all of the appropriate parts of the MWE code below directly within my Scrivener .scriv Project file. I can then compile the Scrivener .scriv file into a .tex file using Scrivener, which I then Typeset using the TexShop app into the final PDF file.
Here is the MWE: (apologies if the formatting is a bit difficult to read.)
%____________________ MWE start_____________________
% Note: The following code needs to be Typeset TWICE for the page number in \pageref{} to work properly.
\documentclass{article}
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{contour}
\usepackage[normalem]{ulem}
\usepackage{verbatim}
\newcommand*{\myuline}[1]{%
\uline{\phantom{#1}}%
\llap{\contour{white}{#1}}%
}
\makeatletter
\newcommand{\linkdest}[1]{%
\Hy@raisedlink{%
\hypertarget{#1}{}%
}%
\phantomsection%
\label{#1}
}%
\makeatother
\begin{document}
\clearpage
Click here to see the \hyperlink{link:TheLastPara}{The;\textbf{Last};Paragraph} on page \pageref{link:TheLastPara}. \par
\linkdest{link:TheFirstPara}\textbf{The \myuline{first} paragraph of the story}.
\blindtext\par
\linkdest{link:TheSecondPara}\textbf{The \myuline{second} paragraph of the story}.
\blindtext
\newpage
\linkdest{link:TheThirdPara}\textbf{The \myuline{third} paragraph of the story}.
\blindtext
\newpage
\linkdest{link:TheLastPara}\textbf{The \myuline{last} paragraph of the story}.
\blindtext \par
Click here to see the \hyperlink{link:TheFirstPara}{The;\textbf{First};Paragraph} on page \pageref{link:TheFirstPara}. \par
Click here to see the \hyperlink{link:TheSecondPara}{The;\textbf{Second};Paragraph} on page \pageref{link:TheSecondPara}. \par
Click here to see the \hyperlink{link:TheThirdPara}{The;\textbf{Third};Paragraph} on page \pageref{link:TheLastPara}. \par
Click here to see the \hyperlink{link:TheLastPara}{The;\textbf{Last};Paragraph} on page \pageref{link:TheLastPara}. \par
\end{document}
% Note: The following code needs to be Typeset TWICE for the page number in \pageref{} to work properly.
%___________________ MWE end______________________
For the Scrivener+LaTeX’ers here, I’ve adjusted how the \hypertarget function positions the connection to the text using the Hy@raisedlink function. For more info, check out the SE post at: hypertarget seems to aim a line too low for more information.
Let me know if anyone has any questions.
Enjoy!
HTH,
scrive