LaTeX forum ⇒ Text FormattingFormatting enumerate environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
ian22
Posts: 3
Joined: Fri Feb 12, 2010 3:40 am

Formatting enumerate environment

Postby ian22 » Fri Feb 12, 2010 3:49 am

Hi,
I am trying to write a letter report for work in Latex. The formatting standard doesn't look great, but I'm stuck with it. On the first page of the letter report I need something like:

Underlined Letter Subject
References: A. ASTM E8M – 00, Standard Test Methods for Tension Testing of Metallic Materials
B. A second reference. Second line does not have hanging indent.
C. Another reference.

It basically has to look like this - no space between any of these lines, no hanging indent, and "References:" immediately before the first one.

I tried using the list and enumerate environments, but couldn't control the spaces while enumerating with capital letters. I want to refer to the references (rarely more than five in these types of reports) with proper cross-references, so I need something I can label that will give something sensible when I write "Reference~\ref{ASTME8}", or something of that sort. I have tried the enumerate and enumitem packages, but find they were conflicting somewhat. I'd appreciate any suggestions. Thanks,

Ian

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Sat Feb 13, 2010 2:15 am

Hi,

in code below I used the enumitem package to define two new environments: (smylist and emylist) which are in fact variations on the standard enumerate environment. The first environment should be used to produce only the first item of the list; the second environment should be used to produce the remaining items.

To cross-reference the items, you can use the standard \label, \ref mechanism.

Take a look at the example:

  1. \documentclass{book}
  2. \usepackage{enumitem}
  3.  
  4. \newenvironment{smylist}
  5. {\par\noindent References:%
  6. \vspace*{-\baselineskip}%
  7. \begin{enumerate}[itemindent=1.9cm,nolistsep,align=left,leftmargin=*,
  8. labelsep=3pt,label=\Alph*.]}
  9. {\end{enumerate}}
  10. \newenvironment{emylist}
  11. {\begin{enumerate}[nolistsep,label=\Alph*.,align=left,leftmargin=*,labelsep=3pt]
  12. \stepcounter{enumi}}
  13. {\end{enumerate}}
  14.  
  15. \begin{document}
  16.  
  17. text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
  18. \begin{smylist}
  19. \item\label{ite:a} First item.
  20. \end{smylist}
  21. \begin{emylist}
  22. \item\label{ite:c} Second item.
  23. \item\label{ite:b} Third item.
  24. \end{emylist}
  25.  
  26. As we can see in \ref{ite:b}, \ref{ite:c}, and \ref{ite:a}...
  27.  
  28. \end{document}


Feel free to adapt my example according to your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...

ian22
Posts: 3
Joined: Fri Feb 12, 2010 3:40 am

Postby ian22 » Sat Feb 13, 2010 3:30 am

Thanks, that works great, but I have three problems with it. The first is that if I don't include \parskip=\baselineskip, I have no space between paragraphs, which doesn't look very good. When I include this line, there are vertical spaces between "References:" and "A." and between the A entry and B entry.

The second is that there is a hanging indent if the item entry is more than one line. Which length controls this?

The third is that Reference~\ref{ref to item A} will output "Reference A." Is there a way to omit the period? It is out of place in the middle of a sentence.

Thanks for your help. This has gotten me a lot closer to what I need.

Ian

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Sat Feb 13, 2010 5:23 am

ian22 wrote:...The first is that if I don't include \parskip=\baselineskip, I have no space between paragraphs, which doesn't look very good...


To increase the vertical separation between paragraphs use one of the commands \bigskip, \medskip or \smallskip. Do not change \parskip as this could affect other parts of your document in an undesired way. The example below shows the use of \bigskip; of course, now the paragraph indentation is superfluous so I suppressed it with

  1. \setlength\parindent{0pt}


ian22 wrote:...The second is that there is a hanging indent if the item entry is more than one line. Which length controls this?...


The documentation for enumitem explains the horizontal lengths involved in a list-like environment. My example code includes the necessary modifications.

ian22 wrote:...The third is that Reference~\ref{ref to item A} will output "Reference A." Is there a way to omit the period? It is out of place in the middle of a sentence...


Again, the documentation contains the answer. All you have to do is to use the ref key in the format declaration of the list. See my example below.

  1. \documentclass{book}
  2. \usepackage{enumitem}
  3.  
  4. \newenvironment{smylist}
  5. {\par\noindent References:%
  6. \vspace*{-\baselineskip}%
  7. \begin{enumerate}[nolistsep,label=\Alph*.,ref=\Alph{enumi},
  8. leftmargin=0pt,labelsep=15pt,align=left,
  9. labelwidth=-0.5cm,itemindent=1.9cm]}
  10. {\end{enumerate}}
  11. \newenvironment{emylist}
  12. {\begin{enumerate}[nolistsep,label=\Alph*.,ref=\Alph{enumi},
  13. leftmargin=0pt,labelsep=0pt,align=left,
  14. labelwidth=17pt,itemindent=16pt]
  15. \stepcounter{enumi}}
  16. {\end{enumerate}}
  17.  
  18. \setlength\parindent{0pt}
  19.  
  20. \begin{document}
  21.  
  22. paragraph one text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text\bigskip
  23.  
  24. paragraph two text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text\bigskip
  25.  
  26. \begin{smylist}
  27. \item\label{ite:a} First item text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
  28. \end{smylist}
  29. \begin{emylist}
  30. \item\label{ite:c} Second item text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
  31. \item\label{ite:b} Third item.
  32. \end{emylist}\bigskip
  33.  
  34. As we can see in \ref{ite:b}, \ref{ite:c}, and \ref{ite:a}
  35.  
  36. \end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...

ian22
Posts: 3
Joined: Fri Feb 12, 2010 3:40 am

Postby ian22 » Wed Feb 17, 2010 9:26 pm

That works great; thank a lot.

ian


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 1 guest