General ⇒ Delay output to another part
-
- Posts: 4
- Joined: Tue Jan 13, 2015 4:23 am
Delay output to another part
What I have in mind is a number of Puzzles in Part I, then hints in Part II and finally solutions in Part III. I want to name each problem once and I expect the hints and solution section of the PDF to automatically get named as problem hint and problem solution respectively.
I would also like functionality like being able to move back and forth between the problem and its hint/solution.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Delay output to another part
i'd love to help you, not only because of your user name, but i don't really know what you want to achieve.
Basically, you can do what you want using nameref. But i guess you want an advanced interface.
Maybe even package exsheets might be of help here.
-
- Posts: 4
- Joined: Tue Jan 13, 2015 4:23 am
Delay output to another part
Thank you very much for your help. I think the exsheets package might do it, though it will take me a while to understand it.
To clarify what I want to do, I have created a small LaTeX file, if you could have a look at it. Here is a https://www.overleaf.com/read/yzzwtxzbhjnq
I want to be able to do the same thing in a more sophisticated and structured manner. Can you suggest me something ?
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Delay output to another part
Delay output to another part
With exsheets this can be done with not too much effort (with a slightly different syntax). The following code uses
exsheets
' question property mechanism and its programming facilities like ForEachQuestion
or \ExSheetsHeading
. The command \NewDocumentCommand
is provided by xparse which is loaded by exsheets
.Code: Select all
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{exsheets}
\SetupExSheets{ headings = block-subtitle }
% new property `hint':
\DeclareQuestionProperty{hint}
% a command to print all given hints
\NewDocumentCommand\printquestionhints{}{%
\ForEachQuestion
{%
\IfQuestionPropertyT{hint}{##1}{%
\ExSheetsHeading
{block} % headings style
{Hint} % heading
{\QuestionNumber{##1}}% number
{0} % points -- need to be zero here
{0} % bonus points -- need to be zero here
{##1}% % ID
\GetQuestionProperty{hint}{##1}%
\par
\medskip
}%
}%
}
\begin{document}
\section{Problems}
\begin{question}[subtitle=Pythagoras]
This is the first problem.
\SetQuestionProperties{ hint = This is a hint to the first problem. }
\end{question}
\begin{solution}
This is the solution to the first problem.
\end{solution}
\begin{question}[subtitle=Another Problem]
This is the second problem.
\end{question}
\begin{solution}
This is the solution to the second problem.
\end{solution}
\begin{question}[subtitle=Yet Another Problem]
This is the third problem.
\SetQuestionProperties{ hint = This is a hint to the third problem. }
\end{question}
\begin{solution}
This is the solution to the third problem.
\end{solution}
\section{Hints}
\printquestionhints
\section{Solutions}
\printsolutions
\end{document}