[Tex/LaTex] Split itemize into multiple columns

columnsitemizemulticol

Is it possible to split an itemize list into several columns? (I'm sure it is, but I couldn't find a solution around here)

And additionally: Is it possible to automatically split a list into multiple columns if it reaches a certain item length?

so i want to display

item1
item2
item3

instead of

item1   item2   item3

while this should still happen

item1   item4
item2   item5
item3   item6

Best Answer

Here is some code that does the automatic column adjust thing, I used the code found in "count and use the number of items in advance" to help me.

\documentclass{article}
\usepackage{etoolbox,refcount}
\usepackage{multicol}

\newcounter{countitems}
\newcounter{nextitemizecount}
\newcommand{\setupcountitems}{%
  \stepcounter{nextitemizecount}%
  \setcounter{countitems}{0}%
  \preto\item{\stepcounter{countitems}}%
}
\makeatletter
\newcommand{\computecountitems}{%
  \edef\@currentlabel{\number\c@countitems}%
  \label{countitems@\number\numexpr\value{nextitemizecount}-1\relax}%
}
\newcommand{\nextitemizecount}{%
  \getrefnumber{countitems@\number\c@nextitemizecount}%
}
\newcommand{\previtemizecount}{%
  \getrefnumber{countitems@\number\numexpr\value{nextitemizecount}-1\relax}%
}
\makeatother    
\newenvironment{AutoMultiColItemize}{%
\ifnumcomp{\nextitemizecount}{>}{3}{\begin{multicols}{2}}{}%
\setupcountitems\begin{itemize}}%
{\end{itemize}%
\unskip\computecountitems\ifnumcomp{\previtemizecount}{>}{3}{\end{multicols}}{}}

\begin{document}

\begin{itemize}
    \item Here are two columns
  \begin{AutoMultiColItemize}
  \item Item 1
  \item Item 2
  \item Item 3
  \item Item 4
  \item Item 5
  \item Item 6
  \end{AutoMultiColItemize}
  \item AutoMultiColItemize can be nested in an itemize
  \item Or it does not have to be.
  \item Normal itemize, like this one, are still single column.
\end{itemize}
Here is one column
\begin{AutoMultiColItemize}
\item Item 1
\item Item 2
\item Item 3
\end{AutoMultiColItemize}

\end{document}

Here is what it looks like: Multiple Columns