4

My question is related to this one : Is it possible to skip the first line in a theorem environment? Actually, I am looking for a way to implement the solution given there in a somewhat systematic manner.

More precisely : whenever one starts a theorem with a list, the first item of the list appears on the same line as the theorem header ("Theorem"), even if one specifies \newline in the theorem style. I would like to force Latex to skip a line, even in this case.

One of the simplest solution suggested in the question above is to add a empty item at the beginning of the list :

\begin{thm}
\begin{enumerate}
\item[] 
\item First actual item
\item Second actual item
\end{enumerate}
\end{thm}

My question is : is there a systematic way to add this blank item at the beginning of every theorem, by adding it into the theoremstyle command ? (Or at the beginning of every enumerate environment ?)

The idea would be that when one types :

\begin{thm}
Body of the theorem
\end{thm}

Latex would understand :

\begin{thm}
\begin{enumerate}
\item[]
\end{enumerate}
Body of the theorem
\end{thm}

My code and my theorem style are the following :

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}

\newtheoremstyle{exercisestyle}%                % Name
{}%                                     % Space above
{}%                                     % Space below
{}%                                     % Body font
{}%                                     % Indent amount
{\bfseries}%                            % Theorem head font
{}%                                     % Punctuation after theorem head
{\newline}%                             % Space after theorem head, ' ', or \newline
{\thmname{#1}\thmnumber{ #2} --- \thmnote{#3}}%            % Theorem head spec (can be left empty, meaning `normal')

\theoremstyle{exercisestyle}
\newtheorem{exercice}{Exercice}

\begin{document}

\begin{exercice}[Title]
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
\end{exercice}

\end{document}
  • What is it supposed to do if theorem body has no list? – Bernard Jul 16 '16 at 21:48
  • @Bernard The idea was to add a list with one empty item at the beginning of each theorem, regardless of whether the theorem starts with a list or not. But as ilFuria pointed out, this may not be very good for theorems starting at the end of a page. – user75362 Jul 17 '16 at 8:29
  • What I meant with my question was this: even if the theorem doesn't begin with a list (or has no list), will it begin on a different line from the label? – Bernard Jul 17 '16 at 9:43
  • @Bernard Yes, but that is taken care of automatically by the \newline command in \theoremstyle. – user75362 Jul 17 '16 at 13:47
2

The amsthm package manual has it covered in §2.1. You can obtain it via texdoc amsthm on your system, or on CTAN

I loosely quote that section:

The best way to avoid these problems is to allow the list to start on a new line. One way to accomplish this is to follow the theorem head (and \label, if present) by the command \leavevmode. (For more information, see section 4.3.1.) However, if the theorem comes near the bottom of a page, the list might move to the top of the next page, leaving an orphaned heading. If this happens, it must be addressed as an exception, to be taken care of after the text is final; at that point, the recommended fix is to call on the needspace [NDS] package, or insert an explicit page break.

Also:

An alternative method of starting a new line after the heading is to provide a \newtheoremstyle{break}; the definition is given below on page 9. Like the \leavevmode approach, a break theorem environment is not perfect; known limitations accompany the definition.

The aforementioned definition on "page 9" is:

This style will break after the theorem heading and start a new line.

\newtheoremstyle{break}%
{}{}%
{\itshape}{}%
{\bfseries}{}% % Note that final punctuation is omitted. 
{\newline}{}

This style can be used for a theorem beginning with a list. When used with enumerate and an AMS document class, all items are properly labeled and will link. However, the vertical spacing needs help; a conflict between definitions prevents the first item from starting on a new line—it looks almost the same as a default theorem beginning with an enumerated list. To repair this problem, begin the theorem like this:

 \begin{breakthm}[...]
 \leavevmode \vspace{-\baselineskip} 
 \begin{enumerate}

\leavevmode alone will leave a full blank line after the theorem head. One more problem may arise: if the theorem starts close to the end of a page, the list could be split to a new page, leaving an orphaned heading. Make a note to address this when the text is final; then call on the needspace [NDS] package, or insert an explicit page break.

In order to reach your goal automatically, you could try to do something like this:

 \documentclass{article}
 \usepackage{amsmath}
 \usepackage{amsthm}
 \usepackage{amssymb}

 \newtheoremstyle{exercisestyle}%                % Name
 {}%                                     % Space above
 {}%                                     % Space below
 {}%                                     % Body font
 {}%                                     % Indent amount
 {\bfseries}%                            % Theorem head font
 {}%                                     % Punctuation after theorem head
 {\newline}%                             % Space after theorem head, ' ', or \newline
{\thmname{#1}\thmnumber{ #2} --- \thmnote{#3}}%            % Theorem head spec  (can be left empty, meaning `normal')

\theoremstyle{exercisestyle}
\newtheorem{exercice}{Exercice}
\newenvironment{breakingex}[1][]{% 
\begin{exercice}[#1]\leavevmode\vspace{-\baselineskip}%
}{\end{exercice}}
\begin{document}

\begin{breakingex}[Title]
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
\end{breakingex}
\end{document}

Which yields the following result:

result

Please do mind that it's possible you will have to create some more environments like this, or to use the default setting with some overrides, in order to overcome page breaks. Refer to the amsthm and your judgement manual to achieve the best solution.

  • Thank you very much for your answer, @ilFuria ! I was aware of the \leavevmode command, but not of the elegant way to suppress the vertical space afterwards. However, the solution you propose (to add \leavevmode \vspace{-\baselineskip} at the beginning of each theorem starting with a list) is still not automatic, is it ? Is there a way to do it automatically ? to unify the cases where the theorem starts with a list and where it does not ? – user75362 Jul 17 '16 at 8:36
  • @user75362 what you can do, and I tried to do it, is create a new environment which wraps the theorem: this way you can embed the \leavevmode \vspace{-\baselineskip} in the starting definition. You still can't automate the page break management – Moriambar Jul 17 '16 at 9:05
  • Thank you, it does create several types of environments, but this is better than having to add a line at the beginning of each (breaking) theorem ! – user75362 Jul 17 '16 at 9:43
  • 1
    @JPi I think for the sake of clarity: what you are doing is simply exit the vertical mode. I honestly don't know whether there are any other reasons. I created my example using the suggestions in the amsthm manual – Moriambar Jul 17 '16 at 17:51
  • 1
    @JPi -- i discovered yesterday that if a ~ is the first thing after \begin{thm} (for any theorem object), the vertical space above the theorem object is suppressed. this is undesirable (and undocumented); and how to fix it is not obvious. that is one reason to use \leavevmode – barbara beeton Feb 16 '18 at 13:44
0

I can propose a simple solution with ntheorem: its break style does not seem to have the same problem with page breaks, so I patched it to do what you want:

\documentclass{article}
\usepackage{amsmath}
\usepackage[thmmarks, amsmath,  thref, hyperref]{ntheorem}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{lipsum}
\makeatletter
\newtheoremstyle{exobreak}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
##1\ ##2\,\textemdash\,##3 \theorem@separator}\smallskip\hbox{\strut}}}]}
\makeatother
\theorempostwork{\vskip-0.5\topsep}
\theoremstyle{exobreak}
\theoremheaderfont{\bfseries}
\theorembodyfont{\normalfont}
\theoremseparator{}
\newtheorem{exercice}{Exercice}

\begin{document}

\vspace*{33\baselineskip}
\lipsum[3]
\begin{exercice}[Title]
  \begin{enumerate}[itemsep=0pt, font =\bfseries,  wide=0pt]
    \item First item
    \item Second item
    \item Third item
  \end{enumerate}
\end{exercice}
\lipsum[4]
\begin{exercice}[Another title]
  \begin{enumerate}[itemsep=0pt, font =\bfseries,  wide=0pt]
    \item First item
    \item Second item
    \item Third item
  \end{enumerate}
\end{exercice}
\lipsum[4]

\end{document} 

enter image description here

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.