可点击的问题书

可点击的问题书

我开始clickable用 编写一本问题书fortextbook。问题:编译为 PDF 后,在 Acrobat Reader 中设置页面适合宽度,如果我单击例如问题 1,它会跳转到解决方案 2,或者单击解决方案 1 旁边的方块,它会跳转到问题 2。

代码:

\documentclass{article}
\usepackage{amsmath}

\usepackage[latextoc,dvips,pdflatex]{web}  % dvipsone, dvips, pdftex, dvipdfm

\usepackage[links,pdftex,fortextbook,nomarginwrite,usecustomdesign,
ftbsolns, forcolorpaper,noseparationrule,usexkv]{eqexam}

\begin{document}

\begin{probset}
{{\thesection} Solutions}%\label{probGrpANS}

\begin{problem}[7]
Solve the equation $ x^2 - 3x + 1 = 0 $ using the \emph{method of
completing the square}. \ANS{$x=\frac{3}{2}-\frac{\sqrt5}{2}$,
            $\frac{3}{2}+\frac{\sqrt5}{2}$}
\begin{solution}[]
\begin{ssol}
$ x = \frac{3}{2}-\frac{\sqrt5}{2},                \frac{3}{2}+\frac{\sqrt5}{2}$
\end{ssol}
\begin{lsol}
We use standard methods.
\begin{align*}
    x^2 - 3x + 1 &= 0 \\
    x^2 - 3x &= -1\\
    x^2 - 3x + \frac{9}{4} &= -1 + \frac{9}{4}\\
    ( x - \frac{3}{2} )^2 &= \frac{5}{4}\\
            x - \frac{3}{2} &= \pm\frac{\sqrt5}{2}\\
            x &= \frac{3}{2} \pm\frac{\sqrt5}{2}
            \qquad\makebox[0pt][l]{\text{The solutions are $\boxed{ x = \frac{3}{2}-\frac{\sqrt5}{2},                \frac{3}{2}+\frac{\sqrt5}{2}}$}}
\end{align*}
\end{lsol}
\end{solution}
\end{problem}

\begin{problem}
Solve the equation $ x^2 - 4x + 8 = 0 $ using the \emph{quadratic formula}.
Simplify your final answer. \ANS{$x=2\pm2\imath$}
\begin{solution}[]
\begin{ssol}
$x=2\pm2\imath$
\end{ssol}
\begin{lsol}
We apply the quadratic formula:
\begin{align*}
    x &= \frac{4\pm\sqrt{16-4(1)(8)}}{2}\\
      &= \frac{4\pm\sqrt{16-32}}{2}\\
      &= \frac{4\pm\sqrt{-16}}{2}\\
      &= \frac{4\pm 4\imath}{2}\\
      &= 2\pm2\imath
\end{align*}
The solutions are $ \boxed{ x = 2-2\imath,\ 2+2\imath }$.
\end{lsol}
\end{solution}
\end{problem}

\end{probset}

\newpage

\includeexersolutions

\end{document}

答案1

