TeX - LaTeX Asked by paz zini on December 22, 2020
How can I get this style of exercise and click at the correction to go there
Here is an answer without TikZ: You must define the target label that the footer will link to with a command such as phantomsectionlabel{ans:imag}
and then pass it to the environment as a parameter, such as begin{equation}{label:imag}
. The phantomsection
is not required if the target is a section
, an environment created with newtheorem
, or another command that is a valid link anchor in hyperref
. If you get a warning about references that may have changed, recompile a second time and it will work properly.
I use unicode-math
, but since you also specified PDFLaTeX: this approach would work just as well with classic packages. For example, all the symbols here are also in stix
and stix2
, or use your font packages of choice.
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.
DeclareRobustCommandqedsymbol{ensuremath{QED}}
% The imaginary unit, here set upright:
newcommandiu{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}%
begingroupnormalfontbfseriesselectfont%
bigskipparnoindentphantomsection{}%
Exercice arabic{ExerciseCtr}endgroup*%
makebox[textwidth]{hrulefill}[0.5baselineskip]
begingroupnormalfontignorespaces%
}
{endgroup%
parnoindentbegingroupnormalfontttfamily%
hyperref[#1]{Correction (blacktriangledown)}%
hfillqedsymbolendgroup*%
makebox[textwidth]{hrulefill}%
medskipparignorespaces%
}
% Also provide an unnumbered exercise*, by analogy with the ams environments.
NewDocumentEnvironment{exercise*}
{m}
{%
begingroupnormalfontbfseriesselectfont%
bigskipparnoindentphantomsection{}%
Exerciceendgroup*%
makebox[textwidth]{hrulefill}[0.5baselineskip]
begingroupnormalfontignorespaces%
}
{endgroup%
parnoindentbegingroupnormalfontttfamily%
hyperref[#1]{Correction (blacktriangledown)}%
hfillqedsymbolendgroup*%
makebox[textwidth]{hrulefill}%
medskipparignorespaces%
}
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
(displaystylesfrac{uppi}{3}).
item Nombre de module (2) et d'argument
(displaystylesfrac{-uppi}{8}).
end{enumerate}
end{exercise}
begin{exercise*}{ans:imag}
Un exercise.
end{exercise*}
phantomsectionlabel{ans:imag}
Reportez-vous à l'exercice ref{exer:1}.
end{document}
Answered by Davislor on December 22, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP