以下是一个例子:
\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, amsthm}
\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}{r @{\hskip .4em} X}
a) & This is a test. \\
b) & This is a long test. \\
c) & This is a very long test.
\end{tabularx}
\end{exercise}
\end{document}
我想要的是练习的编号与顶部表格(问题 a))而不是与中间的 tabularx。
答案1
使用t
(顶部对齐)作为可选参数tabularx
:
\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, amsthm}
\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) & This is a long test. \\
c) & This is a very long test.
\end{tabularx}
\end{exercise}
\end{document}
与问题无关,但为了防止过满,\hbox
您需要减少宽度tabularx
。