考试:如何全局制作跨越多页的 \textwidth-wide 解决方案?

考试:如何全局制作跨越多页的 \textwidth-wide 解决方案?

后续行动这个答案,我想让解决方案跨越整个文本宽度,而不管问题级别如何,同时延续到多页。

\documentclass[answers]{exam}
\usepackage{lipsum}
\usepackage{mdframed}

\renewenvironment{TheSolution}{\begin{mdframed}[skipabove=\baselineskip,innertopmargin=\baselineskip,innerbottommargin=\baselineskip]
        \textbf{Solution:}\enspace\ignorespaces}{\end{mdframed}}

\begin{document}
    \begin{questions}
        \question A question.
        \begin{parts}
            \part part
            \begin{solution}
                The long solution continues onto another page: \lipsum[1-8]
            \end{solution}
        \end{parts}
    \end{questions}
\end{document}

答案1

您可以\parshape在组内使用。但是,我认为它看起来不太好。

\documentclass[answers]{exam}
\usepackage{lipsum}
\usepackage{mdframed}

\renewenvironment{solution}
{\begingroup\par\parshape0%
\begin{mdframed}[skipabove=\baselineskip,
                 innertopmargin=\baselineskip,
                 innerbottommargin=\baselineskip,
                 userdefinedwidth=\textwidth]
\textbf{Solution:}\enspace\ignorespaces}
{\end{mdframed}\par\endgroup}

\begin{document}
    \begin{questions}
        \question A question.
        \begin{parts}
            \part part
            \begin{solution}
                The long solution continues onto another page: \lipsum[1-8]
            \end{solution}
        \end{parts}
    \end{questions}

    \lipsum[1]
\end{document}

在此处输入图片描述

在此处输入图片描述

答案2

由于某种原因,EnvFullwidth 使用了\vbox看似不必要的,但绝对可以防止分页。与任何环境一样,@totalleftmarginetc 的原始值在退出时会恢复。

\documentclass[answers]{exam}
\usepackage{lipsum}
\usepackage{showframe}

\makeatletter
\newenvironment{MyFullwidth}
  {\par\bigskip% \bigskip not really needed
    \leftskip=0pt \rightskip=0pt
    % We adjust \@totalleftmargin (and linewidth?) in case there's a
    % solution environment inside of the environment:
    \advance\linewidth\@totalleftmargin
    \@totalleftmargin=0pt
  }
  {\par}
\makeatother

\begin{document}
    \begin{questions}
        \question A question.
        \begin{parts}
            \part part
            \begin{MyFullwidth}
            \begin{solution}
                The long solution continues onto another page: \lipsum[1-8]
            \end{solution}
            \end{MyFullwidth}
        \end{parts}
    \end{questions}
\end{document}

相关内容