Text FormattingVertical or horizontal rules around enumerate items ?

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

Vertical or horizontal rules around enumerate items ?

Post by Cham »

Is there a way to draw a vertical line on each side of the items in an enumerate list (with equations embeded) ?

See for example this minimal working example :

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{amsmath}
\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\footnote{Testing footnote 1.} :
	\begin{equation*}
		x \cdot y = z^2.
	\end{equation*}
        \end{enumerate}
\medskip
Another line of text, just to see what happens :
        \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 2.}.
        \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 :

\end{document}
Preview :
pict1.jpg
pict1.jpg (60.15 KiB) Viewed 8966 times
I would like to add lines like these :
pict2.jpg
pict2.jpg (61.1 KiB) Viewed 8966 times
Or what about horizontal lines above and under each item ?

Is that possible ?

I tried the framed and mdframed packages, but they apparently have problems with footnotes, and broken items numbers.
Last edited by Cham on Tue Oct 29, 2013 4:49 pm, edited 2 times in total.

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

Vertical or horizontal rules around enumerate items ?

Post by Cham »

Here's an hack which adds horizontal lines above and under an item. But what should be the proper way to do this ? Currently, the last rule vertical spacing isn't right :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[total={6in,10in},left=1.6in,top=0.4in,includehead,includefoot]{geometry}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage[dvipsnames,table]{xcolor}

\begin{document}

Some text here, about anything :
	\begin{center}\textcolor{gray}{\rule{5in}{1.6pt}\vspace{-25pt}}\end{center}
	\begin{center}\textcolor{gray}{\rule{5in}{0.4pt}\vspace{-12pt}}\end{center}
	\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 1.} :
	\begin{equation*}
		x \cdot y = z^2.
	\end{equation*}
        \end{enumerate}
	\vspace{-12pt}
	\begin{center}\textcolor{gray}{\rule{5in}{0.4pt}\vspace{-24pt}}\end{center}
	\begin{center}\textcolor{gray}{\rule{5in}{1.6pt}}\end{center}
Another line of text, just to see what happens :

\end{document}
Here's a preview of the previous code :
pict0.jpg
pict0.jpg (33.23 KiB) Viewed 8945 times
Currently, the vertical spacing of the horizontal lines is very approximate.
Last edited by Cham on Tue Oct 29, 2013 3:48 pm, edited 1 time in total.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Vertical or horizontal rules around enumerate items ?

Post by Cham »

The following code may be better than the previous one (added "before" and "after" directives in the enumitem options). However, I don't think that the vspace directives are right, since the spacing was done approximately from the eye.

Code: Select all

\documentclass[12pt]{book}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage[dvipsnames,table]{xcolor}

\begin{document}

Some text here, about anything :
	\begin{enumerate}[leftmargin=0.5in,rightmargin=0.5in,before=\begin{center}\textcolor{gray}{\rule{5in}{1.6pt}\vspace{-24pt}}\end{center}\begin{center}\textcolor{gray}{\rule{5in}{0.4pt}\vspace{-12pt}}\end{center},after=\begin{center}\vspace{-12pt}\textcolor{gray}{\rule{5in}{0.4pt}}\end{center}\begin{center}\vspace{-28pt}\textcolor{gray}{\rule{5in}{1.6pt}}\end{center}]
                \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 1.} :
	\begin{equation*}
		x \cdot y = z^2.
	\end{equation*}
        \end{enumerate}
Another line of text, just to see what happens :
\end{document}
What should be the proper way of doing this ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Vertical or horizontal rules around enumerate items ?

Post by Cham »

The previous code doesn't work well : the rules vertical spacing is changing, depending on which page I place the enumerate item.

How can I draw two rules with an absolute (i.e. invariable) vertical spacing, above and under the enumerate item ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Vertical or horizontal rules around enumerate items ?

Post by Cham »

No suggestions about the previous query ?

Should I conclude that it's not possible (or very difficult) to add these lines around the enumerate items in LaTeX ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Vertical or horizontal rules around enumerate items ?

Post by Cham »

Still no suggestions ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Vertical or horizontal rules around enumerate items ?

Post by Cham »

I'm still trying to define the horizontal rules above and under the enumerate items, but I'm experiencing the variable horizontal spacement. Nobody has a suggestion ?
Post Reply