Take the 2-minute tour ×
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.

In the following screenshot, I would like the 1st item A) in the inline mode to be at the same level of indentation of the labels A) to D) in the first list.

To do that I would like to know how the enumitem package places the labels.

enter image description here

Here is the code that I've used.

\documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{enumitem}

    \newlist{choices}{enumerate}{1}
    \setlist[choices]{label*=\Alph*)}
    \newcommand{\choice}{\item}

    \newcounter{choice}
    \renewcommand\thechoice{\Alph{choice}}
    \newcommand\choicelabel{\thechoice)}
    \newcommand\choicestarlabel{{\large $\square$}}

    \newenvironment{inlineChoices}{%
        \setcounter{choice}{0}%
            \def\choice{%
            \refstepcounter{choice}%
            \ifnum\value{choice}>1\relax
                \penalty -50\hskip 1em plus 1em\relax
            \else
                \hspace{\labelindent}% WRONG SPACING !!!
            \fi
            \choicelabel
            \nobreak\enskip
        }%
        \ifvmode\else\enskip\fi
        \ignorespaces
    }{}

\begin{document}

\noindent Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla

\begin{choices}
    \choice $\dfrac{4}{7}$
    \choice $\dfrac{8}{24}$
    \choice $\dfrac{44}{121}$
    \choice $\dfrac{9}{11}$
\end{choices}

\noindent Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla

\begin{inlineChoices}
    \choice $\dfrac{4}{7}$
    \choice $\dfrac{8}{24}$
    \choice $\dfrac{44}{121}$
    \choice $\dfrac{9}{11}$
\end{inlineChoices}

\end{document}
share|improve this question
1  
Not a solution to the spacing problem, but you should use the [inline] option for your inline list and define them with \newlist{inlinechoices}{enumerate*}{1} and \setlist[inlinechoices]{label*=\Alph*)}. Then you don't need your inlineChoices environment. –  Alan Munn Mar 4 '12 at 16:45
    
Thanks for this suggestion but it doesn't work... –  projetmbc Mar 4 '12 at 17:05
    
I'm not sure what you mean about it not working. I've added an example in case others would like to do this. –  Alan Munn Mar 4 '12 at 17:21
add comment

2 Answers 2

Using the [inline] option of enumitem makes doing this sort of list simpler. Since these lists are designed to be used in running text, you would need to wrap them in some sort of environment to deal with the spacing issues; I've ignored this in my example, however. I've made the between item separation (itemjoin) \qquad. You can change this as needed. Based on your comments, I've also used the parskip package for setting a zero parindent. Then I've used leftmargin=* and align=left for the regular choices list to make the labels align properly.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[inline]{enumitem}
\usepackage{parskip} % for zero par indent the right way

\newlist{choices}{enumerate}{1}
\newlist{inlinechoices}{enumerate*}{1}
\setlist[inlinechoices]{label*={\Alph*)},itemjoin={\qquad}}
\setlist[choices]{label*={\Alph*)},leftmargin=*,align=left}
\newcommand{\choice}{\item}


\newcounter{choice}
\renewcommand\thechoice{\Alph{choice}}
\newcommand\choicelabel{\thechoice)}
\newcommand\choicestarlabel{{\large $\square$}}


\begin{document}

 Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla

\begin{choices}
    \choice $\dfrac{4}{7}$
    \choice $\dfrac{8}{24}$\label{824}
    \choice $\dfrac{44}{121}$
    \choice $\dfrac{9}{11}$
\end{choices}

 Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla As in \ref{824}
\bigskip

\begin{inlinechoices}
    \choice $\dfrac{4}{7}$
    \choice $\dfrac{8}{24}$
    \choice $\dfrac{44}{121}$\label{44}
    \choice $\dfrac{9}{11}$
\end{inlinechoices}
\bigskip

\noindent Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla As in \ref{44}

\end{document}

output of code

share|improve this answer
    
Your simpler solution for the inline list has one drawback : the spacing between consecutive items is too smal. Is the a way to fix this ? "If yes", I'll definitely use the inline mode of enumitem. –  projetmbc Mar 4 '12 at 17:28
    
Yes, with the itemjoin parameter. I've updated my answer. –  Alan Munn Mar 4 '12 at 17:42
    
Arghhh... I use \setlength\parindent{0mm} which destroys the good spacing for the inline list. How can I repair it ? –  projetmbc Mar 4 '12 at 18:19
1  
It's probably best to use the parskip package for a 0 parskip. I've updated my answer again. But now maybe is the time to read the enumitem documentation to see what options you have for setting the margins. If you want the lists indented relative to the text, you will need to (i) adjust the leftmargin of the choices list, and (ii) wrap the inlinechoices in an environment that indents it an appropriate amount. –  Alan Munn Mar 4 '12 at 18:32
    
Nearly done... Sorry but is it possible to keep indentation for the lists ? You can kill me... :-) –  projetmbc Mar 4 '12 at 18:34
show 2 more comments

Your inline list gets the spacing you are giving it and the normal paragraph indentation, the code below ensures it starts with \noindent if at the start of a paragraph and then gets what I think is the right indentation, depending on the space you want between items.

    \newenvironment{inlineChoices}{%
\ifvmode\noindent\fi
\hspace*{\leftmargini}%
\hspace*{-\labelwidth}%
        \setcounter{choice}{0}%
            \def\choice{%
            \refstepcounter{choice}%
            \ifnum\value{choice}>1\relax
                \penalty -50\hskip 1em plus 1em\relax
            \else
\hspace*{\itemindent}%
            \fi
            \choicelabel
            \nobreak\enskip
        }%
        \ifvmode\else\enskip\fi
        \ignorespaces
    }{}
share|improve this answer
    
Thanks a lot for the explications and the correction of the code. –  projetmbc Mar 4 '12 at 17:13
add comment

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.