The amsthm
package offers three predefined styles for the theorem-like structures: plain
(the default style), definition
and remark
; the remark
style leaves less space before and after the structure than the other two styles, as can be seen in the following example:
\documentclass{article}
\usepackage{amsthm}
\usepackage[hmargin=2cm]{geometry}% just for the example
\usepackage{lipsum}% just to generate text for the example
\newtheorem{exai}{Plain}
\theoremstyle{definition}
\newtheorem{exaii}{Definition}
\theoremstyle{remark}
\newtheorem{exaiii}{Remark}
\begin{document}
\lipsum[4]
\begin{exai}
\lipsum[4]
\end{exai}
\lipsum[4]
\begin{exaii}
\lipsum[4]
\end{exaii}
\lipsum[4]
\begin{exaiii}
\lipsum[4]
\end{exaiii}
\lipsum[4]
\end{document}
The internal lengths controlling the spacing before and after the structures are \thm@preskip
(for the space before) and \thm@postskip
(for the space after); in amsthm.sty
one finds:
\def\thm@space@setup{%
\thm@preskip=\topsep \thm@postskip=\thm@preskip
So the value of \topsep
will be used for the structures built with the plain
and definition
styles; on the other hand, for the remark
style, amsthm.sty
has:
\def\th@remark{%
\thm@headfont{\itshape}%
\normalfont % body font
\thm@preskip\topsep \divide\thm@preskip\tw@
\thm@postskip\thm@preskip
}
so, for the remark style, half the value of \topsep
will be used for the structures built with this style.
If you want to change the default value for the plain
and definition
styles, you could then use in the preamble something like
\makeatletter
\def\thm@space@setup{%
\thm@preskip=.5\topsep \thm@postskip=\thm@preskip
}
\makeatother
A complete example:
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsthm}
\makeatletter
\def\thm@space@setup{%
\thm@preskip=.5\topsep \thm@postskip=\thm@preskip
}
\makeatother
\newtheorem{example}{Exam}[section]
\begin{document}
\section{My section}
\lipsum[2] % Dummy text
\begin{example}
\lipsum[1] % Dummy text
\begin{equation}
x^2 + y^2 = 1
\end{equation}
\end{example}
\lipsum[2] % Dummy text
\end{document}
Of course, this will affect all theorem-like structures for the two styles plain
and definition
, and it will also affect the spacing after the structure, since \thm@postskip=\thm@preskip
; if you want the change only for a particular structure, you can use \newtheoremstyle
(refer to the documentation for
amsthm
) to define the settings appropriately. A little example (using a space that is too small. but it is just for example purposes):
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsthm}
\newtheoremstyle{example}% ⟨name⟩
{3pt}%⟨Space above⟩
{3pt}%⟨Space below⟩
{\itshape}%⟨Body font⟩
{}%⟨Indent amount⟩
{\bfseries}% ⟨Theorem head font⟩
{.}%⟨Punctuation after theorem head⟩
{.5em}%⟨Space after theorem head⟩2
{}%⟨Theorem head spec (can be left empty, meaning ‘normal’)⟩
\theoremstyle{example}
\newtheorem{example}{Exam}[section]
\begin{document}
\section{My section}
\lipsum[2] % Dummy text
\begin{example}
\lipsum[1] % Dummy text
\begin{equation}
x^2 + y^2 = 1
\end{equation}
\end{example}
\lipsum[2] % Dummy text
\end{document}
This class already defines the theorem environment, but amsthm
redefines some (but not all) of the internal commands used in that definition (notably \@thm
). This completely messes things up. For this reason, amsthm
cannot be loaded under siamltex.cls
. Sometimes, loading the package before the document class works. This can be done with
\RequirePackage{amsthm}
\documentclass{siamltex}
Unfortunately, the reverse problem occurs: siamltex
redefines an internal macro of amsthm
's version of the theorem
environment (\@begintheorem
) and messes it up.
The only work-around is not to use these two together. The class defines the various theorem-like environments already, as well as the proof
environment, and does so in the ways the SIAM publishers chose, so there seems to be no reason for amsthm
.
Best Answer
Use
[algorithm]
in all your\newthorem
so they use thealgorithm
counter instead ofthm
.Beware though, if you use a floating environment and a non-floating environment with the same counter the algorithm may float past the theorem so come in the wrong order.