Featured Book

LaTeX Beginners Guide

Who is online

In total there are 8 users online :: 0 registered, 0 hidden and 8 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 8 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Adding horizontal rules between list items

Add tags Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)

Adding horizontal rules between list items

Postby 4fingers on Fri Feb 19th, 2010

Hi,

I have the following list:
Code: Select all  •  Open in writeLaTeX
\documentclass[12]{article}

\newenvironment{questions}{
        \begin{list}{*}{}
}{
        \end{list}
}

\newenvironment{question}{\item}{}

\begin{document}
Hello world
\begin{questions}

\begin{question}Item one\end{question}
\begin{question}Item two\end{question}
\begin{question}Item three\end{question}

\end{questions}
\end{document
}


What I would like to do is add a horzontal rule above and below each list item. I tried placing the rule between each list item but that results in an error:
Code: Select all  •  Open in writeLaTeX
\rule{\textwidth}{1mm}
\begin{question}Item one\end{question}
\rule{\textwidth}{1mm}
\begin{question}Item two\end{question}
\rule{\textwidth}{1mm}
\begin{question}Item three\end{question}
\rule{\textwidth}{1mm
}


I can't place the rule in the actual body of the list item as the rule is not placed above the label:
Code: Select all  •  Open in writeLaTeX
\rule{\textwidth}{1mm}
\begin{question}\rule{\textwidth}{1mm}
Item one\end{question}
\begin{question}\rule{\textwidth}{1mm}
Item two\end{question}
\begin{question}\rule{\textwidth}{1mm}
Item three
\rule{\textwidth}{1mm}\end{question
}


Does anyone have any ideas how this could be achieved?
Thanks
4fingers
 
Posts: 12
Joined: Fri Jul 3rd, 2009

Re: Adding horizontal rules between list items

Postby magicmoose on Fri Feb 19th, 2010

How is this code?
Code: Select all  •  Open in writeLaTeX
    \documentclass{article}

    \newenvironment{question}{\noindent\rule{\textwidth}{1mm}\begin{list}{*}{}\item}{\end{list}}

                \newenvironment{questions}{}{\rule{\textwidth}{1mm}}

    \begin{document}
    Hello world
 
                \begin{questions}
    \begin{question}Item one\end{question}
    \begin{question}Item two\end{question}
    \begin{question}Item three\end{question}
                \end{questions}

    \end{document
}


edit: fixed code ;)
magicmoose
 
Posts: 90
Joined: Fri Nov 6th, 2009

Re: Adding horizontal rules between list items

Postby 4fingers on Fri Feb 19th, 2010

Thanks for your help; I have successfully managed to apply horizontal rules between list items in my PDFs.
4fingers
 
Posts: 12
Joined: Fri Jul 3rd, 2009


Return to Text Formatting

Who is online

Users browsing this forum: No registered users and 8 guests