问题在于使用后台使用的包(该\hypertarget包,\hyperlinkhyperrefeqexamhttp://ftp.cstug.cz/pub/tex/CTAN/macros/latex/contrib/eqexam.zip)。

原因似乎是它的锚点被设置为框的基线(#2)而不是框的左上角。我附上了一个补丁,除了常规的框高度升高之外,您还可以选择左右和上下移动。命令的重新定义\hypertarget使用\raisebox\kern命令。

经您允许,我还修复了环境\section内部的该问题probset。我已添加\noexpand,它似乎正常工作。我附上了一个如何使用此补丁的示例以及这两个页面的预览。祝您的项目好运!

%! {pdf|lua}latex clickable-book.tex
\documentclass{article}
\usepackage{amsmath}
\usepackage[latextoc, pdftex]{web}% dvipsone, dvips, pdftex, dvipdfm [latextoc, dvips, pdftex]
\usepackage[links, fortextbook, %pdftex,
   nomarginwrite, usecustomdesign, ftbsolns, forcolorpaper, noseparationrule, usexkv,
  ]{eqexam}
\textbookOpts{instred,lsols}

% The patch...
\newbox\malbox
\let\malhypertarget=\hypertarget
\newdimen\malreserve \malreserve=8mm% Reserve for moving left and right...
\newdimen\malreserveup \malreserveup=0.5\baselineskip% Reserve for moving up and down...
\def\hypertarget#1#2{% 
  \setbox\malbox=\hbox{#2}% What am I dealing with?
  \advance\malreserveup by \ht\malbox% Reserve plus the height of the box...
  \raisebox{\malreserveup}[0pt][0pt]{% Moving target up....
  \kern-\malreserve\relax% Moving it left...
  \malhypertarget{#1}{% The real \hypertarget is applied.
  \raisebox{-\malreserveup}[0pt][0pt]{\kern\malreserve#2}% Moving it down and right...
  }% End of \malhypertarget...
 }% End of \raisebox...
}% End of new \hypertarget...

\begin{document}
\section{My set of problems}

\begin{probset}
{\noexpand\section{My set of solutions}\noexpand\label{probGrpANS}}

\begin{problem}[7]\strut
Solve the equation $ x^2 - 3x + 1 = 0 $ using the \emph{method of
completing the square}. 
\ANS{\strut$x=\frac{3}{2}-\frac{\sqrt5}{2}$,
            $\frac{3}{2}+\frac{\sqrt5}{2}$}
\begin{solution}[]
\begin{ssol}
$ x = \frac{3}{2}-\frac{\sqrt5}{2},\
            \frac{3}{2}+\frac{\sqrt5}{2}$
\end{ssol}
\begin{lsol}
We use standard methods.
\begin{align*}
    x^2 - 3x + 1 &= 0 \\
    x^2 - 3x &= -1\\
    x^2 - 3x + \frac{9}{4} &= -1 + \frac{9}{4}\\
    \left( x - \frac{3}{2} \right)^2 &= \frac{5}{4}\\
            x - \frac{3}{2} &= \pm\frac{\sqrt5}{2}\\
            x &= \frac{3}{2} \pm\frac{\sqrt5}{2}
            %\qquad\makebox[0pt][l]{\text{The solutions are $\boxed{ x = \frac{3}{2}-\frac{\sqrt5}{2},\ \frac{3}{2}+\frac{\sqrt5}{2}}$}}
\end{align*}
% I would prefer that part typeset over here...
The solutions are $\boxed{ x = \frac{3}{2}-\frac{\sqrt5}{2},\ \frac{3}{2}+\frac{\sqrt5}{2}}$
  \bigskip% Manual intervention between solutions...
\end{lsol}
\end{solution}
\end{problem}

\begin{problem}\strut
Solve the equation $ x^2 - 4x + 8 = 0 $ using the \emph{quadratic formula}.
Simplify your final answer. 
   \ANS{\strut$x=2\pm2\imath$}
\begin{solution}[]
\begin{ssol}
$x=2\pm2\imath$
\end{ssol}
\begin{lsol}
We apply the quadratic formula:
\begin{align*}
    x &= \frac{4\pm\sqrt{16-4(1)(8)}}{2}\\
      &= \frac{4\pm\sqrt{16-32}}{2}\\
      &= \frac{4\pm\sqrt{-16}}{2}\\
      &= \frac{4\pm 4\imath}{2}\\
      &= 2\pm2\imath
\end{align*}
The solutions are $ \boxed{ x = 2-2\imath,\ 2+2\imath }$.
\end{lsol}
\end{solution}
\end{problem}
\end{probset}

% There has been no need for this part...
%\newpage
%\includeexersolutions% or
%\input\jobname.sol
\end{document}

姆韦

相关内容