Graphics, Figures & TablesCentering of table headers and spacing between columns

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Bluemilk
Posts: 5
Joined: Sun Jun 08, 2008 3:12 pm

Centering of table headers and spacing between columns

Post by Bluemilk »

Hi everyone,

Due to the amount of text I have in my tables, I need to have some spacing between the table columns, otherwise the contents might confuse the readers. To improve readability, I think it would be nice to center the table headers in my table as well. I am using the booktables package for this table. Any help would be appreciated.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage{booktabs}
\begin{table}
\begin{center}
\begin{tabular}{lp{5cm}p{5cm}}
\toprule
Lorem & Here1 &  Here There everywhere \\
\midrule
Here1  & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet,
	   & Lacus sit amet tristique gravida, dui mauris auctor orci, non ultricies velit nisl at est.\\[+0.15in] 
Here2  & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, 
\vspace{.15in} & OLacus sit amet tristique gravida, dui mauris auctor orci, non ultricies velit nisl at est.\\ %[+0.30in]
Here3 & Vestibulum sed metus et lectus aliquet luctus. Quisque convallis sapien eget sapien rhoncus vel lobortis urna laoreet. Sed aliquam rhoncus
velit eu venenatis . & Cras dui eros, laoreet sed ornare id, facilisis a lacus.\\
\bottomrule
\end{tabular}
\end{center}
\caption{Caption}
\label{naldsg}
\end{table}
\end{document}
Last edited by Bluemilk on Sat Jun 05, 2010 12:49 pm, 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.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centering of table headers and spacing between columns

Post by localghost »

I'm not sure what you really want because there is already some space between the columns. For custom space and centering of the head cells see the code below.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs}

\begin{document}
  \begin{table}[!ht]
    \caption{Caption}\label{tab:table}
    \centering
    \begin{tabular}{l@{\qquad}p{5cm}@{\qquad}p{5cm}}\toprule
      \multicolumn{1}{c}{Lorem} & \multicolumn{1}{c}{Here1} &  \multicolumn{1}{c}{Here There everywhere} \\ \midrule
      Here1  & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet,
      & Lacus sit amet tristique gravida, dui mauris auctor orci, non ultricies velit nisl at est.\\ \addlinespace
      Here2  & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet,
      & OLacus sit amet tristique gravida, dui mauris auctor orci, non ultricies velit nisl at est. \\ \addlinespace
      Here3 & Vestibulum sed metus et lectus aliquet luctus. Quisque convallis sapien eget sapien rhoncus vel lobortis urna laoreet. Sed aliquam rhoncus velit eu venenatis.
      & Cras dui eros, laoreet sed ornare id, facilisis a lacus. \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}

Thorsten
Bluemilk
Posts: 5
Joined: Sun Jun 08, 2008 3:12 pm

Re: Centering of table headers and spacing between columns

Post by Bluemilk »

Thanks localghost! That was what I wanted. Sorry my initial post wasn't so clear. :oops:
Post Reply