# Referring to unnumbered paragraphs

I'd like to write

We added an explanation on \paragraphref{modifiedparagraph1}.


and have it compiled to:

We added an explanation on page 7, paragraph 2.


where the referenced paragraph is the second on the page not in the section. Is there a package that can do this?

I'm aware of the possibility to refer to numbered paragraphs but that's not what I want because sections and paragraphs are not numbered in my document.

This feature would be very useful when writing response letters to journal editors.

• For the page number it is quite easy using \label{} and \pageref{}. However for the paragraph number I do not have smart ideas for it just now. BTW I guess you made a typo in your question mixing explanation and sentence... – Ludovic C. Oct 19 '13 at 13:36
• Techniques used for numbering footnotes per page may be useful here, but I foresee problems with paragraphs that are split between pages. – Ulrich Schwarz Oct 19 '13 at 13:49

Here is a solution:

\documentclass{article}

\usepackage{lipsum}
\usepackage{hyperref}

\makeatletter
\newcounter{parcount}[page]
\setcounter{parcount}{0}

\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}%
\stepcounter{parcount}%
\def\@currentlabel{\arabic{parcount}}}

\newcommand{\paragraphref}[1]{page \pageref{#1}, paragraph \ref{#1}}
\makeatother

\begin{document}

\paragraph{Foo}
\label{Foo}
\lipsum[1]
See on \paragraphref{Bar}.

\paragraph{Bar}
\lipsum[2]
\label{Bar}

\newpage

\paragraph{Baz}

\paragraph{Foobar}
See on \paragraphref{Foo}.

\end{document}


And here are the output:

• Add the lines \lipsum[1-5] at the top of your document. The paragraph counting is off. I'm not sure how you work around this. – A.Ellett Oct 19 '13 at 14:33
• @A.Ellett My solution is for counting the paragraphs defined by the \paragraph command. If the OP wants to count the paragraphs without using the \paragraph command then the solution needs to be changed to count the \par or something like that. – Ludovic C. Oct 19 '13 at 14:40
• Counting \par will most likely not work since so many other LaTeX structures use \par. But what I was trying to point out is that your \paragraph counting isn't quite working around page boundaries. Try adding \lipsum[1-5] at the top of the document. Even though those lines aren't \paragraphs in the manner of your style, the reference to your \paragraphs is still not correct. – A.Ellett Oct 19 '13 at 14:47
• Counting \pars is what I in fact intended to do. – tmalsburg Oct 19 '13 at 14:58