LaTeX users online

In total there are 4 users online :: 1 registered, 0 hidden and 3 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: Google [Bot] and 3 guests

Adding horizontal rules between list items

LaTeX Forum: Text Formatting

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

Postby 4fingers on Fri Feb 19th, 2010

Hi,

I have the following list:
Code: Select all  •  Open in online LaTeX editor
\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 online LaTeX editor
\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 online LaTeX editor
\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

Postby magicmoose on Fri Feb 19th, 2010

How is this code?
Code: Select all  •  Open in online LaTeX editor
    \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

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

LaTeX users online

Users browsing this forum: Google [Bot] and 3 guests