# How to keep number order with distinct environments?

in trying to make an enumeration like the following, when you can make a problem, but next, you can make a list of problems, i've been using them separately with the enumerate package, and with the tasks package for the horizontal enumerating, but how can i combine both and keep an order for the problems?

I was thinking maybe with the use of a counter, but im not quite sure how i would implement it on the enumerate and task environment, any help would be appreciated, thanks in advance.

## 2 Answers

A solution with tasks, using the resume key. For items spanning the remaining columns in a row, use the \task* command. For items spanning all columns, use \tasks!:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{amsmath}

\usepackage{tasks}
\settasks{counter-format =tsk[1]., label-format=\bfseries, label-offset=1em, label-width = 0.67em, item-indent = 1.67em, before-skip =0.5ex}

\begin{document}

\begin{tasks}(3)
\task* In section 1.1 we guessed solutions to the exponential growth model $d\mkern1.5mu P/d\mkern1.5mu t = k P$, where $k$ is a constant (see page 6). Using the fact that this equation is separable, derive these solutions by separating variables.\medskip
\end{tasks}
In Exercises 5–24, find the general solution of the differential equation specified. (You may not be able to reach the ideal answer of an equation with only the dependent variable on the left and only the independent variable on the right, but get as far as you can.)

\begin{tasks}[resume](3)
\task $\dfrac{dy}{dt} = ty^2$
\task $\dfrac{dy}{dt} = t^4y$
\task $\dfrac{dy}{dt} = 2y + 1$
\task $\dfrac{dy}{dt} = 2-y$
\task $\dfrac{dy}{dt} = e^{-y}$
\task $\dfrac{dy}{dt} = 1 + x^2$
\end{tasks}

\end{document}


• Very nice! Much simpler than my answer!
– user121799
Commented Mar 8, 2018 at 3:54

UPDATE: I realized that my original answer had the flaw that one could not reference the numbers of the items. This is fixed in the following proposal, which is based on this answer.

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

\makeatletter
\def\zinparaenum{%
\ifnum\@enumdepth>\thr@@
\@toodeep
\else
\advance\@enumdepth\@ne
\edef\@enumctr{enum\romannumeral\the\@enumdepth}%
\fi
\@ifnextchar[{\@enumlabel@{\@zinparaenum@}[}{\@zinparaenum@}}
\def\@zinparaenum@{%
\usecounter{\@enumctr}%
\@namedef{p@\@enumctr}{}%
\def\@itemlabel{\csname label\@enumctr\endcsname}%
\let\@item\pl@item
\def\makelabel##1{##1}%
\ignorespaces\setcounter{enumi}{\value{problems}}}
\def\endzinparaenum{\setcounter{problems}{\value{enumi}}\ignorespacesafterend}
\makeatother

\begin{document}

\NumTabs{1}
\begin{zinparaenum}[\bf 1.]
\noindent\item How many marmots live in the Alps?
\end{zinparaenum}

\medskip

In problems \ref{first}--\ref{last} solve the differential equation\dots\\
\NumTabs{3}
\begin{zinparaenum}[\bf 1.]
\item text\label{first}
\tab\item text
\tab\item text
\tab\item text
\tab\item text
\tab\item text   \label{last}
\end{zinparaenum}

\end{document}


This is probably even closer to what you want. (I also made the numbers boldface.) In the best of all worlds, I could combine the two answers in such a way that you do not have to type the \tabs, but it seems like we do not live in the best of all worlds.

ORIGINAL ANSWER: Here is a proposal based on this answer.

\documentclass{article}

\setlength{\parindent}{0mm}

\usepackage{paralist}
\usepackage{tabto}
\newcounter{problems}

\newenvironment{tabbedenum}[1]
{\NumTabs{#1}\inparaenum\let\latexitem\item
\setcounter{enumi}{\theproblems}
\def\item{\def\item{\tab\latexitem}\latexitem}}
{\setcounter{problems}{\theenumi}\endinparaenum}

\begin{document}
\begin{tabbedenum}{1}
\item How many marmots live in Switzerland?
\end{tabbedenum}

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

\end{document}