Graphics, Figures & TablesHelp with row height and cell alignment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
caiosan
Posts: 3
Joined: Sat Mar 27, 2010 8:42 pm

Help with row height and cell alignment

Post by caiosan »

Hi,

I'm trying to do this table in the code section below. I've tried many options and I've read many threads and topics, but I can't make the row height equal to some rows. Independently, if some row has two or one line. Moreover, I want centre alignment to both position (vertical and horizontal) in each cell.

I've tried \renewcommand{\arraystretch}{0.2} into \begin{table}\end{table} but the problem persists.

Can someone help me?

PS: I expect to be clear about the problem.

Code: Select all

\documentclass [a4paper,12pt]{article}
\usepackage [latin1,utf8]{inputenc}
\usepackage [brazil] {babel} % Pacote utilizado (babel)
\usepackage {glossary}
\usepackage {colortbl}
 
\begin{document}

\definecolor{titlecolor}{RGB}{240,240,240}

\begin{center}
\newcommand{\thistablespace}{0.2in}
\begin{longtable}[H]{|>{\raggedright\arraybackslash}m{2in}|c|c|c|c|}
\hline
\rowcolor{titlecolor}
\multicolumn{1}{|>{\columncolor{titlecolor}}c|}{\textbf{Nome}} &
\textbf{Status} &
\textbf{Custo Estimado\footnote{Horas necessárias para que uma única mão de obra complete a tarefa.}} &
\textbf{Prioridade} &
\textbf{Risco}\\
\hline
Gerenciamento de Perfil do Jogo & Proposto & 1000 & Crítica & Crítico\\
[\thistablespace]
\hline
Armazenamento de Perfil em Banco de Dados & Proposto & 500 & Crítica & Crítico\\
[\thistablespace]
\hline
Geração do Módulo Web\footnote{Applet ou Binário executável em navegador web.} & Proposto & 500 & Crítica & Crítico\\
[\thistablespace]
\hline
Geração do Banco de Dados do Módulo Web & Proposto & 500 & Crítica & Crítico\\
[\thistablespace]
\hline
Relatório do Módulo Web & Proposto & 300 & Importante & Significativo\\
[\thistablespace]
\hline
Armazennamento de Perfil em Arquivo & Proposto & 500 & Dispensável & Significativo\\
[\thistablespace]
\hline
Geração de Binário Java & Proposto & 500 & Dispensável & Significativo\\
[\thistablespace]
\hline
\end{longtable}
\end{center}

\end{document}
Last edited by caiosan on Sun Mar 28, 2010 2:24 am, edited 1 time in total.

Recommended reading 2024:

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

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

caiosan
Posts: 3
Joined: Sat Mar 27, 2010 8:42 pm

Help with row height and cell alignment

Post by caiosan »

I've done what I wanted. I expect to there be some more clever way.

Code: Select all

\documentclass [a4paper,12pt]{article}
\usepackage [latin1,utf8]{inputenc}
\usepackage [brazil] {babel} % Pacote utilizado (babel)
\usepackage {glossary}
\usepackage {colortbl}
\usepackage {multirow}

\begin{document}

\definecolor{titlecolor}{RGB}{240,240,240}

\begin{center}

\begin{longtable}[H]{|>{\raggedright\arraybackslash}m{2in}|c|c|c|c|}
\hline
\rowcolor{titlecolor}
\multicolumn{1}{|>{\columncolor{titlecolor}}c|}{\textbf{Nome}} &
\textbf{Status} &
\textbf{Custo Estimado\footnote{Horas necessárias para que uma única mão de obra complete a tarefa.}} &
\textbf{Prioridade} &
\textbf{Risco}\\

