You can define a "reference prefix": if foo
is a counter, then its value when a label refers to it is printed as
\p@foo\thefoo
where \p@foo
is by default empty. So
\documentclass{article}
\setcounter{secnumdepth}{5}
\renewcommand\theparagraph{\S~\arabic{paragraph}}
\newcommand{\pararef}[1]{\ref{#1} (p.~\pageref{#1})}
\makeatletter
\renewcommand{\p@paragraph}{\thesubsubsection, }
\makeatother
\begin{document}
\section{A}
\subsection{B}
\subsubsection{C}
\paragraph{D}\label{x}
This is the reference: \pararef{x}
\end{document}
If you don't always use \paragraph
subordinate to subsubsections, then you can say
\makeatletter
\renewcommand{\p@paragraph}{%
\ifnum\value{subsection}=\z@
\thesection
\else
\ifnum\value{subsubsection}=\z@
\thesubsection
\else
\thesubsubsection
\fi
\fi,\space
}
\makeatother
This assumes that \paragraph
is at least subordinate to a section. This is a test document
\documentclass{article}
\setcounter{secnumdepth}{5}
\renewcommand\theparagraph{\S~\arabic{paragraph}}
\newcommand{\pararef}[1]{\ref{#1} (p. \pageref{#1})}
\makeatletter
\renewcommand{\p@paragraph}{%
\ifnum\value{subsection}=\z@
\thesection
\else
\ifnum\value{subsubsection}=\z@
\thesubsection
\else
\thesubsubsection
\fi
\fi,\space
}
\makeatother
\begin{document}
\section{A}
\subsection{B}
\subsubsection{C}
\paragraph{D}\label{x}
This is the reference: \pararef{x}
\section{E}
\paragraph{F}\label{y}
This is the reference: \pararef{y}
\section{G}
\subsection{H}
\paragraph{I}\label{z}
This is the reference: \pararef{z}
\end{document}
I've always found this kind of cross references heavy and not friendly to the reader.
scrjura
which offers such references?