如何在水平规则之间格式化练习,并在页脚中链接到解决方案?

如何在水平规则之间格式化练习,并在页脚中链接到解决方案?

我怎样才能获得这种练习风格并点击更正以转到那里

谢谢 在此处输入图片描述

答案1

这是不使用 TikZ 的答案:您必须使用诸如的命令定义页脚将链接到的目标标签\phantomsection\label{ans:imag},然后将其作为参数传递给环境,例如\begin{equation}{label:imag}。如果目标是、使用创建的环境或作为有效链接锚点的另一个命令,则\phantomsection不需要。如果您收到有关可能已更改的引用的警告,请重新编译第二次,它将正常工作。\section\newtheoremhyperref

我使用unicode-math,但由于您还指定了 PDFLaTeX:这种方法对于经典软件包同样适用。例如,这里的所有符号也都在stix和中stix2,或者使用您选择的字体包。

\documentclass[12pt]{article}
\usepackage[paperwidth=10cm]{geometry} % Solely to crop the MWE on TeX.SX.
\usepackage[french]{babel}
\usepackage{unicode-math} % Or your font packages of choice, e.g. bera.
\usepackage{xparse} % For \NewDocumentEnvironment
\usepackage{xfrac} % For \sfrac.
\usepackage[svgnames, Svgnames]{xcolor}
\usepackage[colorlinks, linkcolor=MediumVioletRed, unicode]{hyperref}

\defaultfontfeatures{ Scale = MatchLowercase, Ligatures = TeX }
\setmainfont{Fira Sans}[Scale = 1.0]
\setsansfont{Fira Sans}
\setmonofont{Fira Code}
\setmathfont{Fira Math}
\setmathfont[range={\blacktriangledown, \QED}]{XITS Math}

% Use the tombstone symbol for Q.E.D., as in some editions of DEK’s Art of
% Computer Programming.  Will be used at the end of exercises and also proofs.
\DeclareRobustCommand\qedsymbol{\ensuremath{\QED}}

% The imaginary unit, here set upright:
\newcommand\iu{\symup{i}}

\newcounter{ExerciseCtr}

\NewDocumentEnvironment{exercise}
% It would be possible to specify formatting, such as "Exercise/Exercise"
% and the symbols in the footer, as parameters here, e.g. G{Exercise}.  In
% practice, YAGNI.
%
% The argument is the label of the answers, e.g. \begin{exersise}{ans:imag}
{m}
{\refstepcounter{ExerciseCtr}%
\begingroup\normalfont\bfseries\selectfont%
\bigskip\par\noindent\phantomsection{}%
Exercice \arabic{ExerciseCtr}\endgroup\\*%
\makebox[\textwidth]{\hrulefill}\\[0.5\baselineskip]
\begingroup\normalfont\ignorespaces%
}
{\endgroup%
\par\noindent\begingroup\normalfont\ttfamily%
\hyperref[#1]{Correction \(\blacktriangledown\)}%
\hfill\qedsymbol\endgroup\\*%
\makebox[\textwidth]{\hrulefill}%
\medskip\par\ignorespaces%
}

% Also provide an unnumbered exercise*, by analogy with the ams environments.
\NewDocumentEnvironment{exercise*}
{m}
{%
\begingroup\normalfont\bfseries\selectfont%
\bigskip\par\noindent\phantomsection{}%
Exercice\endgroup\\*%
\makebox[\textwidth]{\hrulefill}\\[0.5\baselineskip]
\begingroup\normalfont\ignorespaces%
}
{\endgroup%
\par\noindent\begingroup\normalfont\ttfamily%
\hyperref[#1]{Correction \(\blacktriangledown\)}%
\hfill\qedsymbol\endgroup\\*%
\makebox[\textwidth]{\hrulefill}%
\medskip\par\ignorespaces%
}

\begin{document}
\noindent Lorem ipsum dolor sit amet.
\begin{exercise}{ans:imag}\label{exer:1}
Écrire sous la forme \(a + \iu b\) les nombres complexes suivants:

  \begin{enumerate}
    \item Nombre de module \(2\) et d'argument
          \(\displaystyle\sfrac{\uppi}{3}\).
    \item Nombre de module \(2\) et d'argument
          \(\displaystyle\sfrac{-\uppi}{8}\).
  \end{enumerate}
\end{exercise}

\begin{exercise*}{ans:imag}
Un exercise.  
\end{exercise*}

\phantomsection\label{ans:imag}
Reportez-vous à l'exercice \ref{exer:1}.
\end{document}

示例练习

相关内容