multienum package within enumerate

2,221

You can change \hsize to \linewidth inside multienumerate, so the environment is aware of the current value for the line width (the package uses \textwidth by default); the representation for the counter used can be changed ny redefining \labelenumi. Another option, if your inner items are naturally balanced would be to use three columns built, for example with the multicol package. The following example shows both alternatives:

\documentclass{article}
\usepackage{enumitem}
\usepackage{multienum}
\usepackage{multicol}

\begin{document}

\noindent Using \texttt{multienum}:
\begin{enumerate}
\item 
\setlength\hsize{\linewidth}
\begin{multienumerate}
  \setcounter{enumi}{0}
  \renewcommand{\labelenumi}
  {\addtocounter{enumi}{1}\alph{enumi}.}
\mitemxxx{Not}{Linear}{Not}
\end{multienumerate}
\end{enumerate}

\noindent Using \texttt{multicol}:
\begin{enumerate}
\item \begin{multicols}{3}
\begin{enumerate}
\item Not 
\item Linear
\item Not
\end{enumerate}
\end{multicols}
\end{enumerate}

\end{document}

enter image description here

Perhaps the best option is to use the enumerate* environment from the enumitem package with the inline package option and to control the spacing between items using \hfill:

\documentclass{article}
\usepackage[inline]{enumitem}

\begin{document}

\noindent With \texttt{enumitem}:
\begin{enumerate}
\item 
\begin{enumerate*}[itemjoin=\hfill]
\item Not
\item Linear
\item Not
\end{enumerate*}
\end{enumerate}

\end{document}

enter image description here

With the edit to the original question, a better option seems to be the use of a tabularx environment (from the tabularx package) of width equal to \linewidth and with automatic cell numbering:

\documentclass{article}
\usepackage{array}
\usepackage{tabularx}

\newcounter{row}
\renewcommand\therow{\alph{row}}

\begin{document}


\begin{enumerate}
\item
\begin{tabularx}{\linewidth}[t]{*{3}{>{\stepcounter{row}\makebox[1.8em][l]{(\therow)\hfill}}X}}
part 1 & part 2 & part 3\\
part 4 & part 5 & part 6\\
\end{tabularx}
\item
\setcounter{row}{0}
\begin{tabularx}{\linewidth}[t]{*{3}{>{\stepcounter{row}\makebox[1.8em][l]{(\therow)\hfill}}X}}
part 1 & part 2 & part 3\\
part 4 & part 5 & part 6\\
\end{tabularx}
\end{enumerate}

\end{document}

enter image description here

And, of course, if this structure is to be used several times, you can define a new environment to simplify the writting:

\documentclass{article}
\usepackage{array}
\usepackage{tabularx}

\newcounter{row}
\renewcommand\therow{\alph{row}}

\newenvironment{rowenum}
  {\setcounter{row}{0}%
    \par\noindent\tabularx{\linewidth}[t]
    {*{3}{>{\stepcounter{row}\makebox[1.8em][l]{(\therow)\hfill}}X}}%
  }
  {\endtabularx}

\begin{document}

\begin{enumerate}
\item Question 1 preamble
\begin{rowenum}
part 1 & part 2 & part 3 \\
part 4 & part 5 & part 6 \\
\end{rowenum}
\item Question 2 preamble
\begin{rowenum}
part 1 & part 2 & part 3 \\
part 4 & part 5 & part 6 \\
\end{rowenum}
\end{enumerate}

\end{document}

enter image description here

Share:
2,221

Related videos on Youtube

richtera
Author by

richtera

Updated on August 01, 2022

Comments

  • richtera
    richtera over 1 year

    Is it possible to use the multienum package within the enumerate environment? The following code does not display correctly (the last column moves to the next line):

    \begin{enumerate}
    \item \begin{multienumerate}
    \mitemxxx{Not1}{Linear1}{Not1}
    \mitemxxx{Not2}{Linear2}{Not2} 
    \end{multienumerate}
    \end{enumerate} 
    

    Also, if this is possible, how could I change the numbering? Since multienumerate is nested within the enumerate environment, I would like to have each item tagged with alph characters (a,b,c...). If this is not possible, could someone please suggest an alternative approach.

    Ideally, what I would like to create is the following:
    1. Question 1 Preamble
    (a) part a (b) part b (c) part c
    (d) part d (e) part e (f) part f
    2. Question 2 Preamble
    (a) part a (b) part b (c) part c
    (d) part d (e) part e (f) part f

    where parts a-c and d-f span the linewidth and the labels are vertically aligned.

    • richtera
      richtera over 11 years
      Perhaps the shortlst or multicol package could be good alternatives. Thoughts?
    • richtera
      richtera over 11 years
      The problem with the shortlst package is that the horizontal and vertical spacing does not look good. The problem with the multicols package is that the numbering is vertical instead of horizontal.
  • richtera
    richtera over 11 years
    If there is more than one row, multicols numbers vertically. How can I change it so that it numbers horizontally?
  • richtera
    richtera over 11 years
    If I use multienumerate, how can I change the labels to alph characters? Also, is there a way to make the \hsize property change global to avoid having to add that line every time I call the environment?
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera please see my updated answer; the last option (the one using only enumitem) is the best option.
  • richtera
    richtera over 11 years
    In the last example, if you add a second row, the labels do not line up.
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera please state your full requirements clearly in your question. In your question, as it is now, you only require three in-line items; now, apparently you need something different.
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera please see the code of my updated answer.
  • richtera
    richtera over 11 years
    Thanks. Is it possible to horizontally number using multicol?
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera no, I don't think it's possible.
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera I updated my answer with a simplified version using a newly defined environment.
  • richtera
    richtera over 11 years
    Great. What does the X at the end of the part in braces do?
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera X is the main column format specifier offered by the tabularx package. It is equivalent to a p{<length>} column, once the appropriate length has been internally calculated.
  • richtera
    richtera over 11 years
    Is there a way to adjust the distance between the rows?
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera well, of course. You can, for example, say \renewcommand\arraystretch{1.3} (use an appropriate value) right after \setcounter{row}{0} in the definition of the rowenum environment (this will affect all the rows), or you can use \\[1em] (use the appropriate value) inside the tabular body for individual rows.
  • richtera
    richtera over 11 years
    I should be more specific. With the multicol environment, the vertical distance between the rows naturally adjusts depending on the contents of each "cell". Using the tabularx package, of course it no longer automatically does this. Is it possible to create a naturual buffer between the rows depending on the cell contents using your method?
  • Gonzalo Medina
    Gonzalo Medina over 11 years
    @richtera sorry, but I don't understand; perhaps you should open a new question as a follow-up to this one?