\ autorefコマンドを次のように変更したいと思います。\autorefコマンドとラベルが同じページにある場合、\ autoref *のように動作します(つまり、ハイパーリンクがありません)。それ以外の場合は、通常どおりに動作します。
ありがとう、ヴィシュヌ
\ autorefコマンドを次のように変更したいと思います。\autorefコマンドとラベルが同じページにある場合、\ autoref *のように動作します(つまり、ハイパーリンクがありません)。それ以外の場合は、通常どおりに動作します。
ありがとう、ヴィシュヌ
\myautoref
の代わりに使用できる場合\autoref
、次は希望どおりに機能します。
\documentclass{article}
\usepackage{lipsum}
\usepackage[pdftex,colorlinks]{hyperref}
\makeatletter
\def\my@setref#1#2#3{%
\ifx#1\relax\protect\G@refundefinedtrue
\else\expandafter#2#1\fi}
\def\pagenum#1{\expandafter\my@setref\csname
r@#1\endcsname\@secondoffive{#1}}%
\def\myautoref#1{\def\refnum{\pagenum{#1}}%
\ifnum\refnum=\thepage\relax\autoref*{#1}%
\else\autoref{#1}\fi}
\makeatother
\begin{document}
\section{First}\label{first}
\lipsum[1-3]
\myautoref{first}
\lipsum[4-8]
\myautoref{first}
\end{document}
類似の問題を解決する必要があり、より短いものを見つけました(私にとってはより理解しやすい):
\usepackage{ifthen}
\newcommand{\myautoref}[1]{
\ifthenelse%
{\equal{\pageref{#1}}{\thepage}}%
{\autoref*{#1}}%
{\autoref{#1}}
}