如何在文档中间更改文档类,并在完成后将其改回?

如何在文档中间更改文档类,并在完成后将其改回?

我正在尝试写一系列笔记。我的文档类是 Report。但我需要插入一堆作为笔记一部分的问题(示例)。我知道有一个用于制作 MCQ 问题的“考试”包。我想知道,是否可以在不更改文档类的情况下将 MCQ 问题放在页面中?

如果没有:有没有办法暂时将文档类别更改为考试,输入问题和答案,然后将文档类别更改回报告,最好没有分页符,例如使用小页面?

请提出更好的在报告中插入 MCQ 问卷的策略。谢谢您的宝贵时间。

答案1

您可以使用exam文档类,因为它是基于文章文档类构建的。我使用考试类来制作课程讲义,其中包括大量笔记、表格和图像,偶尔还会包含问题。这是一个基本示例。

\documentclass[12pt]{exam}

\printanswers

\usepackage{lipsum} % For MWE only.

\usepackage{geometry}
\geometry{letterpaper, left=1.5in, bottom=1in}                   

\usepackage[parfill]{parskip} 

% Use small cap letters for enumerated
% lists to distinguish them from questions.
\usepackage{enumitem}
\setlist{leftmargin=*}
\setlist[1]{labelindent=\parindent}
\setlist[enumerate]{label=\textsc{\alph*}.}

\usepackage[sc]{titlesec}

%% Commands for Exam class
\renewcommand{\solutiontitle}{\noindent}
\unframedsolutions
\SolutionEmphasis{\bfseries}

% Shifts margins left. Question numbers appear in margin.
% This allows "fullwidth" to left align with text that is 
% outside of the questions environment.
\renewcommand{\questionshook}{%
    \setlength{\leftmargin}{-\leftskip}%
}

\pagestyle{headandfoot}
\firstpageheader{Title of Class}{}{\ifprintanswers\textbf{KEY}\else Name: \enspace \makebox[2.5in]{\hrulefill}\fi}
\runningheader{}{}{\footnotesize{pg. \thepage}}
\footer{}{}{}
\runningheadrule

\renewcommand{\choiceshook}{%
    \setlength{\leftmargin}{0.25in}%
    \setlength{\parsep}{3pt}%
}

% Next two macros keep constant space between question
% whether answers are printed or not. First is for
% answers that do not require line breaks.
\newcommand*\AnswerBox[2]{%
    \parbox[t][#1]{0.92\textwidth}{%
    \begin{solution}#2\end{solution}}
    \vspace{\stretch{1}}
}

% This allows line breaks.
\newenvironment{AnswerPage}[1]
    {\begin{minipage}[t][#1]{0.92\textwidth}%
    \begin{solution}}
    {\end{solution} \end{minipage}
    \vspace{\stretch{1}}}

% An answer space I commonly use.
\newlength{\basespace}
\setlength{\basespace}{5\baselineskip}

\begin{document}

\subsection*{Title of exercise}

This is the format I use for my laboratory handouts, using the exam class. I use this space to introduce the overall purpose of the exercise.

\subsubsection*{First section}

I break the overall exercise into related sections. Sometimes a list is handy. The bullets are left-aligned with the text. I use
small cap letters to distinguish lists from questions.

\begin{enumerate}
    \item This is the first item.
    \item This is another item.
    \item This is the final item.
\end{enumerate}

Time to answer some questions.

\begin{questions}

\question
Identify at least one structure in the following diagram.

\AnswerBox{2\baselineskip}{%
    The AnswerBox macro is good for answers that only need a single sentence in the key. It does not accept paragraph returns.
}

\question
What is the meaning of life?

\begin{AnswerPage}{1\basespace}
    The AnswerPage environment is a minipage so it accepts paragraph returns.\bigskip

    Like this one.
\end{AnswerPage}

\subsubsection*{Another section}

Here is the next section. Each section can be as long as necessary, and can include figures and tables. Updated to answer the OP's query about multiple choice questions.

\question
What is the speed of an unladen swallow?

\begin{choices}
    \choice 11 meters per second.
    \correctchoice 42.
    \choice Swallows are never unladen.
\end{choices}

\end{questions}

\end{document}

在此处输入图片描述

相关内容