我正在设计试卷。其中几个问题包含图表,我想将图表格式化为问题的右半部分。我正在使用exsheets
软件包来编写问题并TikZ
生成图表。点通过星号显示,应该显示在页边距中。如果没有图表,一切都会正常进行。但是,如果我包含图表,一切都会变得一团糟。
我也尝试过使用wrapfig
和cutwin
包,但结果更糟。最后我尝试使用编写我自己的“包装”命令minipage
。这也非常令人不快。
我发现它有几个问题
问题开始时不显示问号“QB [2]”。
第二个问题的文本缩进与第一个问题的缩进非常不同。
第二个问题中的明星发挥也不太好。
我丑陋地划出额外的 15% 来容纳问号“QB [2]”。
\begin{minipage}{\dimexpr\textwidth-#1\textwidth-.15\textwidth\relax}
完整的 MWE 在此处:
\documentclass{article}
\usepackage[headings=runin]{exsheets}
\usepackage{tikz}
\newcommand{\rowpoints}[1]{[\foreach\x in {1,...,#1} {$\star$}]}
\SetupExSheets{counter-format=QB [qu]}
\SetupExSheets[question]{name=}
\SetupExSheets[points]{name=,number-format=\rowpoints}
\newcommand{\wraparound}[3]{
\begin{minipage}{\dimexpr\linewidth-#1\linewidth-.15\linewidth\relax}
#2
\end{minipage}%
\begin{minipage}{#1\linewidth}%
#3
\end{minipage}%
}%
\begin{document}
\begin{question}{3}
A meaningless question without graphs. This looks nice and the next one is supposed to look the same.
\end{question}
\begin{question}{2}
\wraparound{.5}{
Let me write here a meaningless question with a meaningless graph.
}{\begin{tikzpicture}
\draw[->] (0,-1.5) -- (0,1.5) node[above] {$a (ms^2)$};
\draw[->] (-.3,0) -- (5,0) node[right] {$t (s)$};
\foreach \ini [evaluate=\ini as \inieval using 2*\ini] in {0,...,1}
\draw (\inieval,-1) -- ++(0,2) -| (\inieval+1,-1) -- (\inieval+2,-1);
\draw (1pt, 1) -- (-1pt, 1) node[anchor = east] {$1$};
\draw (1pt, -1) -- (-1pt, -1) node[anchor = east] {$-1$};
\foreach \x in {1,...,4}
\draw (\x cm, 1pt) -- (\x cm, -1pt) node[anchor = north] {$\x$};
\draw (4,0.5) node[align=left] {$\cdots$};
\end{tikzpicture}}
\begin{tabular}{llll}
(\textit{a}) & $\sin\theta_1 < \sin\theta_2$ & (\textit{b}) & $\sin\theta_1 > \sin\theta_2$ \\
(\textit{c}) & $\sin\theta_1 = \sin\theta_2$ & (\textit{d}) & $\sin^2\theta_1 > \sin^2\theta_2$
\end{tabular}
\end{question}
\end{document}
我可以纠正这些问题吗?有什么建议吗?
相同的图像:
答案1
您可以将整个问题放在 minpage 中,但如果您减小宽度,[**] 东西就会移动。因此,我过去常常\rightskip
为图形保留空间。首先,您需要知道它有多大,因此需要 savebox。然后,您使用\llap
和\raisebox
将图形叠加在保留的空间中。
我也尝试使用 wrapfigure,但它将表格视为单行文本,并在图形末尾继续缩进。
\documentclass{article}
\usepackage{tasks}
\usepackage[headings=runin]{exsheets}
\usepackage{tikz}
\usepackage{showframe}% debugging tool
\newsavebox{\wrapbox}
\newcommand{\rowpoints}[1]{[\foreach\x in {1,...,#1} {$\star$}]}
\SetupExSheets{counter-format=QB [qu]}
\SetupExSheets[question]{name=}
\SetupExSheets[points]{name=,number-format=\rowpoints}
\begin{document}
\begin{question}{3}
A meaningless question without graphs. This looks nice and the next one is supposed to look the same.
\end{question}
\savebox{\wrapbox}{\begin{tikzpicture}
\draw[->] (0,-1.5) -- (0,1.5) node[above] {$a (ms^2)$};
\draw[->] (-.3,0) -- (5,0) node[right] {$t (s)$};
\foreach \ini [evaluate=\ini as \inieval using 2*\ini] in {0,...,1}
\draw (\inieval,-1) -- ++(0,2) -| (\inieval+1,-1) -- (\inieval+2,-1);
\draw (1pt, 1) -- (-1pt, 1) node[anchor = east] {$1$};
\draw (1pt, -1) -- (-1pt, -1) node[anchor = east] {$-1$};
\foreach \x in {1,...,4}
\draw (\x cm, 1pt) -- (\x cm, -1pt) node[anchor = north] {$\x$};
\draw (4,0.5) node[align=left] {$\cdots$};
\draw[green] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}}%
\noindent\begin{minipage}[t]{\textwidth}%
\rightskip=\dimexpr \wd\wrapbox+\columnsep\relax
\begin{question}{2}
Let me write here a meaningless question with a meaningless graph.
\begin{tabular}{ll}
(\textit{a}) & $\sin\theta_1 < \sin\theta_2$ \\
(\textit{b}) & $\sin\theta_1 > \sin\theta_2$ \\
(\textit{c}) & $\sin\theta_1 = \sin\theta_2$ \\
(\textit{d}) & $\sin^2\theta_1 > \sin^2\theta_2$
\end{tabular}
\end{question}
\end{minipage}\llap{\raisebox{\dimexpr-\dp\strutbox-\ht\wrapbox}{\usebox{\wrapbox}}}%
\begin{question}{3}
A meaningless question without graphs. This looks nice and the next one is supposed to look the same.
\end{question}
\end{document}
此版本将图形置于问题的中心。
\documentclass{article}
\usepackage{tasks}
\usepackage[headings=runin]{exsheets}
\usepackage{tikz}
\usepackage{showframe}% debugging tool
\newsavebox{\wrapbox}
\newcommand{\rowpoints}[1]{[\foreach\x in {1,...,#1} {$\star$}]}
\SetupExSheets{counter-format=QB [qu]}
\SetupExSheets[question]{name=}
\SetupExSheets[points]{name=,number-format=\rowpoints}
\begin{document}
\begin{question}{3}
A meaningless question without graphs. This looks nice and the next one is supposed to look the same.
\end{question}
\savebox{\wrapbox}{\begin{tikzpicture}
\draw[->] (0,-1.5) -- (0,1.5) node[above] {$a (ms^2)$};
\draw[->] (-.3,0) -- (5,0) node[right] {$t (s)$};
\foreach \ini [evaluate=\ini as \inieval using 2*\ini] in {0,...,1}
\draw (\inieval,-1) -- ++(0,2) -| (\inieval+1,-1) -- (\inieval+2,-1);
\draw (1pt, 1) -- (-1pt, 1) node[anchor = east] {$1$};
\draw (1pt, -1) -- (-1pt, -1) node[anchor = east] {$-1$};
\foreach \x in {1,...,4}
\draw (\x cm, 1pt) -- (\x cm, -1pt) node[anchor = north] {$\x$};
\draw (4,0.5) node[align=left] {$\cdots$};
\draw[green] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}}%
\noindent\begin{minipage}{\textwidth}%
\rightskip=\dimexpr \wd\wrapbox+\columnsep\relax
\begin{question}{2}
Let me write here a meaningless question with a meaningless graph.
\begin{tabular}{ll}
(\textit{a}) & $\sin\theta_1 < \sin\theta_2$ \\
(\textit{b}) & $\sin\theta_1 > \sin\theta_2$ \\
(\textit{c}) & $\sin\theta_1 = \sin\theta_2$ \\
(\textit{d}) & $\sin^2\theta_1 > \sin^2\theta_2$
\end{tabular}
\end{question}
\end{minipage}\llap{\raisebox{-0.5\ht\wrapbox}{\usebox{\wrapbox}}}%
\begin{question}{3}
A meaningless question without graphs. This looks nice and the next one is supposed to look the same.
\end{question}
\end{document}
答案2
部分答案:
我设法使用adjustbox
包纠正了问题 1 和 3。现在只剩下奇怪的缩进和问题 4。
分数维:
\documentclass{article}
\usepackage[headings=runin]{exsheets}
\usepackage{tikz,adjustbox}
\newcommand{\rowpoints}[1]{[\foreach\x in {1,...,#1} {$\star$}]}
\SetupExSheets{counter-format=QB [qu]}
\SetupExSheets[question]{name=}
\SetupExSheets[points]{name=,number-format=\rowpoints}
\newcommand{\wraparound}[3]{
\adjustbox{valign=t}{\begin{minipage}{\dimexpr\linewidth-#1\linewidth-.15\linewidth\relax}
#2
\end{minipage}}%
\hfill%
\adjustbox{valign=t}{\begin{minipage}{#1\linewidth}%
#3
\end{minipage}}%
}%
\begin{document}
\begin{question}{3}
A meaningless question without graphs. This looks nice and the next one is supposed to look the same.
\end{question}
\begin{question}{2}
\wraparound{.5}{
Let me write here a meaningless question with a meaningless graph.
}{\begin{tikzpicture}
\draw[->] (0,-1.5) -- (0,1.5) node[above] {$a (ms^2)$};
\draw[->] (-.3,0) -- (5,0) node[right] {$t (s)$};
\foreach \ini [evaluate=\ini as \inieval using 2*\ini] in {0,...,1}
\draw (\inieval,-1) -- ++(0,2) -| (\inieval+1,-1) -- (\inieval+2,-1);
\draw (1pt, 1) -- (-1pt, 1) node[anchor = east] {$1$};
\draw (1pt, -1) -- (-1pt, -1) node[anchor = east] {$-1$};
\foreach \x in {1,...,4}
\draw (\x cm, 1pt) -- (\x cm, -1pt) node[anchor = north] {$\x$};
\draw (4,0.5) node[align=left] {$\cdots$};
\end{tikzpicture}}
\begin{tabular}{llll}
(\textit{a}) & $\sin\theta_1 < \sin\theta_2$ & (\textit{b}) & $\sin\theta_1 > \sin\theta_2$ \\
(\textit{c}) & $\sin\theta_1 = \sin\theta_2$ & (\textit{d}) & $\sin^2\theta_1 > \sin^2\theta_2$
\end{tabular}
\end{question}
\end{document}