16

Consider the following minimal example:

\documentclass{article}

\setlength{\parindent}{0mm}

\usepackage{paralist}
\usepackage{tabto}

\begin{document}

\NumTabs{3}
\begin{inparaenum}
\item text
\tab\item text
\tab\item text
\tab\item text
\tab\item text
\tab\item text   
\end{inparaenum}

\end{document}

Which results in:

image

It does exactly what I want, but I was wondering whether it was possible to create an environment, say tabbedEnum so that we can eliminate the use of the \tab, in particular, that the first case doesn't need a tab but all others do. Something of the form:

\begin{tabbedEnum}[3]
\item text
\item text
\item text
\item text
\item text
\item text
\end{tabbedEnum}
11

Just redefine \item to do what you want, but after the first use:

\documentclass{article}

\setlength{\parindent}{0mm}

\usepackage{paralist}
\usepackage{tabto}

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

\begin{document}

\begin{tabbedenum}{3}
\item text
\item text
\item text
\item text
\item text
\item text
\end{tabbedenum}

\bigskip

\NumTabs{3}
\begin{inparaenum}
\item text
\tab\item text
\tab\item text
\tab\item text
\tab\item text
\tab\item text   
\end{inparaenum}

\end{document}

Since we are using the original \item command at the end, you can also use the optional argument after \item.

enter image description here

|improve this answer|||||
  • That's cleverer than mine :) – cgnieder Jan 6 '13 at 16:10
  • That's a very elegant solution! – Geoff Jan 6 '13 at 16:12
  • @cgnieder Minimalism. :) – egreg Jan 6 '13 at 16:12
  • How to add package enumerate inside like this 1) tex 2) Tex 3) Tex ... – minthao_2011 Jun 5 '13 at 1:26
9

Well, you can define your own environment that uses some \inner@tab that redefines itself on first use to call \tab and redefines \item to call \inner@tab before it issues the real \item:

\documentclass{article}

\usepackage{paralist}
\usepackage{tabto}
\usepackage{etoolbox}

\makeatletter
\newenvironment{tabbedEnum}[1][3]{%
  \ifblank{#1}{\NumTabs{3}}{\NumTabs{#1}}%
  \inparaenum
    \let\orig@item\item
    \def\inner@tab{\let\inner@tab\tab}%
    \renewcommand\item[1][]{%
      \inner@tab\ifblank{##1}{\orig@item}{\orig@item[##1]}}%
    \ignorespaces
}{%
  \endinparaenum
}
\makeatother

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\noindent
\begin{tabbedEnum}
 \item text
 \item text
 \item text
 \item text
 \item text
 \item text
\end{tabbedEnum}

\lipsum[2]

\end{document}

enter image description here

As an alternative you could use exsheets' {tasks} environment. It does not look exactly the same, though. Anyway, here it is:

\documentclass{article}
\usepackage{exsheets}

% \NewTasks[options]{name}[separator](default number of columns)
% all arguments except {name} are optional
\NewTasks[label=tsk.]{tabbedEnum}[\item](3)

\usepackage{lipsum}% for dummy text

\begin{document}

\lipsum[1]

\begin{tabbedEnum}
 \item text
 \item text
 \item text
 \item text
 \item text
 \item text
\end{tabbedEnum}

\lipsum[2]

\end{document}

enter image description here

|improve this answer|||||
  • I really like the tasks environment from exsheets! Note that it is now available as a standalone package, tasks. Thanks for pointing this out, it also solved an old problem of mine for formatting worksheets: tex.stackexchange.com/questions/133330/… – Chris Chudzicki Oct 22 '15 at 15:21
  • when I copy-paste your MWE for the second solution (using exsheets), I get an array, but it's not enumerated, it just says "tsktext tsktext tsktext" etc. Any ideas? Literal copy-paste, so I'm at a loss. – Rax Adaam Apr 10 '18 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.