段落の間に tikzpicture をうまく配置するにはどうすればよいでしょうか?

段落の間に tikzpicture をうまく配置するにはどうすればよいでしょうか?

段落の間に tikzpicture をうまく配置したいのですが、どうすればよいですか? 下に余分なスペースがあるため、画像環境に配置したくありません。

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions
%\printanswers
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}

\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}

\begin{document}
\begin{questions}


Line above tikzpicture.

\begin{tikzpicture}[rounded corners=5mm]
\path node[rectangle,draw=green,fill=green!8,inner sep=.70cm] {\parbox{\textwidth-1.4cm-\fboxrule}{

\question[2] What is the first question?
\begin{solutionorlines}[4cm]
This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?
\end{solutionorlines}
}};
\end{tikzpicture}

Line under tikzpicture. I don't want this. I want the tikzpicture between paragraphs.

\end{questions}
\end{document}

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

答え1

色付きのボックスを描くことは、 をtcolorboxソリューションとして提供するための私のキャッチフレーズです。 正確な空白の寸法は と を使用して設定できますbefore skipafter skip同じにしたい場合は、 を使用することもできますbeforeafter skip。 以下の 2 つのボックスを使用します。最初のボックスは通常のもので、2 番目のボックスは距離設定を示すためだけのものです。

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions
%\printanswers
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}
\usepackage{tcolorbox}

\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}

\newtcolorbox{greenbox}[1][]{%
  size=fbox,
  arc=5mm,
  boxsep=0.7cm,
  %boxsep=\fboxsep,% uncommented to use \fboxsep
  colframe=green,
  colback=green!8,
  beforeafter skip=3mm,% <--- Space setting before and after
  #1%
}

\begin{document}

\begin{questions}

Line above tikzpicture.

\begin{greenbox}
  \question[2] What is the first question?
  \begin{solutionorlines}[4cm]
  This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?
  \end{solutionorlines}
\end{greenbox}

Line under tikzpicture. I don't want this. I want the tikzpicture between paragraphs.

Line above tikzpicture.

\begin{greenbox}[beforeafter skip=0mm]
  \question[2] What is the first question?
  \begin{solutionorlines}[4cm]
  This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?
  \end{solutionorlines}
\end{greenbox}

Line under tikzpicture. I don't want this. I want the tikzpicture between paragraphs.

\end{questions}

\end{document}

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

答え2

クラスはわかりませんexamが、環境内ではすべての段落が異なって扱われるようですquestions。段落区切りを追加せずに改行を追加できます。

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions
%\printanswers
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}

\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}

\begin{document}
\begin{questions}

Line above tikzpicture.\\[1em]
\begin{tikzpicture}[rounded corners=5mm]
\path node[rectangle,draw=green,fill=green!8,inner sep=.70cm] {
  \parbox{\textwidth-1.4cm-\fboxrule}{
    \question[2] What is the first question?
    \begin{solutionorlines}[4cm]
    This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?
    \end{solutionorlines}
  }};
\end{tikzpicture}\\[1em]
Line under tikzpicture. I don't want this. I want the tikzpicture between paragraphs.

\end{questions}
\end{document}

注記:mdframed質問をフレーム内に配置したい場合はパッケージをチェックしてください。

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

答え3

これは完全な解決策ではありません。間隔がわずかにずれており、回答の幅が広すぎます。最終調整を行う時間がありません。他の人はこの回答を編集したり、出発点として使用したりできます。

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions
\printanswers % or commented out for lines
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}

\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}

\begin{document}
\begin{questions}

\question[2] What is the first question?
\begin{solutionorlines}[4cm]
\begin{minipage}[t][4cm]{\textwidth}This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?\end{minipage}
\end{solutionorlines}
\question[2] What is the second question?
\begin{solutionorlines}[4cm]
\begin{minipage}[t][4cm]{\textwidth} This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?\end{minipage}
\end{solutionorlines}

\end{questions}
\end{document}

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

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

関連情報