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.

I'm currently writing up some solutions, and I like to rewrite the problem before answering it.

I've set exercise to be a theorem environment, and the code I'm using is

\begin{exercise} 
\begin{enumerate} 
\item Show that $R$ is symmetric iff $R^{-1}\subseteq R$.
\item Show that $R$ is transitive iff $R\circ R\subseteq R$.
\end{enumerate}
\begin{proof}
\end{proof}
\end{exercise}

However, when I build, the first item (a) appears immediately to the right of the Exercise heading, and the second item (b) appears below and indented:

alt text

I've tried using \newline and \linebreak, and even skipping a line before typing \begin{enumerate} after the \begin{exercise} command but those don't work. Is there a way to push (a) down below Exercise 3.32. so that it's lined up with (b)? Thank you.

As requested, my preamble is:

\documentclass[11pt]{article}
\input{other/packages.tex}
\input{other/theoremdef.tex}

where packages.tex is

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amscd}
\usepackage{url}
\usepackage[top=1.3in, bottom=1.3in, left=1.3in, right=1.3in]{geometry}

% header and footer
\pagestyle{headings}

\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{stackrel}
\usepackage{mathrsfs}
\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{hyperref}
\usepackage{xy}
\input xy
\xyoption{all}

And theoremdef.tex is:

\newtheorem{exercise}{\bf Exercise}
\newcommand{\dom}{\text{dom}\ }
\newcommand{\ran}{\text{ran}\ }
\newcommand{\fld}{\text{fld}\ }
\newcommand{\op}[2]{\langle #1,#2\rangle}
\newcommand{\ot}[3]{\langle #1,#2,#3\rangle}
\newcommand{\ms}[1]{\mathscr{#1}}
share|improve this question
    
I am waiting for this answer too. If it does not matter to you, please submit the preamble defining the environment too. Thanks. –  xport Jan 2 '11 at 6:11
    
Of course, I will add that in. –  yunone Jan 2 '11 at 6:13
    
I've marked your inline code with backticks. –  Hendrik Vogt Jan 2 '11 at 9:08

5 Answers 5

up vote 12 down vote accepted

Insert

\leavevmode

after the \begin{exercise}. That puts you into horizontal mode, which is where you want to be when you encounter the \begin{enumerate}.

share|improve this answer
    
Thanks Phil, this worked great. This may be a dumb question, but will I ever have to "return to vmode", as in undo the \leavevmode command, or does it leave later parts of the document unaffected? –  yunone Jan 2 '11 at 7:09
    
@yunone: \leavevmode works as \mbox{}, it does not affect other part of document. –  Leo Liu Jan 2 '11 at 7:19
    
@Phil: Welcome to tex.sx! Note that I've marked your inline code with backticks. –  Hendrik Vogt Jan 2 '11 at 9:10

See theorem or ntheorem package. Here is an example:

\documentclass{article}
\usepackage{theorem} % or ntheorem
\theoremstyle{break}
\newtheorem{exercise}{Exercise}
\begin{document}
\begin{exercise}
\begin{enumerate}
  \item foo
  \item bar
\end{enumerate}
\end{exercise}
\end{document}

It may be a little more complex to do that using amsthm. In amsthm we can define:

\usepackage{amsthm}
\newtheoremstyle{break}{3pt}{3pt}{\itshape}{}{\bfseries}{.}{\newline}{}
\theoremstyle{break}
\newtheorem{exercise}{Exercise}

It works fine without a enumerate environment at the beginning, but will fail for your code. This is a solution:

\begin{exercise}\mbox{}
\begin{enumerate}
  \item foo
  \item bar
\end{enumerate}
\end{exercise}

It seems no elegant solution. Therefore I prefer ntheorem to modify theorem styles.

share|improve this answer
    
Thanks Leo for your efforts on my problem. –  yunone Jan 2 '11 at 7:09

I've extracted the following from thmtools' handling of the listhack key:

\def\thmt@amsthmlistbreakhack{%
  \leavevmode
  \vspace{-\baselineskip}%
  \par
  \everypar{\setbox\z@\lastbox\everypar{}}%
}

I find that without the \vspace, the vertical space before the list is excessive. I don't remember right now why I put the \everypar stanza there, in particular, why I didn't use \noindent. I'll check that again.

share|improve this answer

I believe this is what you are looking for:

\begin{exercise} 
\begin{enumerate} 
\item[]
\item Show that $R$ is symmetric iff $R^{-1}\subseteq R$.
\item Show that $R$ is transitive iff $R\circ R\subseteq R$.
\end{enumerate}
share|improve this answer

As Leo Liu suggested, I do this:

\begin{theorem}
  \mbox{}
  \begin{enumerate}
  \item foo
  \item bar
  \end{enumerate}
\end{theorem}
share|improve this answer

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.