5

Here's an example :

\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}

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.

1 Answer 1

4

Use t (top alignment) for the optional argument of 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}

enter image description here

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

2
  • 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, 2014 at 0:37
  • 1
    @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. Jul 27, 2014 at 0:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .