
see Section \ref{labelname}
나는 생산물을 갖는 대신에 멍하니 궁금해하고 있었다
섹션 4.1.1 참조
난 그렇게 만들 수 see Section \ref{labelname}
있어요
섹션 4.1.1 참조(p65)
이것이 가능한가? 이걸 사용하면 hyperref
엉망이 될까요?
답변1
\myref와 같은 명령을 정의할 수 있습니다.
\newcommand{\myref}[1]{\ref{#1} (p\pageref{#1})}
그런 다음 사용할 수 있습니다\myref{xxx}
답변2
더 깨끗한 방법은 의 답변과 같은 새로운 매크로입니다 goodluck
. 하지만 \ref
재정의할 수도 있습니다. 많은 패키지가 이를 재정의하므로 가능한 한 늦게 수행해야 합니다. 솔루션에서는 특히 패키지가 로드된 \AtBeginDocument
후 서문 끝 에서 수행됩니다.hyperref
또한 패키지는 hyperref
링크 없이 참조를 생성하는 별 모양을 지원합니다. 예를 들어, 이는 중첩된 링크를 피하기 위해 참조가 다른 참조의 일부인 경우 유용합니다.
\documentclass{article}
\usepackage{hyperref}
\makeatletter
\AtBeginDocument{%
\newcommand*{\original@ref}{}%
\let\original@ref\ref
\@ifpackageloaded{hyperref}{%
\renewcommand*{\ref}{%
\@ifstar\newrefstar\newref
}%
\newcommand*{\newrefstar}[1]{%
\original@ref*{#1} \textbf{(p\pageref*{#1})}%
}%
\newcommand*{\newref}[1]{%
\hyperref[#1]{\newrefstar{#1}}%
}%
}{%
\renewcommand*{\ref}[1]{%
\original@ref{#1} \textbf{(p\pageref{#1})}%
}%
}%
}
\makeatother
\begin{document}
\section{Introduction}
\section{Foo bar}
\subsection{Hello World}
\label{sec:hello}
This is subsection \ref{sec:hello}.
\end{document}
답변3
어쩌면 당신은varioref
명령을 사용하여 패키지합니다 \vref
. 그러면 원하는 출력이 생성됩니다. 또한 이는 hyperref
설정에 영향을 주지 않습니다.