Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to use enumeration in a text. It would look like in this example:

"Among pets the most common ones are (i) dogs, (ii) cats and (iii) rabbits.
(i) Dogs are very nice animals. However they need to be walked several times a day....[continuous long passage spreading over multiple lines]

(ii) Cats are often considered easier animals but....

[...] "

I guess I will not need to refer to each passage more than once, so I can also just type out the brackets and the numbers. However, just typing "(ii)" doesn't seem very nice when using LaTeX. Is there an easy and more elegant way to enumerate like in the example?

share|improve this question
3  
You need to use an environment for numbering such as enumerate. Please check this for understand it better. And please add an MWE to your questions. –  Aradnix Aug 24 at 19:45
    
@Aradnix sorry I did not see the page before - i think this provides what i am looking for. However since I do not know the code i also did not know what kind of MWE to provide...Since this seems to be quite basic I guess its better to delete the questino. –  aldorado Aug 24 at 19:49
1  
Don't be fearful, you don't have to delete anything, just be right with the conventions of the site to ask questions, and always add an MWE, check out the link I sent you before. And remember that no one was born knowing things. We always can learn. –  Aradnix Aug 24 at 19:55
    
Thanks - the link was very helpful! –  aldorado Aug 24 at 20:15
    
I hope both answers too. –  Aradnix Aug 24 at 20:17

3 Answers 3

up vote 6 down vote accepted
\documentclass{article}
\usepackage[inline]{enumitem}
\begin{document}
Among pets the most common ones are \begin{enumerate*}[label=(\roman*)]
\item dogs,\label{item:dogs}
\item cats and \label{item:cats}
\item rabbits.\label{item:rabbits}
\end{enumerate*}

\ref{item:dogs} Dogs are very nice animals. However they need to be walked several times a day\ldots [continuous long passage spreading over multiple lines]

\ref{item:cats} Cats are often considered easier animals but\ldots
\end{document}

Result using enumitem

share|improve this answer
2  
If the last word before the last is always the same, you can set it globally with itemjoin=and, which saves having to type it each time. –  Bernard Aug 24 at 20:09
    
You can use shortlabels options so that \begin{enumerate*}[(i)] is enough. –  Manuel Aug 24 at 20:55

An alternative solution with package paralist:

    \documentclass{article}
\usepackage{paralist}
    \begin{document}
    Among pets the most common ones are 
        \begin{inparaenum}[(i)]
            \item dogs, 
            \item cats and 
            \item rabbits.
        \end{inparaenum}

        \begin{enumerate}[(i)]
            \item Dogs are very nice animals. However they need to be walked several times a day\ldots [continuous long passage spreading over multiple lines]
            \item Cats are often considered easier animals but\ldots 
            \item \ldots
        \end{enumerate}
    \end{document}

Result with paralist

share|improve this answer

I would do this a bit differently. Rather than using a list environment for the first occurrences of the animal names, I would use it for the main description and use references for the initial list. One advantage of this is that TeX will issue warnings if you forget to actually say anything about any of the animals in your initial list. But mostly, this just seems to me the more natural way to do it since it is the descriptions which you really want formatted as a list.

In the following, I use enumitem to define a new list. I then define a new environment animals for the main list of descriptions, and a new command \animalref to use for the initial listing. The usual \item is redefined within the animals environment in order to accept a tag (the group of animals) which is used to automatically set a label we can reference in the definition of \animalref. The upshot of this is as follows:

  • environment animals takes one optional argument. If the optional argument is used, its contents are basically passed to enumitem's enumerate environment. You only need to worry about this if you want to change something about the list format.
  • \item[]{} within animals only takes one optional and one mandatory argument. The optional one is the usual optional argument for \item. The mandatory one is a tag such as dogs or cats.
  • \animalsref{} takes one mandatory argument. This argument is intended to correspond to the tag set for the item in the main list e.g. dogs or cats. It will typeset the relevant item label followed by the tag itself. So you'll get e.g. '(i) dogs' or '(ii) cats'. If you pass a tag which does not occur in the main list, you'll get question marks e.g. '?? rabbits' and TeX will output a warning.

This sounds a lot more complicated than it really is.

\documentclass{article}
\usepackage{enumitem, xparse, kantlipsum}
\newlist{animalslist}{enumerate}{1}
\setlist[animalslist]{label=(\roman*)}
\global\let\olditem\item
\NewDocumentCommand\animalsitem { o m }{%
  \IfNoValueTF{#1}{%
    \olditem\label{animals:#2}}{%
    \olditem[#1]\label{animals:#2}}%
  }
\newenvironment{animals}[1][]{%
  \let\item\animalsitem
  \begin{animalslist}[#1]%
  }{%
  \end{animalslist}%
}
\newcommand*\animalsref[1]{\ref{animals:#1} #1}
\begin{document}
  Among pets the most common ones are \animalsref{dogs}, \animalsref{cats} and \animalsref{rabbits}.
  \begin{animals}
    \item{dogs} Some people consider dogs very nice animals. However they need to be walked several times a day and tend to eat your shoes.

    \kant[1]

    \item{cats} Cats are nicer animals but need to be worshipped several times a day and tend to walk over your keyboard.

    \kant[2]
  \end{animals}
\end{document}

As you can see, '??' show that I've not remembered to actually say anything about rabbits, while the cats and dogs get their appropriate labels. Compile twice to stabilise the references.

cats and dogs but no rabbits

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.