我想将 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 skip
after skip
beforeafter skip
\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}