TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question
    
If enumitem package is an option, then you can tweak the answer in tex.stackexchange.com/questions/46665/… to your liking – hpesoj626 Jan 6 '13 at 14:14
up vote 9 down vote accepted

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

share|improve this answer
    
That's cleverer than mine :) – clemens 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

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

share|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/… – mrc Oct 22 '15 at 15:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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