\hline
\multirow{2}{2in}{Gerenciamento de Perfil do Jogo} & 
\multirow{2}{*}{Proposto} & 
\multirow{2}{*}{1000} &
\multirow{2}{*}{Crítica} & 
\multirow{2}{*}{Crítico}\\
& & & & \\
\hline
\multirow{2}{2in}{Armazenamento de Perfil em Banco de Dados} &
\multirow{2}{*}{Proposto} &
\multirow{2}{*}{500} & 
\multirow{2}{*}{Crítica} & 
\multirow{2}{*}{Crítico}\\
& & & & \\
\hline
\multirow{2}{2in}{Geração do Módulo Web\footnote{Applet ou Binário executável em navegador web.}} &
\multirow{2}{*}{Proposto} &
\multirow{2}{*}{500} & 
\multirow{2}{*}{Crítica} & 
\multirow{2}{*}{Crítico}\\
& & & & \\
\hline
\multirow{2}{2in}{Geração do Banco de Dados do Módulo Web} &
\multirow{2}{*}{Proposto} &
\multirow{2}{*}{500} & 
\multirow{2}{*}{Crítica} & 
\multirow{2}{*}{Crítico}\\
& & & & \\
\hline
\multirow{2}{2in}{Relatório do Módulo Web} &
\multirow{2}{*}{Proposto} &
\multirow{2}{*}{300} & 
\multirow{2}{*}{Importante} & 
\multirow{2}{*}{Significativo}\\
& & & & \\
\hline
\multirow{2}{2in}{Armazennamento de Perfil em Arquivo} &
\multirow{2}{*}{Proposto} &
\multirow{2}{*}{500} & 
\multirow{2}{*}{Dispensável} & 
\multirow{2}{*}{Significativo}\\
& & & & \\
\hline
\multirow{2}{2in}{Geração de Binário Java} &
\multirow{2}{*}{Proposto} &
\multirow{2}{*}{500} & 
\multirow{2}{*}{Dispensável} & 
\multirow{2}{*}{Significativo}\\
& & & & \\
\hline
\end{longtable}

\end{center}
\end{document}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Help with row height and cell alignment

Post by gmedina »

Hi,

the following code shows a modified version of your table. The most relevant change is the use of the @{...} construct (refer to the documentation of the array package for details) to include in every row an "invisible" symbol that expands two lines (and guarantees an even row height).

I also used some of the features provided by the booktabs package to improve the general appearance of the table; of course, the use of this package (which implies suppressing the vertical lines) is just a suggestion.

Code: Select all

\documentclass [a4paper,12pt]{article}
\usepackage [utf8]{inputenc}
\usepackage [brazil] {babel}
\usepackage{longtable,booktabs}
\usepackage[table]{xcolor}

\definecolor{titlecolor}{RGB}{240,240,240}
\newcolumntype{A}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{longtable}%
  {>{\raggedright\arraybackslash}m{2in}@{\vphantom{$\Bigg($}\hspace*{6pt}}%
   A{1.7cm}A{2.4cm}A{2.2cm}A{2.2cm}}
  \toprule
  \rowcolor{titlecolor}
  \multicolumn{1}{>{\columncolor{titlecolor}}c}{\textbf{Nome}} &
    \textbf{Status} &
    \textbf{Custo Estimado\footnote{Horas necessárias para que uma única mão de obra
      complete a tarefa.}} &
    \textbf{Prioridade} &
    \textbf{Risco}\\
  \toprule
  Gerenciamento de Perfil do Jogo & Proposto & 1000 & Crítica & Crítico\\
  Armazenamento de Perfil em Banco de Dados & Proposto & 500 & Crítica & Crítico\\
  Geração do Módulo Web\footnote{Applet ou Binário executável em navegador web.} 
   &  Proposto & 500 & Crítica & Crítico\\
  Geração do Banco de Dados do Módulo Web & Proposto & 500 & Crítica & Crítico\\
  Relatório do Módulo Web & Proposto & 300 & Importante & Significativo\\
  Armazennamento de Perfil em Arquivo & Proposto & 500 & Dispensável & 
    Significativo\\
  Geração de Binário Java & Proposto & 500 & Dispensável & Significativo\\
  \bottomrule
\end{longtable}

\end{document} 
1,1,2,3,5,8,13,21,34,55,89,144,233,...
caiosan
Posts: 3
Joined: Sat Mar 27, 2010 8:42 pm

Re: Help with row height and cell alignment

Post by caiosan »

That's it. Thank you very much. I really appreciated your help.
Post Reply