1

I´m sorry my English mistakes. I would like to align items using tasks or enumerate (or both) to get better experience for me. I have been using the first one a long time, but unfortunately it does not aligning horizontally like tasks. And I don´t know to produce new items in tasks like enumerate.

enter image description here

Here is a MWE.

\documentclass[a4paper, 12pt]{report}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb, ifthen,amsthm}
\usepackage{babel}
\usepackage[latin1]{inputenc}
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\usepackage{tasks}
\usepackage[margin=1.5cm ]{geometry}

\DeclareInstance{tasks}{alphabetize-parents}{default}{ label-format=\itshape }

\settasks{style=alphabetize-parents} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\pagestyle{myheadings} \thispagestyle{empty}

\noindent Consider

\begin{multicols}{2} \begin{enumerate}[$(a)$, leftmargin=3.2em] \item $f(x) = \begin{cases} \dfrac{1}{x^2}, \mbox{if} \ x\neq 0 \ 0, \mbox{if} \ x= 0. \end{cases}$ \item $ f(x) = \sqrt[3]{x^2}$ \end{enumerate} \end{multicols} \begin{tasks}(2) \task $f(x) = \begin{cases} \dfrac{1}{x^2}, \mbox{if} \ x\neq 0 \ 0, \mbox{if} \ x= 0. \end{cases}$ \task $ f(x) = \sqrt[3]{x^2}$ \end{tasks}

\end{document}

CarLaTeX
  • 62,716
Moura
  • 1,555
  • 2
    There is an entire section (Section 6) in the manual for tasks on how to assign custom labels. I think if you just pass label=(\alph*) it should work. – Willie Wong May 17 '21 at 02:43
  • Have you tried the \begin{align} ... \end{align} environment of the amsmath package ? Probably embedding equations inside enumerate, which is again nested inside multicols might not be a good idea (though I'm not sure why) ! – Partha D. May 17 '21 at 03:33
  • I didn´t try it before. – Moura May 17 '21 at 18:00
  • @WillieWong thanks, this is almost what I would like, but the symbol ( is in italic. – Moura May 17 '21 at 18:03

2 Answers2

2

Does this server your purpose ?

Image

I intentionally changed f(x) to f(x, y) in the second line, to ensure that expressions with unequal widths align perfectly !

\documentclass[a4paper, fleqn, 12pt]{report}
\usepackage[margin=1.5cm]{geometry}
\usepackage{mathpazo, amsmath}

\begin{document}

\pagestyle{myheadings} \thispagestyle{empty}

\noindent Consider \begin{alignat}{4} &(a); &f(x) &= \begin{cases} \dfrac{1}{x^2}, &\text{if } x \neq 0 \ 0, &\text{if } x = 0. \end{cases} \qquad\qquad &&(b); &f(x) &= \sqrt[3]{x^2} \[1em] &(a); &f(x, y) &= \begin{cases} \dfrac{1}{xy}, &\text{if } x,y \neq 0 \ 0, &\text{if } x,y = 0. \end{cases} \qquad\qquad &&(b); &f(x,y) &= \sqrt[3]{xy}
\end{alignat
}

\end{document}

Also note:

  1. the fleqn in the documentclass option-- that aligns the equations to the left. Omitting that would center your equations;
  2. how a gap is forced after the if in text, with \text{if }-- though it might also have been done with \text{if}\; (but the former is more readable in my opinion);
  3. you may get to know more about the alignat environment in answers to @Giovanni's question. Double && and single & aligning characters are a bit tricky-- but works wonderfully once mastered.

The downside of this solution

You'll have to put the item numbers manually, rather than internally generating them with \items inside the enumerate environment. But that too, can be done with a suitable macro defined on some newcounter, I suppose !

Partha D.
  • 2,250
  • I really appreciated your help. But I have some exercices having 10 or more itens. Thans again – Moura May 17 '21 at 18:07
2

I highly encourage reading the package manual.

If you want upright parentheses paired with italic letters in the item label, try

\documentclass{article}
\usepackage{amsmath}
\usepackage{tasks}

\begin{document} \begin{tasks}label=\normalfont({\itshape\alph}),ref=(\alph),label-width=2em \task \label{task1} $f(x) = \begin{cases} \dfrac{1}{x^2}, \mbox{if} \ x\neq 0 \ 0, \mbox{if} \ x= 0. \end{cases}$ \task $ f(x) = \sqrt[3]{x^2}$ \end{tasks}

\ref{task1} \end{document}

I assume that if you are cross referencing and want to point to a particular item, you would want the item label to match the local font specification. (So if the running text is italics, it will show the label in italics. If the running text is upright, it will show the label as upright.) If you want a different appearance, change the argument to the ref key.

The addition of label-width=2em is because the default width allocated to labels is too narrow to fit (a). You can adjust it to your needs.

Willie Wong
  • 24,733
  • 8
  • 74
  • 106
  • I'm really so glad for your help. I couldn't understand the manual. I have read at least 3 times the package manual. Thank you. – Moura May 18 '21 at 22:21