LaTeX forum ⇒ Text FormattingAdding horizontal rules between list items

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
4fingers
Posts: 12
Joined: Fri Jul 03, 2009 11:57 am

Adding horizontal rules between list items

Postby 4fingers » Fri Feb 19, 2010 2:30 am

Hi,

I have the following list:
  1. \documentclass[12]{article}
  2.  
  3. \newenvironment{questions}{
  4. \begin{list}{*}{}
  5. }{
  6. \end{list}
  7. }
  8.  
  9. \newenvironment{question}{\item}{}
  10.  
  11. \begin{document}
  12. Hello world
  13. \begin{questions}
  14.  
  15. \begin{question}Item one\end{question}
  16. \begin{question}Item two\end{question}
  17. \begin{question}Item three\end{question}
  18.  
  19. \end{questions}
  20. \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:
  1. \rule{\textwidth}{1mm}
  2. \begin{question}Item one\end{question}
  3. \rule{\textwidth}{1mm}
  4. \begin{question}Item two\end{question}
  5. \rule{\textwidth}{1mm}
  6. \begin{question}Item three\end{question}
  7. \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:
  1. \rule{\textwidth}{1mm}
  2. \begin{question}\rule{\textwidth}{1mm}
  3. Item one\end{question}
  4. \begin{question}\rule{\textwidth}{1mm}
  5. Item two\end{question}
  6. \begin{question}\rule{\textwidth}{1mm}
  7. Item three
  8. \rule{\textwidth}{1mm}\end{question}


Does anyone have any ideas how this could be achieved?
Thanks

Link:
BBcode:
HTML:
Hide post links
Show post links

magicmoose
Posts: 90
Joined: Fri Nov 06, 2009 7:29 am

Postby magicmoose » Fri Feb 19, 2010 4:08 am

How is this code?
  1. \documentclass{article}
  2.  
  3. \newenvironment{question}{\noindent\rule{\textwidth}{1mm}\begin{list}{*}{}\item}{\end{list}}
  4.  
  5. \newenvironment{questions}{}{\rule{\textwidth}{1mm}}
  6.  
  7. \begin{document}
  8. Hello world
  9.  
  10. \begin{questions}
  11. \begin{question}Item one\end{question}
  12. \begin{question}Item two\end{question}
  13. \begin{question}Item three\end{question}
  14. \end{questions}
  15.  
  16. \end{document}


edit: fixed code ;)

Link:
BBcode:
HTML:
Hide post links
Show post links

4fingers
Posts: 12
Joined: Fri Jul 03, 2009 11:57 am

Postby 4fingers » Fri Feb 19, 2010 1:50 pm

Thanks for your help; I have successfully managed to apply horizontal rules between list items in my PDFs.

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 3 guests