LaTeX forum ⇒ Math & Sciencecustomized equation referencing with page number

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Lifetime Beginner
Posts: 3
Joined: Tue Feb 06, 2024 5:14 pm

customized equation referencing with page number

Postby Lifetime Beginner » Tue Feb 06, 2024 6:03 pm

When I reference an equation, I like to have the page number in the reference as follows: (1.2)(34) would mean equation (1.2) on page 34. This is easy to do using \pageref. The problem is, I only want the page number to show if it is on a page other than the current page. Here is what I tried
\renewcommand{\eqref}[1]{(\ref{#1})(\if\thepage=\pageref{#1}{}\else{(\pageref{#1})}}

In order to invoke this I simply use \eqref in the usual way
\eqref{eq:1}

Unfortunately, it doesn't work. No matter what, the 'not true' clause is alway executed. Something is going wrong with the comparison. I have altered the code to print out \thepage and \pageref{#1}. Even though they are the same, the page number gets printed.
Any ideas?

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Stefan Kottwitz
Site Admin
Posts: 10159
Joined: Mon Mar 10, 2008 9:44 pm

customized equation referencing with page number

Postby Stefan Kottwitz » Tue Feb 06, 2024 8:33 pm

No solution yet, but a question: did you see that referencing style in any book? I've seen a lot of scientific books, and they have never used such an idea. I would stick to the style of my favorite physics books.

Also, you could do as planned but be consistent, always using the page number, so there's no confusion about what the reference means, as it's always two numbers in parentheses.

Stefan
LaTeX.org admin

Lifetime Beginner
Posts: 3
Joined: Tue Feb 06, 2024 5:14 pm

customized equation referencing with page number

Postby Lifetime Beginner » Tue Feb 06, 2024 9:58 pm

I have never seen this in any book, but I highly recommend that authors consider using it. The reason is that equation numbers are not sequential like page numbers are. Have you ever seen a reference to an equation that is many pages away from the page you are reading. If you're like me, you open the book to approximately the place you think it should be. But you don't know if the page you have opened is before or after the page you need to be on. So you look backward and/or forward scanning each page looking for a signpost telling you which direction to move in, but you still won't know how far away your target is. After all, how many pages is it from (9.4) to (12.8)? Once you get your bearings you repeat the process, this time hopefully closer to your target page. I call this the Newton-Raphson method. But if you have the page number in hand, you know as soon as you open the book what page you are on, what direction you need to move in, and approximately how far away, all without having to scan the page for clues. When I encounter a reference I always write a note in my book telling me the page number so at least I only have to search for it once the hard way. But if the referenced equation is on the same page, I don't write a note because the equation is right there in front of my eyes. When I reread the book, (I always reread physics books because I gain insight with each rereading), I have these page numbers to look up instead of equation numbers. I write the same kind of notes for all references such as figures, tables, sections and the like.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 7 guests