3

I want to use a multirow item list in a column of a table, but it does not work. it says an \item is missing but it already ended before.

\documentclass[a4paper,10pt]{article}

\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{lastpage}
\usepackage[utf8]{inputenc}
\usepackage{array,multirow}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{setspace}
\usepackage[table]{xcolor}
%definir a fonte a utilizar
\usepackage{times}
\renewcommand{\familydefault}{\sfdefault}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\vspace{0.5cm}
\noindent
\tabulinesep=1.5ex
\begin{tabu} to \linewidth {|X[m,c]|X[m,c]|X[m,c]}
\cline{0-1}
Autorizado & & \multirow{2}{*}{
    \begin{description}
        \item[First] The first item
        \item[Second] The second item
        \item[Third] The third etc \ldots
    \end{description}
}\\\cline{0-1}
Não Autorizado & \\\cline{0-1}
\end{tabu}

\end{document}`

UPDATE I have done it using a box, but now i have another issue. The table is vertical aligned to middle (m), and in this cell i need it to be aligned to TOP. Not the box, but the multirow. \documentclass[a4paper,10pt]{article}

\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{lastpage}
\usepackage[utf8]{inputenc}
\usepackage{array,multirow}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{setspace}
\usepackage[table]{xcolor}
%definir a fonte a utilizar
\usepackage{times}
\renewcommand{\familydefault}{\sfdefault}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\vspace{0.5cm}
\noindent
\tabulinesep=1.5ex
\begin{tabu} to \linewidth {|X[m,c]|X[m,c]|X[m,c]}
\cline{0-1}
Autorizado & & \multirow{2}{*}{
\parbox[t][][t]{4cm}{
\small
\begin{description}
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\end{description}
}
}\\\cline{0-1}
Não Autorizado & \\\cline{0-1}
\end{tabu}

\end{document}`
  • Welcome to TeX.SX! You have to pass a width to \multirow if you want to typeset a list in it; or you can set the description inside a minipage environment. – egreg Nov 7 '13 at 12:02
  • Thanks! I have made it in other way, i'll update it. Ofcourse with other problems. – LMatos Nov 7 '13 at 12:26
1

I've been thinking of your question. Why do you even want to have a description INSIDE a tabu cell?! If your answer is "to have it beside the table" or "I use the tabu for text alignment" please consider the following alternative. The output looks like the same, but requires much less tinkering.

\documentclass[a4paper,10pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{enumitem}
\usepackage{tabu}

\begin{document}

\noindent
\tabulinesep=1.5ex
\begin{tabu} to 0.66\linewidth [t] {|X[m,c]|X[m,c]|}
\firsthline
Autorizado & \\
\hline
Não Autorizado & \\
\hline
\end{tabu}
\begin{minipage}[t]{\hsize}
    \begin{description}[itemsep=0pt,parsep=0pt]
        \item[First] The first item
        \item[Second] The second item
        \item[Third] The third etc \ldots
    \end{description}
\end{minipage}

\end{document}
  • well ... that's it ... that 0.66 is the true answer. I am new to latex, so i was also unable to remember the minipage. – LMatos Nov 11 '13 at 14:05
  • @user2674293 No problem. I'm quite new to LaTeX as well. Sometimes when I ask a question someone (most of the times egreg) points out that what I'm trying to achieve is a huge overkill and the original task can be done in a "more tex" way (which is often shorter too). That's why I dared to add this answer. And your question triggered an answer which IMHO has really useful info. – masu Nov 11 '13 at 14:25
3

You can set your description in a minipage; with the help of enumitem you can remove the space between items (if desired). There's no need to guess the width of the minipage, because you can use \hsize.

Note that I removed the m specifier in the third column or you will never get top alignment.

This is a rare case where \multirow can benefit, although the purpose is not very clear.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}

\usepackage{array,multirow,enumitem}
\usepackage{longtable}
\usepackage{tabu}

\begin{document}

\noindent
\tabulinesep=1.5ex
\begin{tabu} to \linewidth {|X[m,c]|X[m,c]|X}
% some cells to show the effect
\hline
A & B & C \\
\hline
% now an empty row
\multicolumn{3}{c}{} \\
% here starts your table
\cline{0-1}
Autorizado & & \multirow{2}{*}{%
  \begin{minipage}[t]{\hsize}
    \begin{description}[itemsep=0pt,parsep=0pt]
        \item[First] The first item
        \item[Second] The second item
        \item[Third] The third etc \ldots
    \end{description}
  \end{minipage}%
}\\\cline{0-1}
Não Autorizado & \\\cline{0-1}
\end{tabu}

\end{document}

enter image description here

  • "Note that I removed the m specifier in the third column or you will never get top alignment." - you said it all. and in this case ... i can change the align to top ... but if you wanted this to one one cell it would not be possible, right? – LMatos Nov 7 '13 at 13:28
  • @user2674293 I don't know precisely; and I'm not keen on burning my eyes looking at tabu's documentation. – egreg Nov 7 '13 at 13:31
  • @egreg Your code is identical to the MWE of the asker. Is it on purpose? (Or am I missing sg?) – masu Nov 7 '13 at 17:08
  • @egreg I don't think this is aligned to top (even with the m and x removed). Should it be? – masu Nov 7 '13 at 17:21
  • I mean: a [t] is missing from tabu and a \firsthline would be appropriate. – masu Nov 7 '13 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.