Text FormattingChange Item Labels in an enumerated List

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Change Item Labels in an enumerated List

Post by paulosousa »

Hi,

I am with some problems with the enumerate

I want
1.
2.
2.1.
2.2.
3.
instead of
1.
2.
(a)
(b)
3.

how should I do it?

Code: Select all

\documentclass[11pt, twoside, a4paper]{article}
\usepackage[portuguese]{babel}
\usepackage[applemac]{inputenc}
\usepackage[left=2.0cm,top=1.5cm,right=2.0cm,bottom=1.5cm]{geometry}
\usepackage{amsmath,amssymb,amsfonts,textcomp,setspace,graphicx,makeidx,color,fancyhdr,enumerate,environ,tikz,tabularx,enumitem}
\usepackage[bottom]{footmisc}
\pagestyle{fancy}
\setcounter{tocdepth}{3}

\renewcommand{\headrulewidth}{0pt} % retirar linha
\renewcommand{\footrulewidth}{1pt} % colocar linha

\fancyhead{}
\lfoot{\tiny Prof. Paulo Sousa}
\cfoot{\tiny Matemática A 2012/2013}
\rfoot{\tiny \thepage}

\newcounter{choice}
\renewcommand\thechoice{\Alph{choice}}
\newcommand\choicelabel{(\thechoice)}

\newenvironment{choices}%
  {\list{\choicelabel}%
     {\usecounter{choice}\def\makelabel##1{\hss\llap{##1}}%
       \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 0em}%
       \def\choice{%
         \item
       } % choice
       \labelwidth\leftmargin\advance\labelwidth-\labelsep
       \topsep=0pt
       \partopsep=2pt
     }%
  }%
  {\endlist}

\newenvironment{oneparchoices}%
  {%
    \setcounter{choice}{0}%
    \def\choice{%
      \refstepcounter{choice}%
      \ifnum\value{choice}>1\relax
        \penalty -50\hskip 7em plus 7em\relax
      \fi
      \choicelabel
      \nobreak\enskip
    }% choice
    % If we're continuing the paragraph containing the question,
    % then leave a bit of space before the first choice:
    \ifvmode\else\enskip\fi
    \ignorespaces
  }%
  {}

\NewEnviron{elaboration}{
\par
\begin{tikzpicture}
\node[rectangle,minimum width=0.2\textwidth] (m) {\begin{minipage}{0.91\textwidth}\BODY\end{minipage}};
\draw[dashed] (m.south west) rectangle (m.north east);
\end{tikzpicture}
}

\newcommand{\newfootnotemark}[1]{\addtocounter{footnote}{#1} \footnotemark[\value{footnote}]}
\newcommand{\newfootnotetext}[2]{\addtocounter{footnote}{#1} \footnotetext[\value{footnote}]{#2}}


\begin{document}

\begin{enumerate}
\item Numa cidade nasceram $5350$ meninas e $4850$ meninos, nos últimos $2$ anos. Nessa cidade, a probabilidade de nascer rapariga é de aproximadamente: \\
\begin{oneparchoices}
\choice $48\%$
\choice $50\%$
\choice $52\%$
\choice $53\%$
\end{oneparchoices}

\vspace{0.5cm}

\item Num dado país europeu sabe-se que a probabilidade de nascer menina é metade da de nascer menino. Um casal vai ter 2 filhos. 
\begin{enumerate}
\item a probabilidade de ter 2 raparigas é: \\
\begin{oneparchoices}
\choice $\dfrac{1}{3}$ 
\choice $\dfrac{2}{3}$ 
\choice $\dfrac{1}{4}$ 
\choice $\dfrac{1}{9}$
\end{oneparchoices}

\item a probabilidade de ter uma rapariga e um rapaz é: \\ 
\begin{oneparchoices}
\choice $\dfrac{2}{9}$ 
\choice $\dfrac{4}{9}$ 
\choice $\dfrac{1}{2}$ 
\choice $1$
\end{oneparchoices}
\end{enumerate}

\vspace{0.5cm}

\item Qual das seguinte expressões poderá ser um termo do desenvolvimento de $(a-b)^{18}$? \\
\begin{oneparchoices}
\choice $-816a^{16}b^2$ \hspace{1.7cm}
\choice $816a^{16}b^2$ \hspace{8.7cm}
\choice $-816a^{15}b^3$ \hspace{1.6cm}
\choice $816a^{15}b^3$
\end{oneparchoices}

\end{enumerate}
\end{document}
regards,
Paulo

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Change Item Labels in an enumerated List

Post by Stefan Kottwitz »

Hi Paulo,

you can get it with these two lines in your preamble:

Code: Select all

\renewcommand*{\theenumii}{\arabic{enumii}}
\renewcommand*{\labelenumii}{\theenumi.\theenumii.}
For the counter enumii (ii means second level) the presentation (\theenumii) and the label (\labelenumii) are redefined to be arabic and with dots instead of in parentheses, respectively.

The enumitem package provides a convenient interface for such settings, if you desire further customization of lists.

Stefan
LaTeX.org admin
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

Re: Change Item Labels in an enumerated List

Post by paulosousa »

Hi Stefan,

yes! worked! thanks a lot my friend, many many thanks

Paulo
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Change Item Labels in an enumerated List

Post by localghost »

Things would become a bit easier (and clearer) if you just used the excellent exam class.

Code: Select all

\documentclass[11pt,a4paper,portuges]{exam}
\usepackage[T1]{fontenc}
\usepackage{selinput}
\SelectInputMappings{
  aacute={á},
  otilde={õ},
  Euro={€}
}
\usepackage{babel}
\usepackage[hmargin=2cm,vmargin=1.5cm]{geometry}
\usepackage{mathtools}

\renewcommand*{\thepartno}{\thequestion.\arabic{partno}}
\renewcommand*{\partlabel}{\thepartno.}

\begin{document}
  \begin{questions}
    \question Numa cidade nasceram 5350 meninas e 4850 meninos, nos últimos $2$ anos. Nessa cidade, a probabilidade de nascer rapariga é de aproximadamente:

      \begin{oneparchoices}
        \choice 48\%
        \choice 50\%
        \choice 52\%
        \choice 53\%
      \end{oneparchoices}

    \question Num dado país europeu sabe-se que a probabilidade de nascer menina é metade da de nascer menino. Um casal vai ter 2 filhos. 
      \begin{parts}
        \part a probabilidade de ter 2 raparigas é:

          \begin{oneparchoices}
            \choice $\dfrac{1}{3}$ 
            \choice $\dfrac{2}{3}$ 
            \choice $\dfrac{1}{4}$ 
            \choice $\dfrac{1}{9}$
          \end{oneparchoices}

        \part a probabilidade de ter uma rapariga e um rapaz é:

          \begin{oneparchoices}
            \choice $\dfrac{2}{9}$ 
            \choice $\dfrac{4}{9}$ 
            \choice $\dfrac{1}{2}$ 
            \choice $1$
          \end{oneparchoices}
      \end{parts}

    \question Qual das seguinte expressões poderá ser um termo do desenvolvimento de $(a-b)^{18}$?

      \begin{oneparchoices}
        \choice $-816a^{16}b^2$
        \choice $816a^{16}b^2$
        \choice $-816a^{15}b^3$
        \choice $816a^{15}b^3$
      \end{oneparchoices}
  \end{questions}
\end{document}

Thorsten
Post Reply