#StackBounty: #hyperref #lists #exercises Using the Exercise package, how do we get the title of an answer group to match that of the e…

Bounty: 100

%--------------------------------------------------------------------------------------------------------- %
documentclass[english]{book}
%--------------------------------------------------------------------------------------------------------- %
%
usepackage[fleqn]{amsmath} %
usepackage[explicit]{titlesec} %
usepackage{titletoc} %
usepackage{fancyhdr} %
usepackage{fancyref} %
usepackage{babel} %
usepackage{tikz} % tikz - essential
usepackage{newtxtext} %
usepackage{libertine} %
usepackage{setspace} %
usepackage{colortbl} % changed to just colortbl
usepackage{stackengine} %
usepackage[paperwidth=170mm,paperheight=240mm,textwidth=132mm,lmargin=12.5mm,rmargin=12.5mm,bindingoffset=12.5mm,noheadfoot,nomarginpar,showframe,showcrop]{geometry}
usepackage[a4,frame,cam,center]{crop} %
usepackage{stackengine} %
usepackage{graphicx} %
usepackage[skins,theorems,most]{tcolorbox} %
usepackage{ifpdf} %
usepackage{exercise} %
usepackage{ifthen}newboolean{firstanswerofthechapter} %
usepackage{hyperref} %

definecolor{ThemeColor}{rgb}{0.50,0.04,0.04} % ThemeColor DarkRed
definecolor{DarkBlue}{rgb}{0.00,0.08,0.45} % #000086
definecolor{DarkOrange}{rgb}{0.55,0.22,0.05} % #FB9902
definecolor{DarkRed}{rgb}{0.45,0.06,0.06} % #880000
definecolor{LightOrange}{rgb}{1.00,0.87,0.64} % #FB9902
definecolor{LightYellow}{rgb}{1.00,1.00,0.85}

tcbset{myinnerbox/.style={no shadow, shrink tight, arc=1.5pt, extrude by=2.0mm,
colframe=black, boxrule=0.7pt, frame style={opacity=0.25},
interior style={opacity=0.5}, colback=black!5!white}}

%
% ------------------------------------- Exercise preliminaries ------------------------------------------- %
%

makeatletter
let @subQuestionHeader@original=@subQuestionHeader
newcommand{@subQuestionHeader@noItem}{ %
    hspace{0pt} % between (a) and (b)
    begingroup
        @getsubQuestionInfo
        subQuestionHeaderDifficulty
        subQuestionNBhspace{0.4pt} % adjust space from the ) bracket
    endgroup
    begingroup
        @getsubQuestionInfo
        subQuestionHeaderTitle
    endgroup % affects subquestion on new line
    ignorespaces
        }

newcommand{subQuestionOnSameLine}{ %
    let @subQuestionHeader=@subQuestionHeader@noItem
    subQuestion
}
newcommand{subQuestionOnNewLine}{ %
    let @subQuestionHeader=@subQuestionHeader@original {} % \[-9pt]
    subQuestion
}
makeatother

makeatletter
defendExerciseEnv{termineliste{1}@EndExeBoxvspace{6pt}%
vskipExerciseSkipAfter}

gdefendAnswerEnv{termineliste{1}@EndExeBoxvspace{8pt}termineliste{0}vskipAnswerSkipAfter}
makeatother

renewcommand{AtBeginExercise}{vspace{-6pt}}
%
% ----------------------------------------------- Define counters ------------------------------------ %
%
numberwithin{Exercise}{chapter} % ! not counterwithin
numberwithin{Answer}{chapter}
newcounter{problem}[Exercise] %

renewcommand{ExerciseName}{Exercise}
renewcommand{QuestionNB}{tcbhighmath[size=fbox,colframe=DarkRed,colback=blue!12!white]{arabic{Question}}hspace{3.2pt}}
renewcommand{QuestionHeaderTitle}{emph{(QuestionTitle)} }
renewcommand{subQuestionNB}{alph{subQuestion}hspace{0.7pt})hspace{1.3pt}}
renewcommand{ExerciseHeaderTitle}{hspace{2.4pt}-hspace{1.6pt}-hspace{1.6pt}-;ExerciseTitle}
renewcommand{QuestionHeaderDifficulty}{theQuestionDifficulty }


