
나는 코드에서 각 하위 질문 바로 다음에 답변을 얻을 수 있도록 하위 질문이 포함된 연습 문제를 조판하고 싶습니다. 하지만 출력에서는 모든 답변이 끝에 있게 됩니다. 또한 연습 문제와 하위 질문 모두 자동으로 번호가 매겨지기를 원합니다. 조판 연습을 위한 여러 패키지(예: '답변', '운동' 및 'probsoln')가 있다는 것을 알고 있습니다. '시험'이라는 문서 유형이 있다는 것도 알고 있어요.
내 질문은: 어떤 패키지가 이에 가장 적합하며 어떤 종류의 코드가 결과를 생성합니까?
나는 다음과 같은 것을 쓰고 싶습니다 :
\begin{ExerciseList}
\Exercise{}
Calculate the following:
\Question{$7+2$}
\Answer{$9$}
\Question{$9-9$}
\Answer{$0$}
\Question{$5+5+5$}
\Answer{$15$}
\Exercise{}
Solve the following equations:
\Question{$x+5=7$}
\Answer{$x=2$}
\Question{$x-5=9$}
\Answer{$x=14$}
\Question{$5x=20$}
\Answer{$x=4$}
\end{ExerciseList}
그리고 최종 문서가 다음과 같기를 바랍니다.
연습 1
다음을 계산하십시오:
a) 7+2 b) 9-9 c) 5+5+5연습 2
다음 방정식을 푼다:
a) x+5=7 b) x-5=9 c) 5x=20솔루션:
연습 1
가) 9 나) 0 다) 15연습 2
a) x+5=7 b) x=14 c) x=4
위에 있는 코드는 단지 예일 뿐입니다. 구조가 비슷하다면 명령이 내가 작성한 것과 정확히 같을 필요는 없습니다.
답변1
패키지를 사용하면 probsoln
문서 내에서 또는 \loadallproblems
또는 같은 명령을 사용하여 로드할 수 있는 외부 파일에서 문제를 정의할 수 있습니다 \loadrandomproblems
.
다음은 문서에 정의된 문제에 대한 간단한 예입니다.
\documentclass{article}
\usepackage{probsoln}
\begin{defproblem}{prob1}% label
\begin{onlyproblem}% question
Calculate the following:%
\begin{textenum}
\item $7+2$
\item $9-9$
\item $5+5+5$
\end{textenum}
\end{onlyproblem}%
\begin{onlysolution}% solution
\begin{textenum}
\item $9$
\item $0$
\item $15$
\end{textenum}
\end{onlysolution}
\end{defproblem}
\begin{defproblem}{prob2}% label
\begin{onlyproblem}% question
Solve the following equations:
\begin{textenum}
\item $x+5=7$
\item $x-5=9$
\item $5x=20$
\end{textenum}
\end{onlyproblem}%
\begin{onlysolution}% solution
\begin{textenum}
\item $x=2$
\item $x=14$
\item $x=4$
\end{textenum}
\end{onlysolution}
\end{defproblem}
\begin{document}
\renewcommand{\labelenumii}{\theenumii)}
\begin{enumerate}
\foreachproblem{\item\thisproblem}
\end{enumerate}
\section*{Solutions}
\showanswers
\begin{enumerate}
\foreachsolution{\item\thisproblem}
\end{enumerate}
\end{document}
이는
서식은 변경될 수 있습니다. 예를 들어,enumitem
패키지:
\documentclass{article}
\usepackage{probsoln}
\usepackage{enumitem}
\begin{defproblem}{prob1}% label
\begin{onlyproblem}% question
Calculate the following:%
\begin{textenum}
\item $7+2$
\item $9-9$
\item $5+5+5$
\end{textenum}
\end{onlyproblem}%
\begin{onlysolution}% solution
\begin{textenum}
\item $9$
\item $0$
\item $15$
\end{textenum}
\end{onlysolution}
\end{defproblem}
\begin{defproblem}{prob2}% label
\begin{onlyproblem}% question
Solve the following equations:
\begin{textenum}
\item $x+5=7$
\item $x-5=9$
\item $5x=20$
\end{textenum}
\end{onlyproblem}%
\begin{onlysolution}% solution
\begin{textenum}
\item $x=2$
\item $x=14$
\item $x=4$
\end{textenum}
\end{onlysolution}
\end{defproblem}
\newenvironment{ExerciseList}
{\begin{enumerate}[label={\emph{Exercise \arabic*}},%
ref={\arabic*},wide]
\renewcommand{\labelenumii}{\theenumii)}%
}
{\end{enumerate}}
\newcommand{\exercise}{\item\mbox{}\par}
\begin{document}
\begin{ExerciseList}
\foreachproblem{\exercise\thisproblem}
\end{ExerciseList}
\section*{Solutions}
\showanswers
\begin{ExerciseList}
\foreachsolution{\exercise\thisproblem}
\end{ExerciseList}
\end{document}
이는 다음을 생성합니다.
편집하다:
다음은 코드의 질문 옆에 답변을 작성할 수 있는 대안입니다.
\documentclass{article}
\usepackage{probsoln}
\usepackage{enumitem}
\newcommand{\QA}[2]{%
\begin{onlyproblem}#1\end{onlyproblem}%
\begin{onlysolution}#2\end{onlysolution}}
\begin{defproblem}{prob1}% label
\begin{onlyproblem}% question
Calculate the following:%
\end{onlyproblem}%
\begin{textenum}
\item \QA{$7+2$}{$9$}
\item \QA{$9-9$}{$0$}
\item \QA{$5+5+5$}{$15$}
\end{textenum}
\end{defproblem}
\begin{defproblem}{prob2}% label
\begin{onlyproblem}% question
Solve the following equations:
\end{onlyproblem}%
\begin{textenum}
\item \QA{$x+5=7$}{$x=2$}
\item \QA{$x-5=9$}{$x=14$}
\item \QA{$5x=20$}{$x=4$}
\end{textenum}
\end{defproblem}
\newenvironment{ExerciseList}
{\begin{enumerate}[label={\emph{Exercise \arabic*}},%
ref={\arabic*},wide]
\renewcommand{\labelenumii}{\theenumii)}%
}
{\end{enumerate}}
\newcommand{\exercise}{\item\mbox{}\par}
\begin{document}
\begin{ExerciseList}
\foreachproblem{\exercise\thisproblem}
\end{ExerciseList}
\section*{Solutions}
\showanswers
\begin{ExerciseList}
\foreachsolution{\exercise\thisproblem}
\end{ExerciseList}
\end{document}
결과는 이전 예제와 동일합니다.
편집 2:
문제를 정의하고 표시하는 방법은 다음과 같습니다. 라벨은 자동으로 생성됩니다.
\documentclass{article}
\usepackage{probsoln}
\usepackage{enumitem}
\newcommand{\QA}[2]{%
\begin{onlyproblem}#1\end{onlyproblem}%
\begin{onlysolution}#2\end{onlysolution}}
\newenvironment{ExerciseList}
{\begin{enumerate}[label={\emph{Exercise \arabic*}},%
ref={\arabic*},wide]
\renewcommand{\labelenumii}{\theenumii)}%
}
{\end{enumerate}}
\newcommand{\exercise}{\item\mbox{}\par}
\newcommand{\Exercise}[2]{\exercise
#1\par
\begin{defproblem}{prob\arabic{enumi}}%
\begin{textenum}%
#2%
\end{textenum}%
\end{defproblem}%
\useproblem{prob\arabic{enumi}}%
}
\begin{document}
\begin{ExerciseList}
\Exercise{Calculate the following:}%
{%
\item \QA{$7+2$}{$9$}
\item \QA{$9-9$}{$0$}
\item \QA{$5+5+5$}{$15$}
}%
\Exercise{Solve the following equations:}
{%
\item \QA{$x+5=7$}{$x=2$}
\item \QA{$x-5=9$}{$x=14$}
\item \QA{$5x=20$}{$x=4$}
}
\end{ExerciseList}
\section*{Solutions}
\showanswers
\begin{ExerciseList}
\foreachsolution{\exercise\thisproblem}
\end{ExerciseList}
\end{document}
답변2
패키지를 사용한 솔루션은 다음과 같습니다 answers
. 답변의 형식을 조정할 수 있습니다.
\documentclass[pdftex,12pt]{article}
\usepackage{amsmath}
\usepackage{answers}
\newcommand{\answerFileName}{anexamanswers}
\Newassociation{sol}{Solution}{\answerFileName}
\Opensolutionfile{\answerFileName}
\newenvironment{Exercise}[1]
{\item #1
\begin{enumerate}
}
{
\end{enumerate}
}
\newcommand{\Question}[1]{%
\item #1
}
\begin{document}
\begin{enumerate}
\begin{Exercise}{Calculate the following:}
\Question{$7+2$}
\begin{sol}
$9$
\end{sol}
\Question{$9-9$}
\begin{sol}
$0$
\end{sol}
\end{Exercise}
\begin{Exercise}{Solve the following equations:}
\Question{$x+5=7$}
\begin{sol}
$x=2$
\end{sol}
\Question{$x-5=9$}
% \Answer{$x=14$}
\Question{$5x=20$}
% \Answer{$x=4$}
\end{Exercise}
\end{enumerate}
\Closesolutionfile{\answerFileName}
\newpage
Answers to Exercises:
\input{\answerFileName}
\end{document}
답변3
exsheets
다음은 및 패키지를 사용하는 제안입니다 tasks
.
\documentclass{article}
\usepackage{exsheets,tasks}
\SetupExSheets{
solution/name=Exercise ,
headings-format=\itshape
}
\begin{document}
\begin{question}
Calculate the following:
\begin{tasks}(3)
\task $7+2$
\task $9-9$
\task $5+5+5$
\end{tasks}
\end{question}
\begin{solution}
\begin{tasks}(3)
\task $9$
\task $0$
\task $15$
\end{tasks}
\end{solution}
\begin{question}
Solve the following equations:
\begin{tasks}(3)
\task $x+5=7$
\task $x-5=9$
\task $5x=20$
\end{tasks}
\end{question}
\begin{solution}
\begin{tasks}(3)
\task $x=2$
\task $x=14$
\task $x=4$
\end{tasks}
\end{solution}
\section*{Solutions}
\printsolutions
\end{document}