
在每個問題的末尾,我希望標明該問題的解決方案的頁碼。
如果我做這樣的事情,
\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}