考虑以下 :
\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{shadows}
\newcommand*\squared[1]{\tikz[baseline=(char.base)]{\node[shape=rectangle, draw, inner color = white, drop shadow = {opaque, black}, inner sep=3pt, text justified] (char) {#1};}}
\newtheoremstyle{exercise}
{\topsep}
{\topsep}
{\hangindent=2em}
{}
{}
{}
{.8em}
{\squared{\thmnumber{#2}}}
\theoremstyle{exercise}
\newtheorem{exercise}{}
\renewcommand{\arraystretch}{1.75}
\usepackage{tabularx}
\begin{document}
\begin{exercise}
\begin{tabularx}{\textwidth}[t]{r @{\hskip .4em} X}
a) & This is a test. \\
b) & I say
$$
\pi \approx 3.14.
$$ \\
c) & Do you agree?
\end{tabularx}
\end{exercise}
\end{document}
似乎 b) 以数学模式结束会在 c) 之前增加额外的垂直间距。但我希望间距是均匀的。也就是说,我希望 b) 和 c) 之前有相同的垂直间距。如何做到?
答案1
你的选择不多。
第一个方法是将等式添加到一行中:
\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{shadows}
\newcommand*\squared[1]{\tikz[baseline=(char.base)]{\node[shape=rectangle, draw, inner color = white, drop shadow = {opaque, black}, inner sep=3pt, text justified] (char) {#1};}}
\newtheoremstyle{exercise}
{\topsep}
{\topsep}
{\hangindent=2em}
{}
{}
{}
{.8em}
{\squared{\thmnumber{#2}}}
\theoremstyle{exercise}
\newtheorem{exercise}{}
\renewcommand{\arraystretch}{1.75}
\usepackage{tabularx}
\begin{document}
\begin{exercise}
\begin{tabularx}{\textwidth}[t]{r @{\hskip .4em} X}
a) & This is a test. \\
b) & I say \\
&
\hfil $\pi \approx 3.14$.
\\
c) & Do you agree?
\end{tabularx}
\end{exercise}
\end{document}
然而,我觉得在对练习环境进行一些修改之后,列表枚举会是更好的方法。
这里还有一些补充。这些并不完美,因为被修改了,并且\arraystretch
的宽度没有准确计算。不过,它可以作为一个起点。\parbox
\minipage
\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{shadows}
\newcommand*\squared[1]{\tikz[baseline=(char.base)]{\node[shape=rectangle, draw, inner color = white, drop shadow = {opaque, black}, inner sep=3pt, text justified] (char) {#1};}}
\newtheoremstyle{exercise}
{\topsep}
{\topsep}
{\hangindent=2em}
{}
{}
{}
{.8em}
{\squared{\thmnumber{#2}}}
\theoremstyle{exercise}
\newtheorem{exercise}{}
\renewcommand{\arraystretch}{1.75}
\usepackage{tabularx,enumitem,showframe}
\begin{document}
\begin{exercise}
\begin{tabularx}{\dimexpr\textwidth-2.8em\relax}[t]{@{\,}r @{\hskip .4em} X}
a) & This is a test. \\
b) & I say \parbox[t]{0.88\linewidth}{%
\[
π\approx 3.14.
\]
}\\
c) & Do you agree?
\end{tabularx}
\end{exercise}
\begin{exercise}
\begin{minipage}[t]{0.928\linewidth}
\begin{enumerate}[label = \alph*),leftmargin=*,topsep=0pt,partopsep=0pt]
\item This is a test.
\item I say
\[
π\approx 3.14.
\]
\item Do you agree?
\end{enumerate}
\end{minipage}%
\end{exercise}
\end{document}