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 two questions in creating the following table:

1) How to make the first sub-column (with title No.) adaptive in width? Now it has the same width with the second sub-column, but I'd like to make the No. column narrower.

2) How to vertically center the Employee column title "Employee"?

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}
{ *2{>{\centering}m{2cm}| }
>{\centering\arraybackslash}m{2cm}|
 *2{>{\centering}m{1.6cm}| }
 >{\centering\arraybackslash}m{2cm}|
>{\centering\arraybackslash}m{1.7cm}}
\hline
\multicolumn{2}{c|}{ Location} & Production &
\multicolumn{2}{c|}{Ratio in Year} & Employees & Profit \\
\cline{1-1}\cline{2-1}\cline{4-1}\cline{5-1}
 No. & coordinates& (lb.) & 1983 & 1984 && \$ \\ \hline
1 & -2 36 27 & 28000 & 0.35 & 0.31 & 17 & 542800\\ \hline
\end{tabular}
\end{document}

enter image description here

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

For the adaptive width just split the definition of the first two columns, keeping the m{2cm} column for the second and introducing a c column for the first. c, l, and r columns all take the natural width of text as width.

For the vertical centering you can use the \multirow{<rows>}{<width>}{<content>} command from the multirow package.

\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\begin{document}
\begin{tabular}{
    c|                              %first column
    >{\centering}m{2cm}|            
    >{\centering\arraybackslash}m{2cm}
    |*2{>{\centering}m{1.6cm}| }
    >{\centering\arraybackslash}m{2cm}|
    >{\centering\arraybackslash}m{1.7cm}
}
\hline
\multicolumn{2}{c|}{ Location} & Production &
\multicolumn{2}{c|}{Ratio in Year} & \multirow{2}{*}{Employees} & Profit \\
\cline{1-1}\cline{2-1}\cline{4-1}\cline{5-1}
 No. & coordinates& (lb.) & 1983 & 1984 && \$ \\ \hline
1 & -2 36 27 & 28000 & 0.35 & 0.31 & 17 & 542800\\ \hline
\end{tabular}
\end{document}

enter image description here

share|improve this answer
    
Perfect! Thanks a lot for the kind help. BTW, how do you upload the generated jpg file? –  bluepole Nov 24 '13 at 13:16
1  
@bluepole there is a landscape-like squared icon in the edit box toolbar. Just click on that and select the .jpg/png/gif/whatever from your hard disk –  dcmst Nov 24 '13 at 13:25
add comment

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.