35

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}}
38

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

  • 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
  • This adds a lot of vertical space. I added \vspace*{-\bigskipamount}\vspace*{-\medskipamount} which removes the space again, but I'm not 100% sure that it's the right amount of space. – morxa Mar 12 '17 at 9:48
6

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.

6

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}
3

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.

2

I (sort of accidentally) discovered that simply using \item immediately after \begin{theorem} can achieve the desired effect. For example, try

\begin{theorem}[Name of Theorem]
\item This is a theorem with multiple parts.
    \begin{enumerate}
    \item stuff here.
    \item and here.
    \item and here, as well.
    \end{enumerate}
\end{theorem}

I haven't yet found an instance that this fails for. Hope this helps.

  • Welcome to TeX.SX! Could you elaborate on your solution and show some screen shot? – user31729 Apr 16 '15 at 23:36
  • 1
    This works nicer for me than \leavevmode - that is because leavevmode seems to cause a new paragraph (i.e., there is "too much" spacing between the theorem name and the enumeration). A blank \item line by itself looks much nicer! – MotiN Jan 7 '16 at 11:45
0

As Leo Liu suggested, I do this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.