Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Can you anchor a table at the bottom, inline with text?

I have another question posted which I seemed to have solved myself - List Numbering Through Multiple Tables - but I have since found my way around this original problem, into another.

My goal, depicted in the image below, is to create a multicolumn math test. The problem I have is aligning the question # with the answer choices (See image below MWE for current result). In my MWE my #2 label is midway up the rectangle instead of by the answer choices below "Column A" and "Column B."

Using automatic question numbering is essential. I do not want to have to input question numbers manually.

Goal - Correct Question Number Alignment

MWE:

\documentclass[letterpaper,twoside,openright]{memoir}
\usepackage[bmargin=1in]{geometry}
\setlength{\parindent}{0pt}

\usepackage{enumitem}
    \newlist{ptestlist}{enumerate}{2}
    \setlist[ptestlist]{label={\arabic*.},itemsep=5mm,labelsep=3mm,topsep=1cm}

\usepackage{multirow}
\usepackage{multicol}
\usepackage{tabularx}
    \newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{tikz}

\begin{document}

\begin{center}
{\LARGE Part One --- Word Problems}
\end{center}

\textbf{Directions:} Choose the best answer from the four choices given.

\hrulefill
%-----------        Questions           --------------% 
\setlength{\columnsep}{50pt}
\begin{multicols}{2}
\begin{ptestlist}[series=ptest,labelsep=0pt]
\item \begin{tabularx}{3in}{YY}
      \underline{Column A}
      &
      \underline{Column B}
      \\
      $6 + 4 - 5 \times 6$
      &
      34
      \\
      \end{tabularx}

\item \begin{tabularx}{3in}{YY}
      \multicolumn{2}{c}
      {
      \begin{tikzpicture}
      \draw (-1.85,0) node [rectangle,draw,minimum size=1in,
                            label=below:$2x$,label=right:$x$] (rsquare) {};
      \draw (1.75,0) node [rectangle,draw,minimum size=.8in,
                            label=below:$2y$,label=right:$y$] (lsquare) {};
      \end{tikzpicture}
      } \\
      \underline{Column A}
      &
      \underline{Column B}
      \\
      34
      &
      34
      \\
      \end{tabularx}

\item \begin{tabularx}{3in}{YY}
      \underline{Column A}
      &
      \underline{Column B}
      \\
      34
      &
      34
      \\
      \end{tabularx}

\item \begin{tabularx}{3in}{YY}
      \underline{Column A}
      &
      \underline{Column B}
      \\
      34
      &
      34
      \\
      \end{tabularx}
\end{ptestlist}

\end{multicols}
\end{document}

This code gets me here: MWE Result - Incorrect

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Use

\begin{tabularx}{\linewidth}[b]{YY}

to set the tabularx to be aligned to the bottom. Using \linewidth makes it fit within the column width, even with \item:

enter image description here

share|improve this answer

It sounds like you might like the adjustbox package, which can be used as follows

    \item \begin{adjustbox}{valign=t}\begin{tabularx}{3in}{YY}

screenshot

Here's a complete MWE:

% arara: pdflatex
\documentclass[letterpaper,twoside,openright]{memoir}
\usepackage[bmargin=1in]{geometry}
\setlength{\parindent}{0pt}

\usepackage{enumitem}
    \newlist{ptestlist}{enumerate}{2}
    \setlist[ptestlist]{label={\arabic*.},itemsep=5mm,labelsep=3mm,topsep=1cm}

\usepackage{multirow}
\usepackage{multicol}
\usepackage{tabularx}
    \newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{adjustbox}
\usepackage{tikz}

\begin{document}

\begin{center}
{\LARGE Part One --- Word Problems}
\end{center}

\textbf{Directions:} Choose the best answer from the four choices given.

\hrulefill
%-----------        Questions           --------------% 
\setlength{\columnsep}{50pt}
\begin{multicols}{2}
\begin{ptestlist}[series=ptest,labelsep=0pt]
\item \begin{tabularx}{3in}{YY}
      \underline{Column A}
      &
      \underline{Column B}
      \\
      $6 + 4 - 5 \times 6$
      &
      34
      \\
      \end{tabularx}

    \item \begin{adjustbox}{valign=t}\begin{tabularx}{3in}{YY}
      \multicolumn{2}{c}
      {
      \begin{tikzpicture}
      \draw (-1.85,0) node [rectangle,draw,minimum size=1in,
                            label=below:$2x$,label=right:$x$] (rsquare) {};
      \draw (1.75,0) node [rectangle,draw,minimum size=.8in,
                            label=below:$2y$,label=right:$y$] (lsquare) {};
      \end{tikzpicture}
      } \\
      \underline{Column A}
      &
      \underline{Column B}
      \\
      34
      &
      34
      \\
      \end{tabularx}
    \end{adjustbox}

\item \begin{tabularx}{3in}{YY}
      \underline{Column A}
      &
      \underline{Column B}
      \\
      34
      &
      34
      \\
      \end{tabularx}

\item \begin{tabularx}{3in}{YY}
      \underline{Column A}
      &
      \underline{Column B}
      \\
      34
      &
      34
      \\
      \end{tabularx}
\end{ptestlist}

\end{multicols}
\end{document}
share|improve this answer
    
maybe I've missed the point... –  cmhughes Mar 29 at 1:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.