[Tex/LaTex] Enumeration with several items per line, several lines and nicely formatted

#enumerateenumitemformattinglists

Based on Alan's answer here, I would like to be able to create nicely formatted "inline" enumerated lists.

The issue I have is that the space between items on a line is always fixed, which does not look nice. I'm looking for a way to level out the spacing across lines. Any suggestion and help how to achieve something good looking would be appreaciated. Maybe I should not be using a enumeration environment? The lists in question are either just bullet points or a)-d).

\documentclass[12pt]{article}
\usepackage[inline]{enumitem}
\makeatletter
% This command ignores the optional argument for itemize and enumerate lists
\newcommand{\inlineitem}[1][]{%
\ifnum\enit@type=\tw@
    {\descriptionlabel{#1}}
  \hspace{\labelsep}
\else
  \ifnum\enit@type=\z@
       \refstepcounter{\@listctr}\fi
    \quad\@itemlabel\hspace{\labelsep}
\fi}
\makeatother

\begin{document}

% Combined inline list
\noindent This is a combined inline enumerated list.
\begin{itemize}
\item Less than 5 years \inlineitem Between 5 and 10 years
\item More than 10 years \inlineitem Do not know
\end{itemize}

\bigskip

\noindent Another list.
\begin{itemize}
\item £850
\inlineitem £1,000
\inlineitem £1,150
\inlineitem £1,500
\inlineitem Do not know
\end{itemize}

\bigskip

\noindent And the final one
\begin{enumerate}[label=(\alph*)]
\item Agree strongly \inlineitem Tend to agree \inlineitem Neither agree nor disagree
\item Tend to disagree \inlineitem Disagree strongly \inlineitem Don't know
\end{enumerate}

\end{document}

enter image description here

Best Answer

Here's a possible solution if you know how many items you want on each line. Your MWE does suggest that's OK.

\documentclass{article}

\newcounter{myitemcounter}

\newcommand{\myitemlabel}{$\bullet$\ }

\newcommand{\myitem}{%
\stepcounter{myitemcounter}
\myitemlabel
}

\newcommand{\anitem}[1]{%
\myitem #1 &
}

\newcommand{\lastitem}[1]{%
\myitem #1 \\
}

\newenvironment{inlineitemize}
{\setcounter{myitemcounter}{0}
\begin{tabular}{llllllllll} % you won't want more columns
}
{\end{tabular}}

\newenvironment{inlineenumerate}
{\setcounter{myitemcounter}{0}
\renewcommand{\myitemlabel}{(\alph{myitemcounter})\ }
\begin{tabular}{lllllllllll}
}
{\end{tabular}}

\begin{document}

\begin{inlineenumerate}
 \anitem{Agree strongly}
 \anitem{Tend to agree}
 \lastitem{Neither agree nor disagree}
 \anitem {Tend to disagree}
 \anitem{Disagree strongly}
 \lastitem{Don't know}
\end{inlineenumerate}

\begin{inlineitemize}
\anitem{Less than 5 years} \lastitem{Between 5 and 10 years} 
\anitem{More than 10 years} \lastitem{Do not know}
\end{inlineitemize}

\end{document}

enter image description here

With a little more work you could pass an integer argument to the new environments to specify the number of columns in order to automate the time to invoke lastitem instead of anitem. You can also set the interline spacing in the tabular environments to match your MWE.

Related Question