# Newtheoremstyle head aligned with top of tabularx

Here's an example :

\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, amsthm}

\usepackage{tikz}
\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}


What I want is the number of the exercise to be aligned with the top of the tabularx (question a)) instead of being aligned with the middle of the tabularx.

Use t (top alignment) for the optional argument of tabularx:

\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, amsthm}

\usepackage{tikz}
\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}


Not related to the question, but to prevent an overfull \hbox you'll need to reduce the width for the tabularx.

• You mean I should change the argument \textwidth when I use \tabularx ? Then how could I still have the width of the text without risking an overfull \hbox ? – Amateur Jul 27 '14 at 0:37
• @Amateur Yes, precisely that. Since you declared a 2em hangindet for the exercise environment, you'll need \begin{tabularx}{\dimexpr\linewidth-2em\relax}[t]{r @{\hskip .4em} X} to prevent the bad box in this case. – Gonzalo Medina Jul 27 '14 at 0:39