Text FormattingOverlapping Numbers in Enumerate Environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
JRTsu
Posts: 2
Joined: Tue Jul 17, 2018 10:03 pm

Overlapping Numbers in Enumerate Environment

Post by JRTsu »

Hi!

Something very peculiar is happening in a TeX document I'm typing.

The relevant packages I'm using are xcolor, mdframed, amsthm, and enumerate.

Below is a minimal working example which shows the error I'm seeing:
\documentclass{report}[12pt]

\usepackage{xcolor,mdframed,amsthm,enumerate}

\newtheorem{alg}{{\color{black}{Algorithm}}}[section]

\begin{document}

\begin{mdframed}[backgroundcolor=yellow!10,linewidth=1.5pt]
\begin{alg} {{\textbf{(Algorithm Name)}}}
\begin{enumerate}
\item First item
\item Second item
\item Third item
\end{enumerate}
\end{alg}
\end{mdframed}

\end{document}
When I compile it, the first item doesn't get a number, and the second item gets both labels 1 and 2, then the third item (and onwards) is labelled correctly.

I'm also attaching a picture of what I see.

If I remove the algorithm lines only, everything works (I just don't have my algorithm environment). If I remove just the mdframed lines only, everything works (I just don't get my box and colour). So, I can only assume there's some weird interaction between mdframed and amsthm?

I haven't tried replacing mdframed with a different boxing/colouring package, but I'd be hesitant to do so. I'm typing lecture notes, and I was planning on using the mdframed package throughout to box important theorems, etc. I particularly like mdframed because of the way it wraps between pages (something fbox, etc., doesn't seem to do). However, if there is an functionally equivalent package to mdframed, then I'd be happy to give that a try!

Any help would be greatly appreciated.

Thanks in advance,
Jonathan
Attachments
Strange.png
Strange.png (8.99 KiB) Viewed 4506 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Overlapping Numbers in Enumerate Environment

Post by Stefan Kottwitz »

Hi Jonathan,

welcome to the forum!

It works with standard theorems, without changing the syntax. Once amsthm is removed, it works fine. Maybe you can work without it? No feature of it is needed in the code example.

By the way, tcolorbox is a pretty nice and comprehensive alternative way of making boxes.

Stefan
LaTeX.org admin
JRTsu
Posts: 2
Joined: Tue Jul 17, 2018 10:03 pm

Overlapping Numbers in Enumerate Environment

Post by JRTsu »

Hi Stefan,

Wonderful! That worked perfectly -- Thanks so much!
Post Reply