I'm using the code I found in Collect contents of lists at beginning of document with modified names so that it produces a list of questions
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\let\originalcontentsline\contentsline
\usepackage{hyperref}
\makeatletter
\newcommand{\printquestions}{%
\section*{Questions}
\begin{enumerate}
\let\contentsline\originalcontentsline
\def\@noitemerr{\@latex@warning{Empty questions list}}%
\@starttoc{qst}
\end{enumerate}
}
\newcommand{\l@qst}[3]{#1}
\makeatother
\NewEnviron{questions}
{%
\addcontentsline{qst}{qst}{%
\noexpand\unexpanded{\unexpanded\expandafter{\BODY}}%
}%
}
\begin{document}
\chapter{one}
\begin{questions}
\item some question
\end{questions}
\chapter{two}
\begin{questions}
\item some other question
\end{questions}
\end{document}
but I would like to adapt it in a few ways:
The way the code is at the moment, it takes the items in the list, removes them from its location, and places them wherever my
$
\printquestions$
is located. I would like it to instead copy the items to that location without removing them, sort of like a table of contents (questions in this case).I would like to be able to click on the collected item so that it takes me to the original location of the question within the file, so I can add an answer to the question later on without having to look through the document.
Since ideally I would have one question at a time within the
$
\begin{questions}... \end{questions}$
it would be better to have something like$
\question{some question in here}$
in the fashion of a subsubsection, which I managed by using$
\newcommand{\question}{\subsubsection}$
; and it actually solves most of the above, provided I add\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
in the preamble, except that it does not collect all the questions together, but rather places them in the table of contents within their hierarchy, and that defeats the purpose of not having to look too hard for them in the document.
So, basically I want to create a command that allows me to insert questions, in a sort of "subsection" or "theorem" like style; and that all such instances are collected in a $
\listofquestions$
that I can display at the beginning of the document, and that works with hyperref.
I also tried to implement a solution based on Making a list of hypothesis and references to the hypothesis
% *************** Question ***************
\newtheorem{questionin}{Question}[chapter]
\newtheorem{questionaux}{Question}[chapter]
\usepackage{environ,etoolbox}
\makeatletter
\def\addtoquestionlist{\addtheoremline{questionaux}}
\NewEnviron{question}{%
\refstepcounter{questionaux}%
\expandafter\addtoquestionlist\expandafter{\expandafter\ignorespaces\BODY}
\begin{questionin}\BODY\end{questionin}
}
\patchcmd\listtheorems
{\begingroup}
{\begingroup\let\label\@gobble}
{}{}
\makeatother
but I do not understand enough of how it works to make the proper changes other than the names.
When I use $
\listtheorems$
it prints
questionaux.1.1 questionin.1.1,
without even a header, and it's not exactly what I have in mind. I would rather it printed the question itself as would both of the above solutions (the one with $\begin{question}
\item \end{question}$
, and the one where I just turn it into a subsection.