对于问题库(仅限 pdf CC 版本),我定义了超链接和超目标,如中所述添加另一个与问题本身超链接的答案。
为了排版更多章节(如本回答评论中所述),我尝试添加 \thechapter\thesection\thequestion。我成功将 Problems 链接到 Shortsolutions 和 Longsolutions。但反向链接失败。
有人能帮帮我吗,我正在发布我的 MWE。
\documentclass{memoir}
\usepackage{answers}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{pgffor}
\hypersetup{colorlinks=true}
\setlength{\parindent}{0.0mm}
% very useful during de-bugging!
\usepackage[left]{showlabels}
\showlabels{hypertarget}
\showlabels{hyperlink}
% solutions files
% short solutions
\Newassociation{shortsolution}{shortSoln}{shortsolutions}
% long solutions
\Newassociation{longsolution}{longSoln}{longsolutions}
% new environment that sets up hypertargets both in the question
% section, and in the answer section
\newlist{myenum}{enumerate}{3}
\newcounter{question}[chapter]
\newenvironment{question}[1]%
{%
\refstepcounter{question}%
% hyperlink to solution
\hypertarget{question:{\thequestion}}{}%
\Writetofile{shortsolutions}{\protect\hypertarget{shortsoln:\thequestion}{}}%
\Writetofile{longsolutions}{\protect\hypertarget{longsoln:\thequestion}{}}%
\begin{myenum}[label=\bfseries\protect\hyperlink{shortsoln:\thequestion}{\thequestion},ref=\thequestion]
\item%
\hypersetup{linkcolor=blue}%
\hyperlink{longsoln:\thequestion}{#1}%
}%
{%
\end{myenum}}
\begin{document}
\chapter{Questions and Answers}
%\Opensolutionfile{ans}[\jobname ans\thechapter]
\Opensolutionfile{shortsolutions}[\jobname key\thechapter]
\Opensolutionfile{longsolutions}[\jobname sol\thechapter]
\section{Questions}
\begin{multicols}{3}
\begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
\begin{shortsolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{shortsolution}
\begin{longsolution}
In order to do this, we must first make a substitution\ldots
\end{longsolution}
\end{question}
\begin{question}{$\int(2x-1)^{50}\mathrm{d}x$}
\begin{shortsolution}
$\frac{1}{102}(2x-1)^{51}+C$
\end{shortsolution}
\begin{longsolution}
A very long solution| much longer than the shorter solution
\end{longsolution}
\end{question}
\begin{question}{$\int\sqrt[n]{x}\mathrm{d}x$}
\begin{shortsolution}
$\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
\end{shortsolution}
\begin{longsolution}
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
\end{longsolution}
\end{question}
\end{multicols}
% close solution files
\Closesolutionfile{shortsolutions}
\Closesolutionfile{longsolutions}
\chapter{Two and Second Similar One}
%\Opensolutionfile{ans}[\jobname ans\thechapter]
\Opensolutionfile{shortsolutions}[\jobname key\thechapter]
\Opensolutionfile{longsolutions}[\jobname sol\thechapter]
\section{Questions}
\begin{multicols}{3}
\begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
\begin{shortsolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{shortsolution}
\begin{longsolution}
In order to do this, we must first make a substitution\ldots
\end{longsolution}
\end{question}
\begin{question}{$\int(2x-1)^{50}\mathrm{d}x$}
\begin{shortsolution}
$\frac{1}{102}(2x-1)^{51}+C$
\end{shortsolution}
\begin{longsolution}
A very long solution| much longer than the shorter solution
\end{longsolution}
\end{question}
\begin{question}{$\int\sqrt[n]{x}\mathrm{d}x$}
\begin{shortsolution}
$\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
\end{shortsolution}
\begin{longsolution}
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
\end{longsolution}
\end{question}
\end{multicols}
% close solution files
\Closesolutionfile{shortsolutions}
\Closesolutionfile{longsolutions}
\chapter{Answers to the Problems}
% renew the SHORT solution environment so that it hyperlinks back to
% the question
\renewenvironment{shortSoln}[1]{%
% add some glue
\vskip .5cm plus 2cm minus 0.1cm%
{\bfseries \hyperlink{question:#1}{#1.}}%
}%
{%
}%
% input the file if it exists
%\IfFileExists{shortsolutions.tex}{\input{shortsolutions.tex}}{}
\foreach \i in {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...,15} {%
\edef\FileName{\jobname key\i}% The % here are necessary to eliminate any
\IfFileExists{\FileName}{% spurious spaces that may get inserted
\input{\FileName}% at these points
}
}
\clearpage
\chapter{Solutions}
% renew the LONG solution environment so that it hyperlinks back to
% the question
\renewenvironment{longSoln}[1]{%
% add some glue
\vskip .5cm plus 2cm minus 0.1cm%
{\bfseries \hypersetup{linkcolor=blue}\hyperlink{question:#1}{#1.}}%
}%
{%
}%
% input the file if it exists
%\IfFileExists{longsolutions.tex}{\input{longsolutions.tex}}{}
%Input all Solutions files as they appear Chapter-wise properly hyperlinked.
\foreach \i in {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...,15} {%
\edef\FileName{\jobname sol\i}% The % here are necessary to eliminate any
\IfFileExists{\FileName}{% spurious spaces that may get inserted
\input{\FileName}% at these points
}
}
\end{document}