Hi,
I am using amsthm package, and I need to put a theorem right after \item, but this does not seem to work nicely. E.g. writing
\begin{itemize}
\item[(a)]
\begin{theorem}[Topkis]
some text here...
\end{theorem}
\item[(b)] some text here...
\end{itemize}
will leave an empty line after (a) and Topkis' theorem goes only in the second line. Is there some easy way to prevent this?
Thanks!
Jan
Text Formatting ⇒ theorem right after \item
theorem right after \item
Hi,
in the following example code I defined a command (\myvspace) that corrects the vertical position:
Notice that I also used the enumitem package to automate the change in the numbering of the enumerate environment. Of course, feel free to adapt my example according to your needs.
in the following example code I defined a command (\myvspace) that corrects the vertical position:
Code: Select all
\documentclass{report}
\usepackage{enumitem}
\usepackage{amsthm}
%calculation of the length needed to correct the vertical position
\newlength{\mylen}
\addtolength{\mylen}{\baselineskip}
\addtolength{\mylen}{8pt}
%definition of the command
\newcommand\myvspace{\rule{0pt}{1pt}\vspace*{-\mylen}}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{enumerate}[label=(\alph*)]
\item \myvspace
\begin{theorem}[Topkis]
some text here...
\end{theorem}
\item some text here...
\end{enumerate}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: theorem right after \item
Great, so I guess that if I have 1.13 line spacing I should change this to
\addtolength{\mylen}{1.13\baselineskip}
And one more thing, I also use anysize package with
\marginsize{2.75cm}{2.75cm}{2.5cm}{2.5cm}
How should I change \addtolength{\mylen}{8pt} ? Where do those 8pt come from?
Thanks, I never really had to use any of these weird commands like \newlength so I'm quite confused
Jan
\addtolength{\mylen}{1.13\baselineskip}
And one more thing, I also use anysize package with
\marginsize{2.75cm}{2.75cm}{2.5cm}{2.5cm}
How should I change \addtolength{\mylen}{8pt} ? Where do those 8pt come from?
Thanks, I never really had to use any of these weird commands like \newlength so I'm quite confused

Jan
theorem right after \item
Hi,
A brief explanation of what are those lined doing:
The idea is to store the length \baselineskip+\topsep to be able to use it in the enumerate environment. The first line creates a new length (\mylen); by default a newly created length has a length of 0pt. In the second line, the value of \baselineskip is added to \mylen, so that now \mylen has the value 0pt+\baselineskip=\baselineskip. The third line adds he value of \topsep to \mylen, so now \mylen has the desired value: \baselineskip+\topsep.
The use of the anysize package does not force any modifications to the three lines of code that I just wrote. By the way, anysize is an obsolete package; you should use geometry or typearea instead.
The theorem environment leaves an extra vertical space between the theorem itself and the surrounding text. This ammount of space is controlled by the rubber length \topsep (whose value is 8.0pt plus 2.0pt minus 4.0pt). In your case, the vertical space that was causing the problem is the sum of the normal vertical separation between two text lines (\baselineskip) and the extra vertical space from \topset. Therefore you must move up the text of the theorem in the amount \baselineskip+\topsep ; in my example code I used \baselineskip+8pt since I didn't remembered at that time the precise length (\topsep) that was responsible for those extra 8pt. So instead of 8pt is preferable to use \topsep as injduras wrote:...
And one more thing, I also use anysize package with
\marginsize{2.75cm}{2.75cm}{2.5cm}{2.5cm}
How should I change \addtolength{\mylen}{8pt} ? Where do those 8pt come from?
...
Code: Select all
\newlength{\mylen}
\addtolength{\mylen}{\baselineskip}
\addtolength{\mylen}{\topsep}
The idea is to store the length \baselineskip+\topsep to be able to use it in the enumerate environment. The first line creates a new length (\mylen); by default a newly created length has a length of 0pt. In the second line, the value of \baselineskip is added to \mylen, so that now \mylen has the value 0pt+\baselineskip=\baselineskip. The third line adds he value of \topsep to \mylen, so now \mylen has the desired value: \baselineskip+\topsep.
The use of the anysize package does not force any modifications to the three lines of code that I just wrote. By the way, anysize is an obsolete package; you should use geometry or typearea instead.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: theorem right after \item
Sweet, thanks for the explanation. \topsep really works much better, 8pt was fine in most cases, but in a couple of places it did not work completely.
Jan
Jan