5

--Revised--

I am looking at a math workbook for teenagers. This one has the following structure:

1.Main Chapter

1.1 Subchapter

1.11 Task 1

a) problem 1 b) problem 2 c) problem 3

d) problem 4 e) problem 5

1.12 Task 2

etc. ...

Many of the math problems are very small and the natural thing would be to have them on line, horizontally. However an expression is often broken and aligned at the equal sign. Not unlike an equation (but not). Secondly, when the line that contain the structure breaks, the item indicators also align, presuming the use of an enumerated list.

How can I reasonably assume this is done? Does it have to be a forced method, as a table, or can it be a flexible one, like inline?

Lars
  • 173

1 Answers1

4

With the shortlst package you are nearly safe. In this case you would write:

Solve the following equations for $x$.
\begin{shortenumerate}
  \item $2(x+2)=20$
  \item $4-4x=12$
  \item $x+5x-6=12$
  \item $4x-4x+3x=18$
  \item $3x=12$
\end{shortenumerate}

This will give the following output:

workbook_1

As the picture shows, it is necessary to check for the width of the single tasks to really have a clean and consistent solution. This (and a tiny patch for the alphanumeric labels) is accomplished automatically by the WorkbookTasks environment defined in the following code. Of course, the tasks are indexable, as you requested in the comments.

\documentclass{book}
\usepackage{shortlst}
\usepackage{makeidx}
  \makeindex

\makeatletter
\newdimen\wb@task@maxdimen \wb@task@maxdimen0pt
\newtoks\wb@task@items
\def\Task{\begingroup\catcode`\^^M=12 \Task@}
\bgroup\catcode`\^^M=12 %
  \gdef\Task@#1^^M{%
    \settowidth\@tempdima{#1}%
    \ifdim\@tempdima>\wb@task@maxdimen%
      \global\wb@task@maxdimen\the\@tempdima\fi%
      \global\wb@task@items=\expandafter{\the\wb@task@items \item #1}%
    \endgroup}%
\egroup
\let\leftbracket=[
\def\WorkbookTasks{\futurelet\next\WorkbookTasks@}
\def\WorkbookTasks@{%
  \ifx\next\leftbracket
    \expandafter\WorkbookTasks@@
  \else
    \expandafter\WorkbookTasks@@@
  \fi}
\def\WorkbookTasks@@[#1]{%
  \xdef\wb@ex@text{#1}
  \WorkbookTasks@@@}
\def\WorkbookTasks@@@{%
  \def\labelenumi{\@alph\c@enumi)}}
\def\endWorkbookTasks{%
  \par \noindent\wb@ex@text
  \begin{shortenumerate}[\hbox to \the\wb@task@maxdimen{\hfil}]
    \the\wb@task@items
  \end{shortenumerate}
  \global\wb@task@maxdimen0pt
  \global\wb@task@items={}
  \global\let\wb@ex@text\@empty
  \par}%
\makeatother

\begin{document} 

\chapter{Main chapter}
\section{Subchapter}
\subsection{Task 1}

Solve the following equations for $x$.
\begin{shortenumerate}
  \item $2(x+2)=20$
  \item $4-4x=12$
  \item $x+5x-6=12$
  \item $4x-4x+3x=18$
  \item $3x=12$
\end{shortenumerate}

\subsection{Task 2}

\begin{WorkbookTasks}[Solve the following equations for $x$.]
  \Task $2(x+2)=20$
  \Task $4-4x=12$
  \Task $x+5x-6=12$    \index{Special exercise (that needs to appear in the index)}
  \Task $4x-4x+3x=18$
  \Task $3x=12$
\end{WorkbookTasks}

\subsection{Task 3}

\begin{WorkbookTasks}[Solve the following equations for $y$.]
  \Task $2y=10$
  \Task $4(y+2y)=12$
  \Task $3y=1$
  \Task $y+1=1$
  \Task $y-2=0$
\end{WorkbookTasks}

\printindex
\end{document}

workbook_2

Ruben
  • 13,448