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.

How do I get horizontal spaces to the left and right of theorems? My initial idea was to do the following bad idea:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{amsthm}% http://ctan.org/pkg/amsthm

\newtheoremstyle{newplain}  % name of the style to be used
  {}                        % measure of space to leave above the theorem
  {}                        % measure of space to leave below the theorem
  {\addtolength{\leftskip}{2em}\addtolength{\rightskip}{2em}% this is probably bad!!!
   \itshape}                % commands on body of the theorem
  {}                        % measure of space to indent (empty = no indent, \parindent = para indent)
  {\bfseries}               % name of head font
  {.}                       % punctuation between head and body
  {5pt plus 1pt minus 1pt}  % space after theorem head
  {}                        % Manually specify head

\theoremstyle{newplain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]

\begin{document}

\lipsum[1]

\begin{lemma}
The Lemma says
\begin{equation}
y=mx+c.
\end{equation}
\end{lemma}

\lipsum[2]

\begin{theorem}[Wigner-Eckart theorem]
The Matrix elements of a tensor operator can be rewritten as
\begin{equation}
y=(\partial_x y)x+c.
\end{equation}
This equation does not does not have the correct formatting that was defined above.
\end{theorem}

\lipsum[3]

\end{document}
share|improve this question
1  
what doesn't this do that you want to be done? it's not a great idea to reuse the name \theoremstyle{plain}, but to my surprise, there was no complaint, and the theorem text is indented on both sides as requested. if it's the position of the equation number you want indented, that's a different kettle of fish. –  barbara beeton Apr 12 '13 at 14:37
    
@barbarabeeton: I read the package amsthm and saw what it does such that I understood what I was doing by redefining the style. Of course, it is always better to give the new style a new name. My problem was that the position of the equations number was uaffected by my command. cmhughes' solution below corrects that. –  strpeter Apr 13 '13 at 8:41
add comment

1 Answer

up vote 3 down vote accepted

Here's a solution that uses the etoolbox to wrap the changepage's adjustwidth environment around your theorem environment.

The important parts are:

\BeforeBeginEnvironment{theorem}{\begin{adjustwidth}{2cm}{2cm}}
\AfterEndEnvironment{theorem}{\endadjustwidth}

You can obviously change the 2cm as you see fit.

screenshot

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{amsthm}% http://ctan.org/pkg/amsthm
\usepackage{etoolbox}
\usepackage{changepage}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]  % numbered by the sections number

\BeforeBeginEnvironment{theorem}{\begin{adjustwidth}{2cm}{2cm}}
\AfterEndEnvironment{theorem}{\endadjustwidth}

\begin{document}
\lipsum[1]
\begin{theorem}[Wigner-Eckart theorem]
    The Matrix elements of a tensor operator $T_{q}^{(1)}$ can be rewritten as
    \begin{equation}
        y=mx+c
    \end{equation}
\end{theorem}
\lipsum[2]
\end{document}
share|improve this answer
    
Do you have an idea how to define it for all theorem, lemma, corollary, etc. at once? –  strpeter Apr 13 '13 at 18:02
    
@strpeter as far as I know (I may be wrong), amsthm does not have that capability (ntheorem does). You'll just need to copy the BeforeBeginEnvironment and AfterEndEnvironment code for each in your preamble –  cmhughes Apr 13 '13 at 18:16
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.