9

This is a follow up question to the one I asked a while back: Horizontal enumeration in multiple columns .

There I was using paralist and now I feel it is better to switch to enumitem (since I can use the resume option). The environment tabbedenum using paralist worked perfectly for my needs, but transferring this to Tabbedenum based on enumitem no longer works.

Could this be because of the star (i.e. if \enumerate is short for \begin{enumerate} then what works for \begin{enumerate}*)? That's why I tried by defining the environment Inparaenum.

Could the problem be based on the optional options? In fact, could Tabbedenum be defined with the optional options too, so that the syntax would be: \begin{Tabbedenum}[label=\emph{\alph*})]{3}?

Below is a MWE.

\documentclass{article}
\usepackage{tabto}
\usepackage{paralist}

\newenvironment{tabbedenum}[1]
 {\NumTabs{#1}\inparaenum\let\latexitem\item
  \def\item{\def\item{\tab\latexitem}\latexitem}}
 {\endinparaenum}

\usepackage[inline]{enumitem}
\newenvironment{Inparaenum}{\begin{enumerate*}[label=\emph{\alph*})]}{\end{enumerate*}}

\newenvironment{Tabbedenum}[1]
 {\NumTabs{#1}\Inparaenum\let\latexitem\item
  \def\item{\def\item{\tab\latexitem}\latexitem}}
 {\endInparaenum}

\begin{document}

\begin{tabbedenum}{3}
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\end{tabbedenum}

\begin{Tabbedenum}{3}
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\end{Tabbedenum}

\end{document}

1 Answer 1

10

This is actually a lot simpler with enumitem. Essentially you can just use the itemjoin option to produce the tabbing:

Sample output

\documentclass{article}
\usepackage{tabto}

\usepackage[inline]{enumitem}

\newenvironment{Tabbedenum}[1]
 {\NumTabs{#1}\begin{enumerate*}[label=\emph{\alph*}),itemjoin={\tab}]}{\end{enumerate*}}

\begin{document}

\begin{Tabbedenum}{3}
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\end{Tabbedenum}

\end{document}

If you also want the first item placed at a tab stop then you can add before={\tab}:

Second sample

\documentclass{article}
\usepackage{tabto}

\usepackage[inline]{enumitem}

\newenvironment{Tabbedenum}[1]
{\NumTabs{#1}\begin{enumerate*}[label=\emph{\alph*}),
before={\tab},itemjoin={\tab}]}{\end{enumerate*}}

\begin{document}

\noindent
My items:
\begin{Tabbedenum}{3}
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\end{Tabbedenum}

\end{document}

If there is no text before the list you will have to back up to hit the first tab stop, e.g. by issuing

\noindent\hspace{-10pt}

before the list or setting

before={\unskip\hspace{\dimexpr-\parindent-1pt}\tab}

You can pass optional arguments to such contstructs as in the following code. Note that because of the grouping, resume needs to be combined with series to work.

\documentclass{article}
\usepackage{tabto}

\usepackage[inline]{enumitem}

\newenvironment{Tabbedenum}[2][]
{\NumTabs{#2}\begin{enumerate*}[label=\emph{\alph*}),
before={\unskip\hspace{\dimexpr-\parindent-1pt}\tab},itemjoin={\tab},#1]}%
{\end{enumerate*}}

\begin{document}

\begin{Tabbedenum}[series=test]{3}
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\end{Tabbedenum}

\begin{Tabbedenum}[resume=test]{4}
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\item hello world
\end{Tabbedenum}

\end{document}

Sample resume

4
  • This is great. I tried to pass some optional arguments as follows: \newenvironment{Tabbedenum}[2][label=\emph{\alph*}] {\NumTabs{#2}\begin{enumerate*}[ before={\unskip\hspace{\dimexpr-\parindent-1pt}\tab},itemjoin={\tab},#1]}{\end{enumerate*}} but this gives errors, which disappear when I remove the \unskip. Can this be circumvented? Do I need the \unskip?
    – Geoff
    Commented Jul 2, 2013 at 12:50
  • Just to add, I tried to optionally include resume but that didn't work.
    – Geoff
    Commented Jul 2, 2013 at 12:53
  • I have now added code to show how to cope with optional arguments. The \unskip is not giving me errors, but could be removed without affecting the given examples. Commented Jul 2, 2013 at 13:14
  • Your last solution works and even with the \unskip there are no errors. Many thanks for your effort!
    – Geoff
    Commented Jul 2, 2013 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .