試験資料に図を囲むにはどうすればいいですか?

試験資料に図を囲むにはどうすればいいですか?

ARTICLE ではラップできますが、EXAM ではラップできません。EXAM でラップするにはどうすればよいでしょうか? (質問プラス - LaTeX の達人の場合 - この種のことを実行するのに最も適した簡単なパッケージは何ですか?)

図をARTICLE文書にラップすることができます

このコードで

\documentclass[12pt]{article}
\usepackage{graphicx,wrapfig,lipsum}
\usepackage[onehalfspacing]{setspace}
\usepackage{mwe}

\begin{document}
%\begin{questions}
    \begin{wrapfigure}{r}{.3\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-a.png}
    \caption{This is A}
\end{wrapfigure}
Hello, I want to wrap this figure in exam
\lipsum[2]\lipsum[1]
%\end{questions}
\end{document}

ここに画像の説明を入力してください

しかし、EXAM ドキュメントで画像をラップしたいのですが、このコードではラップされた図は表示されません。

\documentclass[12pt]{exam}
\usepackage{graphicx,wrapfig,lipsum}
\usepackage[onehalfspacing]{setspace}
\usepackage{mwe}

\begin{document}
\begin{questions}
\begin{wrapfigure}{r}{.3\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-a.png}
    \caption{This is A}
\end{wrapfigure}
\question Hello, I want to wrap this figure in exam
\lipsum[2]\lipsum[1]

\end{questions}
\end{document}

ここに画像の説明を入力してください

**

編集済み(2019/02/24)Skillmonソリューションを試した後、質問のリスト(列挙)に関する新しい問題が発生しました

**

これが問題です ここに画像の説明を入力してください

