[Tex/LaTex] Add second enumeration item on the same line


I'm writing a document that has a large number of lists containing short enumeration items, and I'd like to be able to [manually] put multiple items on one line. Thus, for example, I'd like to say

    \item Goes on first line.
    \samelineitem Also goes on first line.
    \item Goes on second line.

I'm quite happy with making the one line/two lines decision myself (in fact, I'd prefer it), so all I'm looking for is a macro that will determine the current enum counter, do the right thing regarding horizontal spacing, and print the item. It would be nice if this would work with enumerate, description, and itemize lists (or with general lists). (For a description list, I guess something like \samelineitem[newlabel] Text of item).

Is there a package with such a capability, or would anyone out there like to tell me how to do it? Thanks.

Best Answer

Here's a general solution using the enumitem package. What you want produces some strange looking lists, so I'm not sure I would recommend using it. It works for all three types of lists. The enumitem package also implements inline lists for all of the three list types. I've added an example here to show that too.

For enumerate and itemize lists, any label argument is ignored and therefore you should not use an arbitrarily specified label with those sorts of list.

% This command ignores the optional argument for itemize and enumerate lists

% Pure inline list
This is an inline list.

    \item First item.
    \item Second item.
    \item Third item.
    \item Fourth item.


% Combined inline list
This is a combined inline enumerated list.
    \item First item \inlineitem Second item\inlineitem Third item.
    \item Fourth item
    \item Fifth item


% Works with itemize
This is a combined inline itemized list.
    \item First item \inlineitem Second item \inlineitem Third item. 
    \item Fourth item
    \item Fifth item

% Works with description lists
This is a combined inline description list.
    \item[Foo] First item \inlineitem[Bar]Second item\inlineitem[FooBar] Third item.
    \item[Bar] Fourth item
    \item[Foo] Fifth item

% Showing that it can be embedded and works with modified labels
The new command works with arbitrary labels and embedding.
        \item First item\inlineitem Second item \inlineitem Third item. 
        \item Fourth item
        \item Fifth item

output of code

Related Question