# Mixing enumerate and tabbing, whats wrong here?

So I can't seem to figure out whats wrong with my LaTeX file. Do you guys see anything obvious?

\documentclass[11pt]{article}

\newcommand{\df}[1]{\textbf{#1}}

\begin{document}
\section{Midterm 1}
\subsection{Definitions}
\begin{enumerate}
\begin{tabbing}
\item \df{Determinism} \= - \= blabhablabhabhalbha
\item \df{Parsimony} \> - \> alalalalalalala
\end{tabbing}
\end{enumerate}
\end{document}

-

You cannot nest the tabbing environment inside an enumerate in this way. Perhaps this is what you're after - alignment after the -:

\documentclass[11pt]{article}

\newcommand{\df}[1]{\textbf{#1}}

\begin{document}
\section{Midterm 1}
\subsection{Definitions}
\begin{enumerate}
\item \df{Determinism} - blabhablabhabhalbha
\item \leavevmode\rlap{\df{Parsimony}}\phantom{\df{Determinism}} - alalalalalalala
\end{enumerate}
\end{document}


\leavevmode initializes the \item, while \rlap causes a right overlap (zero-width, left-aligned box) of the \phantom (non-existent) content.

This can be automated to some extent using the following setup:

\documentclass[11pt]{article}
\newcommand{\df}[1]{\textbf{#1}}
\newlength{\maxitemwidth}
\newcommand{\maxitem}[1]{\settowidth{\maxitemwidth}{#1}}
\makeatletter
\newcommand{\Item}[1]{%
\item #1%
\sbox\@tempboxa{#1}%
\ifdim\maxitemwidth>\z@\hspace*{\dimexpr\maxitemwidth-\wd\@tempboxa}\fi%
}
\begin{document}
\section{Midterm 1}
\subsection{Definitions}
\begin{enumerate}
\item \df{Determinism} - blabhablabhabhalbha
\item \df{Parsimony} - alalalalalalala
\end{enumerate}
Some text.
\maxitem{\df{Determinism}}\showthe\maxitemwidth
\begin{enumerate}
\Item{\df{Determinism}} - blabhablabhabhalbha
\Item{\df{Parsimony}} - alalalalalalala
\end{enumerate}
\end{document}


You set the maximum-width item using \maxwidth and then use \Item{<item>} in the enumerate list. All subsequent lists will then be typeset with this in mind. There are other ways of doing this, but not knowing the exact usage makes this sufficient, I guess.

-
Holy crap I never would have gotten that on my own. What a solution! Thumbs up for you good sir. – Dan Jun 16 '12 at 5:26
Wouldn't it be possible to make a function that does this for each word, takes in two arguments, the word to type, and the word to phantom? – Dan Jun 16 '12 at 17:24
@Dan: I've added some detail to this extent which is a little easier than using two arguments. It's not optimal, but it should suffice in your instance. As I mention, there should be other ways of doing this, but without knowing more about your usage its hard to make things work efficiently. Give some feedback if you need more. – Werner Jun 16 '12 at 17:49

if you want also possible linebreaks in the definition

\documentclass[11pt]{article}

\usepackage{tabularx,lipsum}
\newcolumntype{S}{@{\stepcounter{Definition}\theDefinition.~} >{\bfseries}l @{~--~}X@{}}
\newcounter{Definition}[subsection]

\begin{document}
\section{Midterm 1}
\subsection{Definitions}

\begin{tabularx}{\linewidth}{S}
Determinism & blabhablabhabhalbha \\
Parsimony   & \lipsum[4]
\end{tabularx}

\end{document}


-