Graphics, Figures & Tablestabularx | Alignment in an enumerated List

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jason17439
Posts: 1
Joined: Fri Sep 07, 2012 1:04 am

tabularx | Alignment in an enumerated List

Post by jason17439 »

I am writing a homework document for my class. The questions are provided in a LaTeX document and we are to add our solutions to the document. I want my solutions to have a consistent look throughout the document so I have created a couple of new environments.

The first is a pretty simple enumerate environment for solutions to multi-part questions, defined as follows:

Code: Select all

\newenvironment{solutionenum}
{
\begin{enumerate}[a)]
\setlength{\itemsep}{1.5pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}
{\end{enumerate}}
The second environment is for two column proofs, i.e. logical steps on the left side and justification on the right side. It is defined as follows:

Code: Select all

\newenvironment{solutiontable}
{\def\arraystretch{1.3}  \tabularx{\linewidth}{l | l}}
{\endtabularx}
They both work fine on their own but when used together:

Code: Select all

\begin{solutionenum}
\item
\begin{solutiontable}
$[\neg p \wedge (p\vee q)] \rightarrow q$ & Hypothesis \\
$(\neg p \wedge p)\vee (\neg p \wedge q) \rightarrow q$ & Distributive property. \\
etc...
\end{solutiontable}
\end{solutionenum}
the enumeration label is centered vertically on the table rather than at the top.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tabularx | Alignment in an enumerated List

Post by localghost »

The tabularx environment accepts an optional alignment parameter.

Code: Select all

\newenvironment{solutiontable}{%
  \renewcommand*{\arraystretch}{1.3}%
  \tabularx{\linewidth}[t]{l|l}%
}{\endtabularx}
Since you don't use the X column type, you actually don't need the tabularx environment.

Next time please prepare a proper minimal example to avoid guesswork.


Best regards and welcome to the board
Thorsten
Post Reply