.png)
각 문제가 끝나면 해당 문제에 대한 해결책의 페이지 번호를 표시하고 싶습니다.
내가 이런 짓을 하면,
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheoremstyle[
notefont=\bfseries,
notebraces={}{},
headformat={\large\NUMBER.\NOTE},
headpunct={\vspace{\topsep}\newline},
spacebelow=40pt,
prefoothook={\hfill Solução: pág. \pageref{solucao:\Currentlabel}}
]{problemastyle}
\declaretheorem[style=problemastyle]{problema}
\usepackage{answers}
\Newassociation{solucao}{Sol}{solucoes}
\renewenvironment{Sol}[1]{\begin{trivlist}
\item[\hskip\labelsep\textbf{#1.}] \label{solucao:#1} \ignorespaces}%
{\end{trivlist}}
\usepackage{hyperref}
\usepackage{lipsum}
\begin{document}
\Opensolutionfile{solucoes}
\begin{problema}[Primeiro problema]
Problema 1.
\begin{solucao}
\lipsum
\end{solucao}
\end{problema}
\begin{problema}[Segundo problema]
Problema 2.
\begin{solucao}
\lipsum[1]
\end{solucao}
\end{problema}
\begin{problema}[Terceiro problema]
Problema 3.
\begin{solucao}
\lipsum[1]
\end{solucao}
\end{problema}
\Closesolutionfile{solucoes}
\include{solucoes}
\end{document}
원하는 것을 얻었지만 페이지 번호의 링크가 모두 같은 위치를 가리키고 있습니다.
이 문제를 어떻게 바로잡을 수 있나요?
답변1
환경을 갖추어야 합니다.솔상호 참조 레이블을 생성할 뿐만 아니라 이름이 매크로의 새 정의가 되어 상호 참조 레이블을 생성할 때 \@currentHref
명령에서 사용되는 연결을 위한 명명된 대상/대상/앵커도 생성합니다. \label
를 사용할 수 있지만 \phantomsection
, 인수를 사용하여 자신만의 것을 구현할 수도 있습니다.솔-environment는 명명된 대상/대상/앵커의 이름으로도 사용됩니다. 이 경우의 주장은솔-환경은 PDF 뷰어가 대상/대상/앵커 이름의 구성 요소로 처리할 수 있는 것들로만 구성될 수 있으며 두 대상/대상/앵커는 동일한 이름을 가질 수 없습니다. 이 경우 두 개는 없습니다.솔-환경은 동일한 것으로 확장되는 인수를 가질 수 있습니다.
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheoremstyle[
notefont=\bfseries,
notebraces={}{},
headformat={\large\NUMBER.\NOTE},
headpunct={\vspace{\topsep}\newline},
spacebelow=40pt,
prefoothook={\hfill Solução: pág. \pageref{solucao:\Currentlabel}}
]{problemastyle}
\declaretheorem[style=problemastyle]{problema}
\usepackage{answers}
\Newassociation{solucao}{Sol}{solucoes}
\renewenvironment{Sol}[1]{\begin{trivlist}%
\item[\hskip\labelsep\SolutionAnchor{#1}\textbf{#1.}]\ignorespaces}%
{\end{trivlist}}%
\makeatletter
\DeclareRobustCommand\SolutionAnchor[1]{%
\begingroup
\Hy@localanchornametrue
\Hy@MakeCurrentHref{solution.#1}%
\Hy@raisedlink{\hyper@anchorstart{\@currentHref}\hyper@anchorend}%
\label{solucao:#1}%
\endgroup
}%
%
% Alternatively, using \phantomsection:
%
% \DeclareRobustCommand\Hy@SolutionAnchor[1]{%
% \begingroup
% \Hy@localanchornametrue
% \phantomsection
% \label{solucao:#1}%
% \endgroup
% }%
%
% Or, with a very recent TeX installation, use \MakeLinkTarget*
%
%\DeclareRobustCommand\SolutionAnchor[1]{%
% \MakeLinkTarget*{solution.#1}%
% \label{solucao:#1}%
%}%
\makeatother
\usepackage{hyperref}
\usepackage{lipsum}
\begin{document}
\Opensolutionfile{solucoes}
\begin{problema}[Primeiro problema]
Problema 1.
\begin{solucao}
\lipsum
\end{solucao}
\end{problema}
\begin{problema}[Segundo problema]
Problema 2.
\begin{solucao}
\lipsum[1]
\end{solucao}
\end{problema}
\begin{problema}[Terceiro problema]
Problema 3.
\begin{solucao}
\lipsum[1]
\end{solucao}
\end{problema}
\Closesolutionfile{solucoes}
\include{solucoes}
\end{document}