How can I specify which column each \item goes into? For example, I want column 1 to contain everything except the last 2 \items and column 2 to contain the last 2 \items. (I did not include all the data in this post)

How can I format this data into three columns and specify which column they shall be placed in?

Perhaps the approach you are suggesting right now it's not the best one (specially if there's no particular order for the items of each column); perhaps you could use three side-by-side minipages and place one enumearte environment in each one of the minipages?
–
Gonzalo MedinaOct 7 '12 at 19:13

I think it would be helpful if you provided some example as I am not clear on what you are trying to accomplish. If you could show what you want instead of describing it that would probably greatly clarify things.
–
Peter GrillOct 7 '12 at 19:29

Was my answer below of any help, or did I totally misunderstand the question?
–
Peter GrillNov 1 '12 at 7:02

1 Answer
1

It seems that this is another case (see References below for the earlier case) where the most important thing to figure out really is exactly how do you want to specify which items you want printed. So, here is one way where you can specify which rows of the data end up in each of the columns.

Define the enumerated list in a macro so that it can be reused. In this you call \MyItem{} and pass in the parameter as the data:

This is part of the definition of the macro \MyEnumeratedList which has some initialization before this list.

Now wherever you want to use this enumerated list, you simply specify which rows you actually want printed. So if you only want rows 2, 5 and 7 to be printed, you say:

\MyEnumeratedList{2,5,7}

Any row not specified in this list is not printed.

So, with the data provided, I have printed the rows as specified in the question. Column 3 was not specified so I chose rows 2, 5, and 7 for that column:

Notes:

I assumed that the list was to be numbered consecutively from 1 for each of the columns. If this is not desired using another counter to number then would preserve the numbering of the items across the three columns.

I used three minipages to display the three columns, as suggested by Gonzalo Medina in the comments. The multicols approach is not the way to achieve the desired result.

There is an assumption here that at least one row will be printed in each column. Otherwise you will end up with the error message:

LaTeX Error: Something's wrong--perhaps a missing \item.

This could occur if you provide much larger numbers than the total number of rows.

Further Enchantments:

Handle the case where none of the rows are printed.

Provide for greater flexibility in how the rows are to be printed. For example a better way to have specified the first column in the example provided would have been:

References:

So for these type of questions it would be helpful if the person asking the question considered first: How do I want to specify what I want?

Code:

\documentclass{article}
\usepackage{xstring}
\newcounter{RowCounter}
\newcommand*{\ListOfRowsToDisplay}{}%
\newcommand*{\MyItem}[1]{%
% #1 = comma separated list of which rows to show
% #2 = item data
\stepcounter{RowCounter}%
% Add extra commas on what we are searching for and what we are searching in.
% Hence, to check if the number (for example), six is in the string we
% search for ",6,". This will prevent the returning of a false positive
% when the number 6 is not in the sting, but the digit 6 is used as part of a
% number. Say the search string is "23,25,26,27", now searching for ",6,"
% will result in not found, but searching for "6" would have resulted in the
% string being found.
\StrPosition{\ListOfRowsToDisplay}{,\arabic{RowCounter},}[\PositionInString]
\IfEq{\PositionInString}{0}{%
% This row number is not to be printed and we keep movin on
}{%
% This is a row that needs to be printed
\item #1
}%
}%
\newcommand*{\MyEnumeratedList}[1]{%
% #1 = comma separated list of which rows to show
\setcounter{RowCounter}{0}% reset as we are starting over
% Save the list of rows globally so to make the enumerated list easier to read
\xdef\ListOfRowsToDisplay{,#1,}%
\begin{enumerate}%
\MyItem{(1)(2)(3)}
\MyItem{(1,2)(3)}
\MyItem{(1,3)(2)}
\MyItem{(2,3)(1)}
\MyItem{(1, 2, 3)}
\MyItem{(1, 3, 2)}
\MyItem{(1)(2)(3)(4)}
\MyItem{(1,3)(2)(4)}
\end{enumerate}%
}%
\begin{document}
\begin{minipage}{0.30\linewidth}%
\MyEnumeratedList{1,2,3,4,5,6}
\end{minipage}%
\begin{minipage}{0.30\linewidth}%
\MyEnumeratedList{7,8}
\end{minipage}%
\begin{minipage}{0.30\linewidth}%
\MyEnumeratedList{2,5,7}
\end{minipage}%
\end{document}