Xparse에서 생성된 목록을 "섹션과 같은" 환경으로 어떻게 나눌 수 있습니까?

Xparse에서 생성된 목록을 "섹션과 같은" 환경으로 어떻게 나눌 수 있습니까?

나는 주로 xparse정리된 목록을 만들기 위해 라이브러리를 사용합니다. MWE는 다음과 같습니다.

\documentclass{article}
\usepackage{xparse}
\newcounter{quest}
\newcommand{\quest}{\noindent\stepcounter{quest}{\bf Q}{\bf \arabic{quest}.\ }}

\ExplSyntaxOn

\NewDocumentCommand{\answer}{ m }{ \malmedal_input_add:n { #1 } }
\NewDocumentCommand{\listanswers}{ }{ \malmedal_output_direct: }

\seq_new:N \g_malmedal_input_seq
\seq_new:N \l_malmedal_temp_seq
\int_new:N \l_malmedal_count_int

\cs_new:Npn \malmedal_input_add:n #1
 {
  \seq_gput_right:Nn \g_malmedal_input_seq { #1 }
 }

\cs_new_protected:Npn \malmedal_output_direct:
 {
  \int_zero:N \l_malmedal_count_int
  \seq_map_inline:Nn \g_malmedal_input_seq
   {
    \int_incr:N \l_malmedal_count_int
    \malmedal_print:n { ##1 }
   }
 }

\cs_new:Npn \malmedal_print:n #1
 {
  \noindent{\textbf{Question } ~ \bfseries\int_to_arabic:n { \l_malmedal_count_int }} ~ : ~ #1 \par
 }
\ExplSyntaxOff

\begin{document}

\section{Math}
\quest $1 + 1 = ?$
\answer{$2$.}

\quest If $a = 2$ and $b = 5$, then $a - b = ?$
\answer{$-3$.}

\quest Are there any natural numbers between $8$ and $9$?
\answer{No.}

\section{Physics}
\quest What's the speed of light in vacuum?
\answer{$\approx 3\cdot 10^8$ m/s}

\quest Name one thing one can't do without atmospheric pressure.
\answer{To drink water with a straw.}
\section{Answer Key}

\listanswers
\end{document}

이는 다음을 생성합니다.

여기에 이미지 설명을 입력하세요

생성된 목록을 아래와 같이 각 섹션으로 나누는 방법이 있는지 궁금합니다.

여기에 이미지 설명을 입력하세요

그리고 도움을 주고 싶다면 답안을 생성하는 더 간단한 방법이 있다고 말하지 마세요. xparse 패키지 내에 솔루션이 필요합니다. 벌써 고마워요!

관련 정보