Placing ref/pageref target labels inside a section
Use another label for the pageref of the important fact:
\documentclass{article}
\usepackage{lipsum}
\makeatletter
\def\magicref#1{\expandafter\magicref@i#1\@nil}
\def\magicref@i#1::#2\@nil{section \ref{#1} on page \pageref{#1::#2}}
\makeatother
\begin{document}
\section{First Section}
\label{first}
This is my first section. Let me add enough text to fill up more than one page here.
\lipsum[1-6]
Fine, so we've written quite a lot of text. Now let's talk about
\textbf{some important topic}\label{first::important} -- %%%%%%%%%%%%%%%
\lipsum[7-10]
\section{Second Section}
This is where things get interesting. In this section, I would like to discuss something
entirely different, which is nonetheless related to \textbf{some important topic} that I
introduced earlier (see \magicref{first::important}).
\end{document}
\ref{first}
and \ref{first:important}
are always the same. but \pageref
can be different. \magricref
is split into a \ref
and \pageref
.