考试类的全新图形环境

考试类的全新图形环境

在考试类的解决方案框中有一个浮点数的不兼容性是众所周知的。存在多种解决方案,几乎所有解决方案都使用caption 包和 minipage 环境的一些变体

为什么简单地将图形包装在小页面环境中不起作用?

我试过

\renewenvironment{figure}{\begin{minipage}[c]{\linewidth}}{\end{minipage}}

答案1

exam基于文章,因此定义了图形环境。您可以使用 minipage 定义新环境,但我不建议重新定义原始figure环境。但这样做,图形(和标题)的顺序可能会非常混乱。您需要决定,让它们全部浮动,还是不让任何图形浮动。

--编辑--@tohecz 让我意识到解决方案环境。这是一件严肃的事情。传统的浮点数只会迷路刚刚定义的questionfigure环境可以工作,但还有一件事。有一个开关可以打印答案,或者不是如果不是,柜台仍然会refstepped,并可以让一切看起来奇数以上如果没有打印答案。我建议为问题(始终打印)和答案/解决方案(仅在切换时打印)定义单独的环境。这将处理编号。但随后出现了一个问题:您是否需要在框架(默认)环境中可以引用的图形?

我定义了两个独立的环境,并给它们起了相当愚蠢的名字。引用问题中的图形总是有效的,无论是从问题还是答案调用。从答案引用其他答案(或者更确切地说是其中的图片)也有效。如果printanswers为假,则引用问题中的答案图形将不起作用,但用例是什么?»哈哈,答案中会有一张很棒的图片,但看不到它!«

免责声明:如果您编写以下内容(您应该这样做),则需要发挥您的想象力。在撰写此答案时,没有鸭子受到伤害。

\documentclass[
answers
]{exam}%based on article
\usepackage{xcolor}
\usepackage{tocbasic}
\usepackage[tocindentauto]{tocstyle}
\DeclareNewTOC[
name=questionFigure,
listname={List of questionfigures},
type=qfigure,
nonfloat]{loq}
\DeclareNewTOC[
name=answerFigure,
listname={List of answerfigures},
type=afigure,
nonfloat]{loa}

\makeatletter
\renewcommand\theqfigure{\thenumquestions}
\newenvironment{questionfigure}{%
    \begin{center}%
    \begin{minipage}[c]{\linewidth}%
    \def\@captype{qfigure}%
}{%
    \end{minipage}%
    \end{center}%
}
\renewcommand\theafigure{\thenumquestions-\alph{afigure}}
\newenvironment{answerfigure}{%
    \begin{center}%
    \begin{minipage}[c]{\linewidth}%
    \def\@captype{afigure}%
}{%
    \end{minipage}%
    \end{center}%
}
\makeatother
\newcommand\rplcPic{\rule{4cm}{3cm}}
\usepackage{hyperref}
\begin{document}
\listofqfigures
%Print the list of afigures only if answers toggled
\ifprintanswers
\listofafigures
\fi
\begin{questions}
    \question Name a place where the lights are always on.
        \begin{solution} The light in my fridge is always
            on. 
        \begin{answerfigure}
            \rplcPic
            \caption{Almost all refridgerators
                provide the feature of \emph{eternal}
            light.}
        \end{answerfigure}
        \end{solution}
        \question Look at the following picture. What do
        you conclude?
        \begin{questionfigure}
        \rplcPic
        \caption{An open fridge. What do you conclude?}
        \label{fridge}
    \end{questionfigure}
    \begin{solution}
        Seeing the footprints in the butter, i can conclude that there must
        have been an elephant in there earlier.
    \end{solution}
    \question Homer was one of the greatest greek
    philosophers. Sum up his philosophy in as few words as
    possible.
    \begin{solution}
        Beer, Donuts.
    \end{solution}
    \question Nucleaar weapons are terrible. Describe and
    explain the physical reactions of an atomic bomb.
    \begin{solution}
        A picture is worth more than a thousand words.
        \begin{answerfigure}
            \begin{verbatim}
                  _-^--^=-_
           _.-^^          -~_
        _--                  --_
        <                       >)
        |                        |
        \._                   _./
           ```--. . , ; .--'''
             | |   |
              .-=||  | |=-.
              `-=#$%&%$#=-'
             | ;  :|
        _____.,-#%&$@%#&#~,._____
            \end{verbatim}
            \caption{BOOOM}
            \label{boom}
        \end{answerfigure}
    \end{solution}
    \question When to \emph{Duck and cover}?
    \begin{solution} See \autoref{boom}!
    \end{solution}
\question{Is it easy to change a refridgerator light bulb?}
\begin{solution} Sure, according to \autoref{fridge} an elephant
    lives in there. Just place the light bulb inside, the
    elephant will do the work.
\end{solution}
\question You see a block of iron glowing with an orange color
(see the picture).
What does that tell you about the temperature?
\begin{questionfigure}
    {\color{orange!40!white}{\rplcPic}}
    \caption{A gloowing block of iron}
\end{questionfigure}
\begin{solution} Oh, that's hot. Can't touch this!
\end{solution}
\question Did you ever use Plan 9 from Bell Labs?
\begin{solution} 42! Glenda is cool. See \autoref{boom}. 
\end{solution}
\end{questions}
\end{document}

相关内容