Text Formatting ⇒ theorem right after \item
theorem right after \item
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
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
theorem right after \item
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}
Re: theorem right after \item
\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
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.
Re: theorem right after \item
Jan