[texhax] Table question - defined width and alignment

E. Krishnan ekmath at asianetindia.com
Sat Apr 9 05:49:31 CEST 2005


On Fri, 8 Apr 2005, Peter Flom wrote:

> \begin{table}
> \begin{tabular}{|l|p{.8 in}|p{.8in}|}\hline
> & \multicolumn{2}{c|}{Percent using} \\\hline
>  & Direct questioning & Randomized response \\\hline
>   18 - 25 & \centering{53} & \centering{48} \tabularnewline \hline
>  26 - 34 & \centering{36} & \centering{45} \\\hline
>  35 - 49 & 6 & 19 \\\hline
>  50 + & <1 & 3\\\hline
>  Total & 21 & 24\\\hline
> \end{tabular}
> \end{table}
> 
> I'd like "Direct Questioning" and "Randomized Response" to be set on
> two lines in one cell, but the numbers in the columns below to be flush
> right.


See whether any of these meets your needs

First :

\begin{table}
   \renewcommand{\arraystretch}{1.5}
  \begin{tabular}{|l|r|r|}
    \hline
    & \multicolumn{2}{c|}{Percent using} \\
    \cline{2-3}
    & \multicolumn{1}{p{0.8in}|}{\raggedright Direct \\ questioning}
    & \multicolumn{1}{p{0.8in}|}{\raggedright Randomized \\ response} 
    \tabularnewline 
    \hline
    18 - 25 & 53 & 48 \\ 
    \hline
    26 - 34 & 36 & 45 \\ 
    \hline
    35 - 49 & 6 & 19 \\
    \hline
    50 + & $<1$ & 3 \\
    \hline
    Total & 21 & 24 \\
    \hline
  \end{tabular}
\end{table}

Second :

 \begin{table}
  \renewcommand{\arraystretch}{1.5}
  \begin{tabular}{|l|c|c|}
    \hline
    & \multicolumn{2}{c|}{Percent using} \\
    \cline{2-3}
    & \multicolumn{1}{p{0.8in}|}{\raggedright Direct \\ questioning}
    & \multicolumn{1}{p{0.8in}|}{\raggedright Randomized \\ response} 
    \tabularnewline 
    \hline
    18 - 25 & 53 & 48 \\ 
    \hline
    26 - 34 & 36 & 45 \\ 
    \hline
    35 - 49 & \hphantom{3}6 & 19 \\
    \hline
    50 + & $<$1 & \hphantom{1}3 \\
    \hline
    Total & 21 & 24 \\
    \hline
  \end{tabular}
\end{table}







-- 
Krishnan



More information about the texhax mailing list