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.

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}
share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

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

enter image description here

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

enter image description here

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

share|improve this answer
    
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
add comment

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}

enter image description here

share|improve this answer
add comment

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.