コード付き(図の引用文に項目を追加するだけ)

        \documentclass[12pt]{exam}
        \usepackage{graphicx,wrapfig,lipsum}
        \input{insbox}
        \usepackage{capt-of}
        \usepackage[onehalfspacing]{setspace}
        \usepackage{mwe}

        \usepackage{etoolbox}

        \makeatletter
        %% Stealing some code from exam:
        \def\mypointshandling
          {%>>>
            \if@bonus
              \def\padded@point@block{%
            \begingroup
              \@placepointstrue
              \bonuspoint@block
            \endgroup
              }%
            \else
              \def\padded@point@block{%
            \begingroup
              \@placepointstrue
              \point@block
            \endgroup
              }%
            \fi
            \if@pointsdropped
            \else
              \if@bonus
            \if@bonusqformat
              \ifx\ques@ref\@queslevel
              \else
                \setup@point@toks
              \fi
            \else
              \setup@point@toks
            \fi
              \else
            \if@qformat
              \ifx\ques@ref\@queslevel
              \else
                \setup@point@toks
              \fi
            \else
              \setup@point@toks
            \fi
              \fi
            \fi
            \global \MyIfPointsfalse
          }%<<<
        \newif\ifMyIfPoints
        \protected\def\questionInsbox
          {%
            \@ifnextchar[\questionInsbox@a{\questionInsbox@a[]}%
          }
        \protected\long\def\questionInsbox@a[#1]#2#3%
          {%
            \@ifnextchar[{\questionInsbox@b{#1}{#2}{#3}}
              {\questionInsbox@b{#1}{#2}{#3}[0]}
          }
        \long\def\questionInsbox@b#1#2#3[#4]%
          {%
            \apptocmd\@itemlabel{\hskip\leftmargin}{}{}%
            \def\makelabel##1{\hss\llap{##1}}%
            \if\relax\detokenize{#1}\relax
              \question
            \else
              \global\MyIfPointstrue
              \patchcmd\@readpoints{\global\@placepointstrue}{\relax}{}{}%
              \question[#1]%
              \patchcmd\@readpoints{\relax}{\global\@placepointstrue}{}{}%
            \fi
            \patchcmd\@itemlabel{\hskip\leftmargin}{}{}{}%
            \let\makelabel\@mklab
            \mbox{}%
            \vspace*{-\baselineskip}%
            \setlength{\leftskip}{\leftmargin}%
            \InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#4]%
            \ifMyIfPoints
              \mypointshandling
            \fi
            \the\point@toks
            \ignorespaces
          }
        \makeatother

        \begin{document}
        \begin{questions}
          \question Jei you
          \questionInsbox[5]{0}
            {%
              \parbox[t]{.3\linewidth}
            {%
              \centering
              \includegraphics[width=\linewidth]{example-image-a.png}
              \captionof{figure}{This is A}%
            }%
            }[1]
        Hello, I want to wrap this figure in exam, and you should choose the rigth answer:
        \begin{enumerate}
          \item \lipsum[1]  
          \item \lipsum[1]
        \end{enumerate}

        \question Another
        \end{questions}
        \end{document} 

解決策は、最善ではありませんが、その場で入力したものは次のとおりです。

\question See figure and answer, please:    
\begin{enumerate}
\begin{multicols}{2}  
\item answer 1
\item ans 2
\item ans 3
{\centering
    \begingroup
                \centering
                \includegraphics[width=1.00\linewidth]{{example-image-a.png}
                \vspace{-0.3cm}
                \captionof{figure}{}
                \label{fig:croquis-rectangulo-ecuacions.png}
            \endgroup}
  \end{multicols}
  \item ans afeter fig
  \end{enumerate}

編集(2019/02/25)スキルモンの編集3の後 あなたの LaTeX プログラミングの知識に感心しています。素晴らしいですね!!

この解決策は通常のテキストには最適ですが、リスト(列挙、項目化など)を使用すると問題が残ります。Skillmonの最後のコメント(2019/02/24)を読んだ後、通常のテキストでリストをシミュレートすることにしました。\ a) 回答 1 回答 1 回答 1 回答 1 回答 1 回答 1 回答 1 回答 1 回答 1 回答 1\ b) 回答 2 回答 2 回答 2 回答 2 回答 2 回答 2 回答 2 回答 2 回答 2 回答 2\

LaTeX はとても美しく、とても複雑です!!

将来の試験クラスでこのオプションを待っています (私は楽観的です、はい!! :-) )... 時々あなたのソリューションを使用します。

私が見る限り、ページの下部でのみ失敗し、質問間のページがほぼ空白である \questionInsboxL[5]{2} を使用する場合に失敗が起こります。

皆様の解決策とご尽力に感謝いたします。

ここに画像の説明を入力してください

ありがとう、スキルモン

答え1

wrapfigリストでは機能せず、questionsリストの別のバージョンにすぎません。以下は、https://tex.stackexchange.com/a/453624/117050enumerateの代わりに、like リストで動作しますitemize。@Bernard の回答と同じように使用しますinsboxが、手動の段落は必要ありません。1 つの質問内でラップするコードのみを実装し、次の質問内ではラップしません。

編集:のポイント システムをサポートするようになりましたexamが、十分にテストしていません。うまくいかなかった場合は、再度戻ってきて苦情を言うかもしれません。

編集2:インターフェースが のインターフェースに似るように簡素化されました。\InsertBoxR新しいマクロの名前は\questionInsboxRで、オプションの引数、2 つの必須引数、および 2 番目のオプション引数を取ります。最初のオプション引数は のインターフェースに似ており\question、2 つの必須引数とそれに続くオプション引数は のインターフェースに似ています\InsertBoxR

編集3:1 つの環境内での複数の使用\questionInsboxLの動作を追加、修正しました。\questionInsboxL/Rquestions

\documentclass[12pt]{exam}
\usepackage{graphicx,wrapfig,lipsum}
\input{insbox}
\usepackage{capt-of}
\usepackage[onehalfspacing]{setspace}
\usepackage{mwe}

\usepackage{etoolbox}

\makeatletter
%% Stealing some code from exam:
\def\mypointshandling
  {%>>>
    \if@bonus
      \def\padded@point@block{%
        \begingroup
          \@placepointstrue
          \bonuspoint@block
        \endgroup
      }%
    \else
      \def\padded@point@block{%
        \begingroup
          \@placepointstrue
          \point@block
        \endgroup
      }%
    \fi
    \if@pointsdropped
    \else
      \if@bonus
        \if@bonusqformat
          \ifx\ques@ref\@queslevel
          \else
            \setup@point@toks
          \fi
        \else
          \setup@point@toks
        \fi
      \else
        \if@qformat
          \ifx\ques@ref\@queslevel
          \else
            \setup@point@toks
          \fi
        \else
          \setup@point@toks
        \fi
      \fi
    \fi
    \global \MyIfPointsfalse
  }%<<<
\protected\long\def\myOargparse#1#2%>>>
  {%
    \@ifnextchar[{\myOargparse@{#2}}{#2{#1}}%
  }%<<<
\long\def\myOargparse@#1[#2]%>>>
  {%
    #1{#2}%
  }%<<<
\def\q@mark{\q@mark}
\newif\ifMyIfPoints
\newif\if@notfirstins
\protected\def\questionInsboxL%>>>
  {%
    \myOargparse{\q@mark}{\questionInsbox@a\InsertBoxL}%
  }%<<<
\protected\def\questionInsboxR%>>>
  {%
    \myOargparse{\q@mark}{\questionInsbox@a\InsertBoxR}%
  }%<<<
\protected\long\def\questionInsbox@a#1#2#3#4%>>>
  {%
    \myOargparse{0}{\questionInsbox@b{#1}{#2}{#3}{#4}}%
  }%<<<
\protected\long\def\questionInsbox@b#1#2#3#4#5%>>>
  {%
    \if@notfirstins
    \else
      \def\makelabel##1{\hss\llap{##1}}%
      \apptocmd\@itemlabel{\hskip\leftmargin}{}{}%
    \fi
    \ifx\q@mark#2%
      \question
    \else
      \global\MyIfPointstrue
      \patchcmd\@readpoints{\global\@placepointstrue}{\relax}{}{}%
      \question[{#2}]%
      \patchcmd\@readpoints{\relax}{\global\@placepointstrue}{}{}%
    \fi
    \if@notfirstins
    \else
      \patchcmd\@itemlabel{\hskip\leftmargin}{}{}{}%
      \let\makelabel\@mklab
      \@notfirstinstrue
    \fi
    \mbox{}%
    \vspace*{-\baselineskip}%
    \setlength{\leftskip}{\leftmargin}%
    \ifx\InsertBoxR#1%
      #1{#3}{\hskip-\leftmargin#4\hskip\leftmargin}[{#5}]%
    \else
      #1{\numexpr#3+1\relax}{#4}[{#5}]\par\hspace{\itemindent}%
    \fi
    \ifMyIfPoints
      \mypointshandling
    \fi
    \the\point@toks
    \ignorespaces
  }%<<<
\makeatother

\begin{document}
\begin{questions}
  \question[5]\lipsum[2]
  \questionInsboxR[5]{0}
    {%
      \parbox[t]{.3\linewidth}
        {%
          \centering
          \includegraphics[width=\linewidth]{example-image-a.png}%
          \captionof{figure}{This is A}%
        }%
    }[1]
    Hello, I want to wrap this figure in exam
    \lipsum[1]
  \questionInsboxL[5]{2}
    {%
      \parbox[t]{.3\linewidth}
        {%
          \centering
          \includegraphics[width=\linewidth]{example-image-a.png}%
          \captionof{figure}{This is A}%
        }%
    }[1]
    Hello, I want to wrap this figure in exam
    \lipsum[1]
\end{questions}
\end{document}

ここに画像の説明を入力してください

答え2

captionこれは、プレーンな TeXinsboxマクロ パッケージを使用したソリューションです。\InsertBoxR段落の先頭に挿入されるコマンドを定義します。このコマンドは、挿入されるボックス ID の前の未変更の行数と、挿入されるボックス自体という 2 つの必須引数を受け取ります。さらに、TeX が必要な短い行の数を誤って計算した場合に備えて、必要な追加の短い行の数をオプションの引数として受け入れます。

\documentclass[12pt]{exam}
\usepackage{graphicx,wrapfig,lipsum}
\usepackage[onehalfspacing]{setspace}
\usepackage{mwe}
\usepackage{caption}
\input{insbox}

\begin{document}

\begin{questions}
\question
Hello, I want to wrap this figure in exam. \par
\InsertBoxR {0}{\parbox{0.3\linewidth}{\includegraphics[width=\linewidth]{example-image-a.png}\captionof{figure}{This is A}}}[3]
\lipsum[2]\lipsum[1]
\end{questions}

\end{document} 

ここに画像の説明を入力してください

関連情報