6

I have the following list:

\begin{itemize}
    \item És associativa:$\qquad(x+y)+z=x+(y+z)$
    \item És commutativa:$\qquad x+y=y+x$
    \item Té element neutre:$\qquad\exists 0\in\K : 0+x=x+0=x$
    \item Té element invers:$\qquad\forall x\in\K\;\exists(-x)\in\K : x+(-x)=(-x)+x=0$
\end{itemize}

But I want to align that like

\begin{tabular}{ll}
    És associativa:&$\quad(x+y)+z=x+(y+z)$\\
    És commutativa:&$\quad x+y=y+x$\\
    Té element neutre:&$\quad\exists 0\in\K : 0+x=x+0=x$\\
    Té element invers:&$\quad\forall x\in\K\;\exists(-x)\in\K : x+(-x)=(-x)+x=0$\\
\end{tabular}

How can I "mix" them?

0

4 Answers 4

4

Here is a minor enhancement to this solution.

Using the array package you can define a new column type L which automatically inserts the bullet at the start of the column in which it is used:

enter image description here

Notes:

  • This could also be done with the collcell package. This commented out in the code below, but that would only make sense if there was further processing you wanted to do with the entries in the first column.

Code:

\documentclass[a5paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}  % add packages you need here ...

\usepackage{array}
\newcolumntype{L}{>{\labelitemi~~}l<{}}

%% Don't need above two lines if want to use `collcell` pacakage
%\usepackage{collcell} 
%\newcommand*{\AddBullet}[1]{\labelitemi~#1}%
%\newcolumntype{L}{>{\collectcell\AddBullet}{l}<{\endcollectcell}}

\newcommand*{\K}{\mathbf{K}}%  Not sure what \K is supposed to be

\begin{document}
\begin{tabular}{L l}
    És associativa:    & $\quad(x+y)+z=x+(y+z)$\\
    És commutativa:    & $\quad x+y=y+x$\\
    Té element neutre: & $\quad\exists 0\in\K : 0+x=x+0=x$\\
    Té element invers: & $\quad\forall x\in\K\;\exists(-x)\in\K : x+(-x)=(-x)+x=0$\\
\end{tabular}
\end{document}
2
  • Thanks, it works! But in my case the list is inside another list, so I have used \newcolumntype{L}{>{\labelitemii~~}l<{}}. Is there a way to make it recognize automatically the level of the list?
    – Oriol
    Oct 7, 2012 at 18:54
  • I don't know how to do that, but that would be a excellent separate question to ask here as it may be useful to know in situations other than this specific case. Oct 8, 2012 at 3:27
5

You can do it like this (\textbullet inserts the bullet, and you have to mark the new row with a &. To be more flexible you can use \labelitemi instead of \textbullet as Juri said in his comment):

%http://tex.stackexchange.com/questions/75717/how-can-i-mix-itemize-and-tabular-environments#comment161963_75717
\documentclass[a5paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}  % add packages you need here ...

\begin{document}
\begin{tabular}{lll}
    \labelitemi & És associativa:&$\quad(x+y)+z=x+(y+z)$\\
    \labelitemi & És commutativa:&$\quad x+y=y+x$\\
    \labelitemi & Té element neutre:&$\quad\exists 0\in\K : 0+x=x+0=x$\\
    \labelitemi & Té element invers:&$\quad\forall x\in\K\;\exists(-x)\in\K : x+(-x)=(-x)+x=0$\\
\end{tabular}
\end{document}
5
  • 1
    If you put \def\curlabelitem{\csname\csname @itemitem\endcsname\endcsname} in your preamble, you can then use \curlabelitem and it will point out to the correct thing at every place.
    – yo'
    Oct 7, 2012 at 19:11
  • @tohecz It throws errors. Must I include any package?
    – Oriol
    Oct 7, 2012 at 19:34
  • Well, you might want to use \\[\itemsep] instead of \\ to get the proper spacing.
    – yo'
    Oct 7, 2012 at 19:37
  • 1
    @Oriol oh sorry, things might be a bit more complicated. I forgot you're not in the list. It should be: \makeatletter \def\curlabelitem{\begingroup\advance\@itemdepth\@ne\csname labelitem\romannumeral\the\@itemdepth\endcsname\endgroup} \makeatother
    – yo'
    Oct 7, 2012 at 19:41
  • @tohecz Thanks, your last code works. But which is the list I'm not in? And how can I use \\[\itemsep], and what does it do?
    – Oriol
    Oct 7, 2012 at 21:46
3

There is no requirement for intermixing the two environments if you manage some of the box widths yourself. The following MWE shows an environment myitemize - based on itemize, that breaks across the page boundary and sets the width of an item (\myitemlen) if it's set at the beginning of the environment. Otherwise, it takes the natural width of each specified item.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}% http://ctan.org/pkg/inputenc
\newlength{\myitemlen}
\newcommand{\myitem}[1]{%
  \olditem\ifdim\myitemlen>0pt
      \makebox[\myitemlen][l]{#1}%
    \else
      #1%
    \fi}
\newenvironment{myitemize}
  {% \begin{myitemize}
   \begin{itemize}\let\olditem\item\let\item\myitem}
  {\end{itemize}}% \end{myitemize}
\newcommand{\K}{\mathbf{K}}
\begin{document}
\begin{myitemize}
  \item{És associativa:} $(x+y)+z=x+(y+z)$
  \item{És commutativa:} $x+y=y+x$
  \item{Té element neutre:} $\exists 0\in\K : 0+x=x+0=x$
  \item{Té element invers:} $\forall x\in\K\;\exists(-x)\in\K : x+(-x)=(-x)+x=0$
\end{myitemize}

\begin{myitemize}
  \settowidth{\myitemlen}{Té element neutre:\qquad}
  \item{És associativa:} $(x+y)+z=x+(y+z)$
  \item{És commutativa:} $x+y=y+x$
  \item{Té element neutre:} $\exists 0\in\K : 0+x=x+0=x$
  \item{Té element invers:} $\forall x\in\K\;\exists(-x)\in\K : x+(-x)=(-x)+x=0$
\end{myitemize}

\end{document}
3
  • Thanks, but if I change the texts later maybe the widest one will be another item, istead of "Té elemetn neutre:"
    – Oriol
    Oct 7, 2012 at 18:16
  • @Oriol: Exactly. And you can change that again. It would be possible to modify the environment into something different (like myitemize) so that you specify the text that is the widest every time you use it. enumitem can also be employed here. Note that a tabular will not break across the page boundary, while a regular itemize will.
    – Werner
    Oct 7, 2012 at 18:22
  • @Oriol: I've updated my answer to be a little more user-friendly. :)
    – Werner
    Oct 8, 2012 at 6:59
0

One more simple solution

\documentclass[a5paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}  % add packages you need here ...

\usepackage{array}

\newcommand*{\K}{\mathbf{K}}
\begin{document}
\begin{itemize}
  \item \parbox{3.5cm}{És associativa:}    \parbox{6cm}{$\quad(x+y)+z=x+(y+z)$}
  \item \parbox{3.5cm}{És commutativa:}    \parbox{6cm}{$\quad x+y=y+x$}
  \item \parbox{3.5cm}{Té element neutre:} \parbox{6cm}{$\quad\exists 0\in\K : 0+x=x+0=x$}
  \item \parbox{3.5cm}{Té element invers:} \parbox{7.5cm}{$\quad\forall x\in\K\;\exists(-x)\in\K : x+(-x)=(-x)+x=0$}
\end{itemize}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .