How to automatically link questions and solutions with the Exsheets package?
I'm writing up some lecture notes that contain questions/problems for the reader scattered accross the text. The solutions are provided in the end of each chapter. Exsheets appears to be a nice package for doing so.
Students will use the document mainly electronically and so I'd like to hyperlink each question to the corresponding answer and vice-versa. Now exsheets has the option to auto-label
each question with label{qu:id}
and the id
is generated automatically as well. So far so good.
Using the headings
, solution/pre-hook
or solution/post-hook
options I tried referencing the corresponding label, but don't manage to construct it. I tried using CurrentQuestionID
which, however, is empty when in the solution environment.
Any ideas how to accomplish the cross-linking automatically? Thanks!
cross-referencing exsheets
add a comment |
I'm writing up some lecture notes that contain questions/problems for the reader scattered accross the text. The solutions are provided in the end of each chapter. Exsheets appears to be a nice package for doing so.
Students will use the document mainly electronically and so I'd like to hyperlink each question to the corresponding answer and vice-versa. Now exsheets has the option to auto-label
each question with label{qu:id}
and the id
is generated automatically as well. So far so good.
Using the headings
, solution/pre-hook
or solution/post-hook
options I tried referencing the corresponding label, but don't manage to construct it. I tried using CurrentQuestionID
which, however, is empty when in the solution environment.
Any ideas how to accomplish the cross-linking automatically? Thanks!
cross-referencing exsheets
This is a missing feature I guess.
– clemens
Jan 12 '15 at 22:45
add a comment |
I'm writing up some lecture notes that contain questions/problems for the reader scattered accross the text. The solutions are provided in the end of each chapter. Exsheets appears to be a nice package for doing so.
Students will use the document mainly electronically and so I'd like to hyperlink each question to the corresponding answer and vice-versa. Now exsheets has the option to auto-label
each question with label{qu:id}
and the id
is generated automatically as well. So far so good.
Using the headings
, solution/pre-hook
or solution/post-hook
options I tried referencing the corresponding label, but don't manage to construct it. I tried using CurrentQuestionID
which, however, is empty when in the solution environment.
Any ideas how to accomplish the cross-linking automatically? Thanks!
cross-referencing exsheets
I'm writing up some lecture notes that contain questions/problems for the reader scattered accross the text. The solutions are provided in the end of each chapter. Exsheets appears to be a nice package for doing so.
Students will use the document mainly electronically and so I'd like to hyperlink each question to the corresponding answer and vice-versa. Now exsheets has the option to auto-label
each question with label{qu:id}
and the id
is generated automatically as well. So far so good.
Using the headings
, solution/pre-hook
or solution/post-hook
options I tried referencing the corresponding label, but don't manage to construct it. I tried using CurrentQuestionID
which, however, is empty when in the solution environment.
Any ideas how to accomplish the cross-linking automatically? Thanks!
cross-referencing exsheets
cross-referencing exsheets
edited Jan 6 at 15:38
lukasimir
asked Jan 12 '15 at 22:13
lukasimirlukasimir
485
485
This is a missing feature I guess.
– clemens
Jan 12 '15 at 22:45
add a comment |
This is a missing feature I guess.
– clemens
Jan 12 '15 at 22:45
This is a missing feature I guess.
– clemens
Jan 12 '15 at 22:45
This is a missing feature I guess.
– clemens
Jan 12 '15 at 22:45
add a comment |
1 Answer
1
active
oldest
votes
Edit
With version 0.19 (2015/07/04) the hack isn't necessary anymore. The following preamble to the code below suffices:
documentclass{article}
usepackage[auto-label]{exsheets}[2015/07/04]
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
usepackage{hyperref}
begin{document}
Original answer
The problem your having is (I guess) that when the solutions are printed CurrentQuestionID
doesn't hold the corresponding ID but in fact expands to an empty token list. This is probably a missing feature or even some kind of bug since arguably CurrentQuestionID
should work in for the solutions as well...
Here is a suggestion which will probably find its way into exsheets
in the next few days:
documentclass{article}
usepackage[auto-label]{exsheets}
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
ExplSyntaxOn
cs_set_protected:Npn __exsheets_print_solution:nnnn #1#2#3#4
{
tl_set:Nn CurrentQuestionID {#3} % <<< this is needed
tl_use:N l__exsheets_solutions_pre_hook_tl
exsheets_solutions_print_name:nnn {#1} {#2} {#3}
tl_use:N l__exsheets_solutions_pre_body_hook_tl
use:n {#4}
tl_use:N l__exsheets_solutions_post_body_hook_tl
tl_use:N l__exsheets_solutions_post_hook_tl
exsheets_h_or_vspace:N l__exsheets_solutions_skip_below_dim
}
ExplSyntaxOff
usepackage{hyperref}
begin{document}
section{Problems}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
section{Answers}
SetupExSheets{headings=myblock}
printsolutions
end{document}
Thanks! In the direction solution->question this does exactly what I was looking for. Ideally, I'd like to place a link to the solution somewhere in the question as well (e.g. in the heading or post-hook). But the solutions are not auto-labelled, are they?
– lukasimir
Jan 13 '15 at 7:33
1
That's true, there isn't. There are reasons for this: since it it possible for a solution to be printed more than once this could result in multiple labels; also solutions don't have a counter that gets stepped so there is nothing to refer to other than the page.
– clemens
Jan 13 '15 at 8:55
That being said it should be possible with the fix in my answer and the question and solution hooks to build something.
– clemens
Jan 13 '15 at 8:56
@lukasimir I updated the answer
– clemens
Jul 5 '15 at 22:04
@clemens How can I add links from all Exercises to solutions and reverse?
– minthao_2011
Jul 9 '16 at 0:53
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f222814%2fhow-to-automatically-link-questions-and-solutions-with-the-exsheets-package%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Edit
With version 0.19 (2015/07/04) the hack isn't necessary anymore. The following preamble to the code below suffices:
documentclass{article}
usepackage[auto-label]{exsheets}[2015/07/04]
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
usepackage{hyperref}
begin{document}
Original answer
The problem your having is (I guess) that when the solutions are printed CurrentQuestionID
doesn't hold the corresponding ID but in fact expands to an empty token list. This is probably a missing feature or even some kind of bug since arguably CurrentQuestionID
should work in for the solutions as well...
Here is a suggestion which will probably find its way into exsheets
in the next few days:
documentclass{article}
usepackage[auto-label]{exsheets}
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
ExplSyntaxOn
cs_set_protected:Npn __exsheets_print_solution:nnnn #1#2#3#4
{
tl_set:Nn CurrentQuestionID {#3} % <<< this is needed
tl_use:N l__exsheets_solutions_pre_hook_tl
exsheets_solutions_print_name:nnn {#1} {#2} {#3}
tl_use:N l__exsheets_solutions_pre_body_hook_tl
use:n {#4}
tl_use:N l__exsheets_solutions_post_body_hook_tl
tl_use:N l__exsheets_solutions_post_hook_tl
exsheets_h_or_vspace:N l__exsheets_solutions_skip_below_dim
}
ExplSyntaxOff
usepackage{hyperref}
begin{document}
section{Problems}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
section{Answers}
SetupExSheets{headings=myblock}
printsolutions
end{document}
Thanks! In the direction solution->question this does exactly what I was looking for. Ideally, I'd like to place a link to the solution somewhere in the question as well (e.g. in the heading or post-hook). But the solutions are not auto-labelled, are they?
– lukasimir
Jan 13 '15 at 7:33
1
That's true, there isn't. There are reasons for this: since it it possible for a solution to be printed more than once this could result in multiple labels; also solutions don't have a counter that gets stepped so there is nothing to refer to other than the page.
– clemens
Jan 13 '15 at 8:55
That being said it should be possible with the fix in my answer and the question and solution hooks to build something.
– clemens
Jan 13 '15 at 8:56
@lukasimir I updated the answer
– clemens
Jul 5 '15 at 22:04
@clemens How can I add links from all Exercises to solutions and reverse?
– minthao_2011
Jul 9 '16 at 0:53
add a comment |
Edit
With version 0.19 (2015/07/04) the hack isn't necessary anymore. The following preamble to the code below suffices:
documentclass{article}
usepackage[auto-label]{exsheets}[2015/07/04]
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
usepackage{hyperref}
begin{document}
Original answer
The problem your having is (I guess) that when the solutions are printed CurrentQuestionID
doesn't hold the corresponding ID but in fact expands to an empty token list. This is probably a missing feature or even some kind of bug since arguably CurrentQuestionID
should work in for the solutions as well...
Here is a suggestion which will probably find its way into exsheets
in the next few days:
documentclass{article}
usepackage[auto-label]{exsheets}
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
ExplSyntaxOn
cs_set_protected:Npn __exsheets_print_solution:nnnn #1#2#3#4
{
tl_set:Nn CurrentQuestionID {#3} % <<< this is needed
tl_use:N l__exsheets_solutions_pre_hook_tl
exsheets_solutions_print_name:nnn {#1} {#2} {#3}
tl_use:N l__exsheets_solutions_pre_body_hook_tl
use:n {#4}
tl_use:N l__exsheets_solutions_post_body_hook_tl
tl_use:N l__exsheets_solutions_post_hook_tl
exsheets_h_or_vspace:N l__exsheets_solutions_skip_below_dim
}
ExplSyntaxOff
usepackage{hyperref}
begin{document}
section{Problems}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
section{Answers}
SetupExSheets{headings=myblock}
printsolutions
end{document}
Thanks! In the direction solution->question this does exactly what I was looking for. Ideally, I'd like to place a link to the solution somewhere in the question as well (e.g. in the heading or post-hook). But the solutions are not auto-labelled, are they?
– lukasimir
Jan 13 '15 at 7:33
1
That's true, there isn't. There are reasons for this: since it it possible for a solution to be printed more than once this could result in multiple labels; also solutions don't have a counter that gets stepped so there is nothing to refer to other than the page.
– clemens
Jan 13 '15 at 8:55
That being said it should be possible with the fix in my answer and the question and solution hooks to build something.
– clemens
Jan 13 '15 at 8:56
@lukasimir I updated the answer
– clemens
Jul 5 '15 at 22:04
@clemens How can I add links from all Exercises to solutions and reverse?
– minthao_2011
Jul 9 '16 at 0:53
add a comment |
Edit
With version 0.19 (2015/07/04) the hack isn't necessary anymore. The following preamble to the code below suffices:
documentclass{article}
usepackage[auto-label]{exsheets}[2015/07/04]
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
usepackage{hyperref}
begin{document}
Original answer
The problem your having is (I guess) that when the solutions are printed CurrentQuestionID
doesn't hold the corresponding ID but in fact expands to an empty token list. This is probably a missing feature or even some kind of bug since arguably CurrentQuestionID
should work in for the solutions as well...
Here is a suggestion which will probably find its way into exsheets
in the next few days:
documentclass{article}
usepackage[auto-label]{exsheets}
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
ExplSyntaxOn
cs_set_protected:Npn __exsheets_print_solution:nnnn #1#2#3#4
{
tl_set:Nn CurrentQuestionID {#3} % <<< this is needed
tl_use:N l__exsheets_solutions_pre_hook_tl
exsheets_solutions_print_name:nnn {#1} {#2} {#3}
tl_use:N l__exsheets_solutions_pre_body_hook_tl
use:n {#4}
tl_use:N l__exsheets_solutions_post_body_hook_tl
tl_use:N l__exsheets_solutions_post_hook_tl
exsheets_h_or_vspace:N l__exsheets_solutions_skip_below_dim
}
ExplSyntaxOff
usepackage{hyperref}
begin{document}
section{Problems}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
section{Answers}
SetupExSheets{headings=myblock}
printsolutions
end{document}
Edit
With version 0.19 (2015/07/04) the hack isn't necessary anymore. The following preamble to the code below suffices:
documentclass{article}
usepackage[auto-label]{exsheets}[2015/07/04]
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
usepackage{hyperref}
begin{document}
Original answer
The problem your having is (I guess) that when the solutions are printed CurrentQuestionID
doesn't hold the corresponding ID but in fact expands to an empty token list. This is probably a missing feature or even some kind of bug since arguably CurrentQuestionID
should work in for the solutions as well...
Here is a suggestion which will probably find its way into exsheets
in the next few days:
documentclass{article}
usepackage[auto-label]{exsheets}
DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](marginparsep,0pt)
} ,
title-post-code = bfseriesspace
to question GetQuestionProperty{ref}{CurrentQuestionID}
}
ExplSyntaxOn
cs_set_protected:Npn __exsheets_print_solution:nnnn #1#2#3#4
{
tl_set:Nn CurrentQuestionID {#3} % <<< this is needed
tl_use:N l__exsheets_solutions_pre_hook_tl
exsheets_solutions_print_name:nnn {#1} {#2} {#3}
tl_use:N l__exsheets_solutions_pre_body_hook_tl
use:n {#4}
tl_use:N l__exsheets_solutions_post_body_hook_tl
tl_use:N l__exsheets_solutions_post_hook_tl
exsheets_h_or_vspace:N l__exsheets_solutions_skip_below_dim
}
ExplSyntaxOff
usepackage{hyperref}
begin{document}
section{Problems}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
begin{question}
foo bar baz
end{question}
begin{solution}
blah blah
end{solution}
section{Answers}
SetupExSheets{headings=myblock}
printsolutions
end{document}
edited Jul 5 '15 at 22:04
answered Jan 12 '15 at 23:01
clemensclemens
51.2k5129278
51.2k5129278
Thanks! In the direction solution->question this does exactly what I was looking for. Ideally, I'd like to place a link to the solution somewhere in the question as well (e.g. in the heading or post-hook). But the solutions are not auto-labelled, are they?
– lukasimir
Jan 13 '15 at 7:33
1
That's true, there isn't. There are reasons for this: since it it possible for a solution to be printed more than once this could result in multiple labels; also solutions don't have a counter that gets stepped so there is nothing to refer to other than the page.
– clemens
Jan 13 '15 at 8:55
That being said it should be possible with the fix in my answer and the question and solution hooks to build something.
– clemens
Jan 13 '15 at 8:56
@lukasimir I updated the answer
– clemens
Jul 5 '15 at 22:04
@clemens How can I add links from all Exercises to solutions and reverse?
– minthao_2011
Jul 9 '16 at 0:53
add a comment |
Thanks! In the direction solution->question this does exactly what I was looking for. Ideally, I'd like to place a link to the solution somewhere in the question as well (e.g. in the heading or post-hook). But the solutions are not auto-labelled, are they?
– lukasimir
Jan 13 '15 at 7:33
1
That's true, there isn't. There are reasons for this: since it it possible for a solution to be printed more than once this could result in multiple labels; also solutions don't have a counter that gets stepped so there is nothing to refer to other than the page.
– clemens
Jan 13 '15 at 8:55
That being said it should be possible with the fix in my answer and the question and solution hooks to build something.
– clemens
Jan 13 '15 at 8:56
@lukasimir I updated the answer
– clemens
Jul 5 '15 at 22:04
@clemens How can I add links from all Exercises to solutions and reverse?
– minthao_2011
Jul 9 '16 at 0:53
Thanks! In the direction solution->question this does exactly what I was looking for. Ideally, I'd like to place a link to the solution somewhere in the question as well (e.g. in the heading or post-hook). But the solutions are not auto-labelled, are they?
– lukasimir
Jan 13 '15 at 7:33
Thanks! In the direction solution->question this does exactly what I was looking for. Ideally, I'd like to place a link to the solution somewhere in the question as well (e.g. in the heading or post-hook). But the solutions are not auto-labelled, are they?
– lukasimir
Jan 13 '15 at 7:33
1
1
That's true, there isn't. There are reasons for this: since it it possible for a solution to be printed more than once this could result in multiple labels; also solutions don't have a counter that gets stepped so there is nothing to refer to other than the page.
– clemens
Jan 13 '15 at 8:55
That's true, there isn't. There are reasons for this: since it it possible for a solution to be printed more than once this could result in multiple labels; also solutions don't have a counter that gets stepped so there is nothing to refer to other than the page.
– clemens
Jan 13 '15 at 8:55
That being said it should be possible with the fix in my answer and the question and solution hooks to build something.
– clemens
Jan 13 '15 at 8:56
That being said it should be possible with the fix in my answer and the question and solution hooks to build something.
– clemens
Jan 13 '15 at 8:56
@lukasimir I updated the answer
– clemens
Jul 5 '15 at 22:04
@lukasimir I updated the answer
– clemens
Jul 5 '15 at 22:04
@clemens How can I add links from all Exercises to solutions and reverse?
– minthao_2011
Jul 9 '16 at 0:53
@clemens How can I add links from all Exercises to solutions and reverse?
– minthao_2011
Jul 9 '16 at 0:53
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f222814%2fhow-to-automatically-link-questions-and-solutions-with-the-exsheets-package%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This is a missing feature I guess.
– clemens
Jan 12 '15 at 22:45