Text FormattingGray box around enumerate item ?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Gray box around enumerate item ?

Post by Cham »

I would like to add a thin black frame, filled with a light gray color, all around the text in an enumerate environment. How ?

Here's a minimal working example to work with :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{graphicx}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{gray192}{RGB}{192,192,192}
\usepackage{enumitem}

\begin{document}
Some text here, about anything :
\medskip
	\begin{enumerate}[leftmargin=0.5in,rightmargin=0.5in]
		\item More text, just to see what happens.  Bla bla bla bla Bla bla bla bla, bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.
	\end{enumerate}
\medskip
Bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla :
\medskip
	\begin{enumerate}[leftmargin=0.5in,rightmargin=0.5in,resume]
		\item Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.
	\end{enumerate}
\medskip
Bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla.
\end{document}
The box should be larger than the text inside it (including the item number), but smaller than the normal text above and under it. I have absolutely no clue about how to do this.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Gray box around enumerate item ?

Post by Cham »

Ok, I've found the mdframed package which should do the trick. I'll have to play a lot with it, since there are lots of options.

I'm currently unable to display the footnotes, however :cry: .

EDIT : What are the other solutions ? I'm experiencing troubles with mdframed margins around enumerate environments and also with footnotes declared inside any mdframed environment.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Gray box around enumerate item ?

Post by Cham »

Here's what I get, with the mdframed package. There are three problems :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{graphicx}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{gray230}{RGB}{230,230,230}
\usepackage{enumitem}
\usepackage{mdframed}

\begin{document}

Some text here, about anything :
\medskip
	\begin{mdframed}[leftmargin=0.0in,rightmargin=0.0in,backgroundcolor=gray230]
	\begin{enumerate}[leftmargin=0.5in,rightmargin=0.5in]
		\item More text, just to see what happens.  Bla bla bla bla Bla bla bla bla, bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla\footnote{Testing footnote, which isn't displayed at the proper place (bottom of page).}.
	\end{enumerate}
	\end{mdframed}
\medskip
	\begin{enumerate}[leftmargin=0.5in,rightmargin=0.5in,resume]
		\item More text, just to see what happens.  Bla bla bla bla Bla bla bla bla, bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla\footnote{Testing footnote, this one is displayed.}.
	\end{enumerate}
Bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla :
\medskip
	\begin{mdframed}[backgroundcolor=gray230]
	\begin{enumerate}[leftmargin=0.5in,rightmargin=0.5in,resume]
		\item Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.
	\end{enumerate}
	\end{mdframed}
\medskip
Bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla, bla bla bla bla bla bla bla bla bla bla bla bla.

\end{document}
As you can see after the compilation, the first footnote isn't displayed at the bottom of page. It should be placed at the bottom of the page, like the second footnote. On my computer, I don't even get the footnote at all (not even displayed inside the gray box). I'm using pdfLaTeX on OS X.

The enumerate item number appears to be broken. They should be updated for all three items (#1, 2 and 3).

Also, the first enumerate item should have exactly the same size (margins) as the second one (without a gray box around it).

How can I fix these ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Gray box around enumerate item ?

Post by Cham »

Any suggestions on the previous query? I'm still puzzled with this.
Post Reply