Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have this table:

\usepackage{array}
\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}

\begin{table}[ht]\footnotesize
\centering
\begin{tabular*}{0.95\textwidth }{@{\extracolsep{\fill}}|llllllllllllllll|x{0.15\textwidth}|}
\hline
\multicolumn{16}{|c|}{Small text} & Long text \\ \hline 
1 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 16 & 19 & 20 & 21 & 22 & 23 & 0.9636149 \\ \hline 
\end{tabular*}
\caption{Caption}
\label{tab:Example}
\end{table}

How to center "Small text"?

share|improve this question
    
I can't compile your example. What table-extending packages are you using? –  Matthew Leingang Nov 7 '10 at 19:38
    
Sorry, I haven't included my custom column definition. Now it should compile. –  pixel Nov 7 '10 at 19:45
    
Works for me, sort of. With the standard article class the lines don't extend all the way across, because the table is too wide for the \textwidth. If I do \usepackage[letterpaper]{geometry} which shortens the margins a bit, the lines extend all the way across. Either way, though, "small text" is centered across the first 16 columns. Can you post a picture of what you're seeing? –  Matthew Leingang Nov 7 '10 at 19:54
1  
@Matthew: I think the important word here is vertical. Think of ”long text” as something that has multiple lines. Then “small text” is aligned at the top. –  Caramdir Nov 7 '10 at 20:20
1  
Ah. I might have realized that if "long text" had actually been long text. :) –  Matthew Leingang Nov 7 '10 at 21:21

1 Answer 1

up vote 8 down vote accepted

Change the p to m in your definition of the x column type:

\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}m{#1}}

Full example:

\documentclass{article}
\usepackage{array}
\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}

\begin{table}[ht]\footnotesize
\centering
\begin{tabular*}{0.95\textwidth }{@{\extracolsep{\fill}}|llllllllllllllll|x{0.15\textwidth}|}
\hline
\multicolumn{16}{|c|}{Small text} & Long long long long long text \\ \hline 
1 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 16 & 19 & 20 & 21 & 22 & 23 & 0.9636149 \\ \hline 
\end{tabular*}
\caption{Caption}
\label{tab:Example}
\end{table}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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