latex table heading help...

75 views
Skip to first unread message

Srivathsan Srinivas

unread,
Feb 11, 2010, 11:03:22 PM2/11/10
to latexus...@googlegroups.com
Hi,
     I have the following table. I have an issue with the headings of the individual columns. For example, the first heading "Related Work" is in a single line. I really want it to appear in two lines -- as -- "Related \\ Work"  ....the word 'Work' should appear **below** the word 'Related'. Any suggestions would be very helpful.

A working code is below.



\usepackage{tabularx}  % for better, more flexible-column tables
\usepackage{multirow}  % for multirow, multicolumn
\usepackage{booktabs}  % For very nice tables
\usepackage[table]{xcolor}  % for coloring table rows and columns.


%%%%%%%%%%%%%%%%%%%%%%    WORKING TABLE   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\multirowsetup}{\centering}
\newcommand {\otoprule}{\midrule [\heavyrulewidth]}  % This is for getting a bold horizontal line in the
                                                                                                         % middle of the table.
\newcommand{\capbot}[1]{%
\vspace{8pt}\footnotesize\raggedright #1}%                                                                                                         
   
\begin{table}                                                                                                       
\begin{center}
    \caption{Our results and comparison with previous results for data-fusion schemes.}   
  \footnotesize
  \renewcommand{\arraystretch}{1.5}
  %\begin{tabular}{*{3}{m{2.3cm}}*{2}{>{$}c<{$}}{>{$}r<{$}}}
     %\begin{tabular}{lllccc{>{$}r<{$}}}
     \begin{tabular}{*{3}{m{2.2cm}}*{3}{>{$}c<{$}}{>{$}r<{$}}}
    \otoprule%\toprule[2pt]
    \multirow{2}*{Related \\Work}
    & \multirow{2}*{\bfseries Algorithm}
    & \multirow{2}*{\bfseries Graph Type}
    & \multirow{2}*{\bfseries IAF}
    & \multirow{2}*{\bfseries ISS}
    & \multirow{2}*{\bfseries Approx Factor}
    & \multirow{2}*{\bfseries Tree Type}\\
    %\cmidrule{3-5}
    %&
    %& \bfseries Graph Type
    %& \multicolumn{1}{c}{\centering\bfseries IAF}
    %& \multicolumn{1}{c}{\centering\bfseries ISS}
    & \\
    \otoprule %\hline
    \raggedright Lujun Jia\\ \textit{et al.} \cite{JiaNRS06}
    & GIST
    & \raggedright Random\\Deployment
    & \times
    & \checkmark
    & O(\log n)
    & \times \\
    \hline
    \raggedright Ashish Goel\\ \textit{et al.} \cite{644191}
    & Randomized
    & Complete Graph
    & \checkmark
    & \times
    & O(\log k)
    & \times \\
    \hline
    \raggedright Ashish Goel\\ \textit{et al.} \cite{DBLP:journals/corr/abs-0908-3740}
    & Probabilistic
    & Set of Overlay Graphs
    & \checkmark
    & \times
    & O(1)
    & \times \\
    \hline
    \rowcolor[gray]{.95}
    This paper
    & Independent Set
    & \raggedright Low Doubling\\ Dimension
    & \checkmark
    & \checkmark
    & O(\log^4 n)
    & \checkmark \\
    \bottomrule
 
  \end{tabular}
  \label{table:comparison}
    \center {\capbot{IAF - Independent of fusion function, ISS - Independent of source-set,
                    $n$ is the total number of nodes in the topology, $k$ is the total number of source nodes.}}
   
\end{center}
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Werner Grundlingh

unread,
Feb 12, 2010, 2:28:55 AM2/12/10
to LaTeX Users Group
On Feb 11, 8:03 pm, Srivathsan Srinivas

Since the code does not compile on its own, I would have to go by
faith here...

I've used the package makecell for many instances where I want to put
2 (or more) cells on top of one another in a similar way that multirow
does it, but where multirow didn't yield adequate results. Consider
reading the package documentation, available online via CTAN from:
http://www.ctan.org/tex-archive/macros/latex/contrib/makecell/

Something as simple as
\makecell[c]{Related \\ Work}
for the 2-line table heading entry would work...

Hope this helps,
Werner

Peter Flynn

unread,
Feb 12, 2010, 4:29:48 AM2/12/10
to latexus...@googlegroups.com
\usepackage{array}
and then in the header line, replace the cells you want multilined with
\multicolumn{1}{b{2cm}}{Related Work}
(set whatever width is needed). The b format works like standard p format,
but aligns on the bottom line of content, not the top line.

///Peter


--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.


Reply all
Reply to author
Forward
0 new messages