SHARE
TWEET

Untitled

a guest Nov 6th, 2015 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \documentclass{article}
  2.  
  3. \usepackage{lipsum}% Just for this example
  4. \usepackage{refcount,hyperref,graphicx}
  5.  
  6. \newcount\cnt
  7. \let\oldref\ref
  8.  
  9. \AtBeginDocument{%
  10.    \renewcommand\ref[1]{%
  11.      \cnt=\value{page}%
  12.      \advance\cnt by -2
  13.      \ifnum\cnt > \getpagerefnumber{#1}
  14.     \oldref{#1}~p.\,\pageref{#1}%
  15.      \else
  16.      \oldref{#1}%
  17.      \fi
  18.     }
  19.   }
  20.  
  21. \begin{document}
  22. \sloppy% Just for this example
  23. \lipsum[1]
  24.  
  25. Figure~\ref{fig:example_image}.
  26.  
  27. \begin{figure}[ht]
  28.  \centering
  29.  \includegraphics[width=0.6\textwidth]{example-image}%
  30.   \caption{example-image}\label{fig:example_image}
  31. \end{figure}
  32.  
  33. \lipsum[2-13]
  34.  
  35. \lipsum*[14]
  36. Figure~\ref{fig:example_image}.
  37.  
  38. \end{document}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top