[texhax] target page number of label

Pedro Santos pmsantos at dec.uc.pt
Tue Dec 20 15:54:38 CET 2005


I read your first post very quickly and misunderstood it. I thought that
you only want to get the reference to the page.
Try this, I think this is what you really want. Tell me if it was
usefull.


\documentclass[12pt]{article}
% graphicx package to work with pictures
\usepackage{graphicx}
% ifthen package to provide logical operations between the figure and
page numbers
\usepackage{ifthen}

\begin{document}

% define your own command "ReferenceToFigure", with three parameters,
the first is the reference to your figure, the second the figure page,
and the third is the page in which is inserted the reference to the
figure
\newcommand{\ReferenceToFigure}[3]
{
 \ifthenelse{\equal{#2}{#3}}{Figure #1}{Figure #1 on page #2}
}

% insert your picture
\begin{figure}
 \includegraphics[height=1cm]{tux.png}
 \caption{TUX Picture}
 \label{fig:tux}
\end{figure}

% create a reference to your picture in the same page, with no reference
to the page number itself
bla bla bla, with a reference to
\ReferenceToFigure{\ref{fig:tux}}{\pageref{fig:tux}}{\thepage}, in the
same page\\

\newpage

% create a reference to your picture in a different page, with reference
to the page number
bla bla bla, with a reference to
\ReferenceToFigure{\ref{fig:tux}}{\pageref{fig:tux}}{\thepage}, which is
in another page\\

\end{document}


Pedro Santos
Portugal



On Tue, 2005-12-20 at 15:09 +0100, attila marxer wrote:
> hi,
> 
> thanks for the answer. unfortunately using pdflatex (sorry i
> didn't mention it before), \pageref{label} creates a link. 
> but what i need is the plain number so i can compare it
> to the value of counter 'page' ...?
> 
> any idea?
> 
> thanks,
> Attila
> 
> 
> On Mon, 2005-12-19 at 20:18 +0000, Pedro Santos wrote:
> > Try this
> > 
> > \begin{figure}
> > \includegraphics{mypicture.jpg}
> > \caption{My Picture}
> > \label{fig:mypicture}
> > \end{figure}
> > 
> > and now insert in your text something like this:
> > bla bla bla reference to Figure ~\ref{fig:mypicture} on page ~\pageref{fig:mypicture} bla bla bla
> > 
> > 
> > Pedro Santos
> > Portugal
> > 
> > 
> > 
> > On Mon, 2005-12-19 at 18:05 +0100, attila marxer wrote:
> > > hi everybody :)
> > > 
> > > let's say, i've got a figure 3.2 on page 7 labelled
> > > "fig:somefigure". what i would like to have, is a
> > > macro \someref{fig:somefigure} which results in
> > > (a) "figure 3.2" if the figure appears on the same
> > > page as the text and
> > > (b) "figure 3.2, p.7" otherwise.
> > > 
> > > however, this requires to check the current page
> > > number against the page of the label (the page
> > > where the float is finally placed)
> > > 
> > > i'm not into TeX at all, even though i tried to look
> > > at the pageref source. so anybody who can tell me how
> > > i get the plain page number of a label?
> > > 
> > > thanks!
> > > 
> > > Attila
> > > 
> > > _______________________________________________
> > > TeX FAQ: http://www.tex.ac.uk/faq
> > > Mailing list archives: http://tug.org/pipermail/texhax/
> > > More links: http://tug.org/begin.html
> > > 
> > > Automated subscription management: http://tug.org/mailman/listinfo/texhax
> > > Human mailing list managers: postmaster at tug.org
> > 
> > 



More information about the texhax mailing list