% Setting up the EXERCISES header (conditional)...
renewcommand{ExerciseHeader}
{ifthenelse{boolean{firstanswerofthechapter}} % line 1
%
{newpagenoindenthspace{1.5pt}vspace*{4pt} % line 2

% AAAAAAAAAAAA
{libertineSBfontsize{12}{14}selectfont{text{Exercises based on the content of text{chapterhspace{2.4pt}thechapter}}}} % END OF MAJOR TITLE line 5

vspace{9pt} % BBBBBBBBBBBB
noindentdefstackalignment{l}stackunder[4.5pt]{colorbox{LightOrange} % line 6
{libertineSBfontsize{11.5}{15}selectfont{textcolor{ThemeColor}{Exercise~ExerciseHeaderNB}}}ExerciseHeaderTitlenewlinesmallskip}
{textcolor{DarkOrange}{rule{linewidth}{1.2pt}}}} % ELSE line 7
%
    {noindentdefstackalignment{l}stackunder[4.5pt]{colorbox{LightOrange} % line 8
%
        {libertineSBfontsize{11.5}{15}selectfont{textcolor{ThemeColor} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   
{Exercise~ExerciseHeaderNB}}}ExerciseHeaderTitlenewlinenewlinesmallskip} % line 9
{textcolor{DarkOrange}{rule{linewidth}{1.2pt}}}}} % line 10



% Setting up the ANSWERS header (conditional)...
renewcommand{AnswerHeader}
{ifthenelse{boolean{firstanswerofthechapter}} % this is correct
%
{newpagenoindenthspace{1.5pt}vspace*{4pt}
% AAAAAAAAAAAA
{libertineSBfontsize{11}{14}selectfont{Answershspace{1.2pt}/hspace{0.1pt}solutions to exercises based on text{chapterhspace{2.4pt}thechapter}}}  % END OF MAJOR TITLE line 5

vspace{9pt} % BBBBBBBBBB
noindentdefstackalignment{l}stackunder[4.5pt]
{colorbox{LightOrange} % continue
{libertineSBfontsize{11}{14}selectfont{textcolor{ThemeColor}
{Answers to exercise~ExerciseHeaderNBhspace{3.4pt}on hspace{0.6pt}phspace{1.5pt}pageref{AnswerRef}
ExerciseHeaderTitle},}}} %
{textcolor{DarkOrange}{rule{linewidth}{1.2pt}}}vspace{3pt}} % ELSE line 7
%
%
{noindentdefstackalignment{l}stackunder[4.5pt]{colorbox{LightOrange} % line 8
%
        {libertineSBfontsize{11}{14}selectfont{textcolor{ThemeColor} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
{Answers to exercise~ExerciseHeaderNBhspace{3.4pt}on hspace{0.6pt}phspace{1.5pt}pageref{AnswerRef}
ExerciseHeaderTitle},}}} %
{textcolor{DarkOrange}{rule{linewidth}{1.2pt}}}vspace{3pt}}}


begin{document}

setstretch{1.20}
chapter{} % Chapter 1

setboolean{firstanswerofthechapter}{true}
begin{Exercise}[title={title of FIRST exercise},label=chap_01_exer_01] % EX 1_1
Question{Question 1}
Question{Question 2}
end{Exercise}

setboolean{firstanswerofthechapter}{false}
begin{Exercise}[title={title of SECOND exercise},label=chap_01_exer_02] % EX 1_2
Question{Question 1}
Question{Question 2}
end{Exercise}

begin{Exercise}[title={title of THIRD exercise},label=chap_01_exer_03] % EX 1_3

Question{Question 1}
Question{Qustion 2}
end{Exercise}

setboolean{firstanswerofthechapter}{true}
begin{Answer}[ref={chap_01_exer_01}]
Question{Answer to question 1}
Question{Answer to question 2}
end{Answer}

vspace{6pt}
noindent {color{DarkBlue}fontsize{11}{12}selectfont{The wordinghspace{0.6pt}: ``,title of THIRD exercise,'' is what I wish to change - it should be the

noindent same as the title description in the corresponding questionhspace{0.7pt}.

vspace{4pt}
noindent It suggests the use of a construction using a ``,hash $1$,'' - but I do not understand that.}}

vspace{15pt}
setboolean{firstanswerofthechapter}{false}
begin{Answer}[ref={chap_01_exer_02}]
Question{Answer to question 1}
Question{Answer to question 2}
end{Answer}

begin{Answer}[ref={chap_01_exer_03}]
Question{Answer to question 1}

Question{Answer to question 2}
end{Answer}

end{document}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.