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.

What I'm trying to do is to make my enumerates look like this

a)
    i) answer
    ii) answer
b) answer

Currently, I'm using

\begin{enumerate}
\item \hfill \\
    \begin{enumerate}[a)]
    \item
    \item
    \end{enumerate}
\end{enumerate}

but it looks like there are 2 empty lines when I do this, instead of one.

a)


    i)

I have tried a lot of spacing commands, but I couldn't get them to work (new to LaTeX).

So, Is there a way to do this? or should i just put them all on the same line? I know its easier but I think it looks weird.

share|improve this question
1  
"Or should I just put them all on the same line?" Yes, that's what I'd recommend, at least if this doesn't destroy alignment of "i)" with "ii)". That case could also be dealt with. –  Hendrik Vogt Jan 24 '11 at 11:47
add comment

2 Answers

up vote 10 down vote accepted

Anything that creates an empty box or adds some white space will do the trick. For example \mbox{} or even \hfill. The problem with \hfill\\ is that it fills the line, then creates a new line and then creates a new paragraph for the list; so there is to much vertical white space.

\begin{enumerate}
    \item \mbox{}
    \begin{enumerate}
        \item
        \item
    \end{enumerate}
\end{enumerate}

example

share|improve this answer
1  
I misunderstood '\hfill', I thought it would fill in the horizontal space only if there was another character after it, sort of like a justification. At least now its fixed. \hurray! –  Buttink Jan 24 '11 at 4:28
add comment

If you wish all your {enumerate} to behave like this, you can patch the \item command to add a \leavevmode (which has the same effect here as the \mbox{} suggested by Caramdir) to automate all this. The patching can be done through the \apptocmd command from the etoolbox package which appends code at the end of a command. You cannot directly append to enumerate and item if you want to be able to use optional arguments (you need to patch \\enumerate and \@item for this). In the following code, I've also used the enumitem package to customize the lists (it allows to automatically have a), b), etc. for second level {enumerate}).

screenshot of the result

\documentclass{article}
\usepackage{enumitem}
\setenumerate[2]{label=\alph*)}
\usepackage{etoolbox}
\makeatletter
\expandafter\apptocmd\expandafter{\csname\string\enumerate\endcsname}{\apptocmd{\@item}{\leavevmode}{}{}}{}{}
\makeatother
\begin{document}
\begin{enumerate}
    \item \begin{enumerate}
              \item answer
              \item answer
          \end{enumerate}
    \item answer
          \begin{enumerate}
              \item answer
              \item answer
          \end{enumerate}
\end{enumerate}
\end{document}

The code \apptocmd{\@item}{\leavevmode}{}{} appends to \item a \leavevmode which always starts a new line after an \item inside an {enumerate}. To restrict this to {enumerate} environments only, this code is itself append to \enumerate thanks to another \apptocmd.

A final note on this code: if you nest an {itemize} inside a {enumerate}, the \item will also have been redefined (if that's a problem, it's not difficult to patch {itemize} to keep the original definition of \item).

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.