2

I'm having a problem with deleting the extra space in the cell. I think it may have something to do with using \makecell in a \mulitcolumn. I'm trying to have empty space on the 1st line in the second column then have the other 2 values on two different lines.

\begin{table}[!htbp]
\scriptsize
\begin{adjustbox}{width=\textwidth}
\begin{tabular}{|p{11em}|c|c|}
 \hline
 \multicolumn{1}{|l|}{\textbf{Variable}} & \textbf{Frequency} & {\textbf{Percentage}} \\
\hline
 \multicolumn{1}{|p{8em}|}{ Binge Drinker  \newline  Not Binge Drinker \newline Binge Drinker} & {\makecell{ \\ \\ 1147 \\ 2982}} & { \makecell{\\ \\  27.8 \\ 72.2}} \\

This is the table should look like with no extra in the cell.

\begin{table}[!htbp]
\scriptsize
\begin{adjustbox}{width=\textwidth}
  \begin{tabular}{r|p{6em}|l|r|r }
 \hline
\multicolumn{1}{|l|}{\textbf{Independent Variable}} & \multicolumn{4}{c|} 
{\textbf{Chi- Square Results}} \\
\hline
\multicolumn{1}{|r|}{} & \textbf{Alcohol Use} & \multicolumn{1}{p{6em}|} 
 {\textbf{Chi-Square}} & \multicolumn{1}{p{4em}|}{\textbf{P-Value}} & 
\multicolumn{1}{p{1em}|}{\textbf{Sig}} \\
\hline
\multicolumn{1}{|p{8em}|}{Education\newline Freshman\newline 
 Sophomore/Junior\newline Senior/Grad} & -----\newline 71.9 \newline 73 
 \newline 71.2 & \multicolumn{1}{c|}{-0.005} & \multicolumn{1}{c|}{0.725} & 
 \multicolumn{1}{c|}{} \\
 \end{tabular}%
 \end{adjustbox}
 \caption{\textbf{Table 4.3.1}}
 \end{table}%
  • Welcome to tex.sx, please add a full compilable MWE that shows your problem and don't forget to indent the code by 4 spaces. – AboAmmar Aug 6 '18 at 1:20
0

Not sure to have understood exactly what you want, but maybe it is this, obtained with tabulatx. Don't use adjustbox with tables – it results in inconsistent font sizes:

\documentclass[openany, oneside]{book}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{setspace} 
\usepackage{booktabs, makecell, caption, threeparttable, tabularx}
\usepackage{float}

\begin{document} 

\begin{table}[!htbp]
\setlength{\extrarowheight}{2pt}
\begin{tabularx}{\linewidth}{|X|c|c|}
 \hline
\textbf{Variable} & \textbf{Frequency} & {\textbf{Percentage}} \\
\hline
Binge Drinker & & \\
 Not Binge Drinker & 1147 & 27.8 \\
Binge Drinker & 2982 & 72.2 \\
\hline
\end{tabularx}
\end{table}

\end{document} 

enter image description here

| improve this answer | |
1

enter image description here

table isbased on guessing ...since you not provide mwe. in above table design i use the \thead macro from the makecell package, and for vertical spacing of cells' contents in the second and third column \multirow cells. the code:

\documentclass[margin=3mm]{standalone}
\usepackage{makecell, multirow}
\renewcommand\theadfont{\bfseries\normalsize}

\begin{document}
    \begin{tabular}{|p{11em}|c|c|}
    \hline
\thead{Variable}
    & \thead{Frequency} & \thead{Percentage}        \\
    \hline
\makecell[tl]{Binge Drinker\\
              Not Binge Drinker\\
              Binge Drinker}
    & \multirow{3}{*}{\makecell{1147\\ 2982}}
        & \multirow{3}{*}{\makecell{27.8\\ 72.2}}   \\
    \hline
    \end{tabular}
\end{document}

edit: it seems that my guessing in the first attempt wass wrong, hopefully i will have now more luck :-)

enter image description here

\documentclass[margin=3mm]{standalone}
\usepackage{makecell, multirow}
\renewcommand\theadfont{\bfseries\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}

\begin{document}
{\makegapedcells
    \begin{tabular}{|p{11em}|c|c|}
    \hline
\thead{Variable}        & \thead{Frequency}         & \thead{Percentage}        \\
    \hline
Binge Drinker           &                           &                           \\
Not Binge Drinker       & \makecell{1147\\ 2982}    & \makecell{27.8\\ 72.2}    \\
Binge Drinker           &                           &                           \\
    \hline
    \end{tabular}
}
\end{document}

or like this:

enter image description here

where table body is:

   \begin{tabular}{|p{11em}|c|c|}
    \hline
\thead{Variable}        & \thead{Frequency}         & \thead{Percentage}        \\
    \hline
Binge Drinker           &                           &                           \\
    \hline
Not Binge Drinker       & \makecell{1147\\ 2982}    & \makecell{27.8\\ 72.2}    \\
    \hline
Binge Drinker           &                           &                           \\
    \hline
    \end{tabular}
| improve this answer | |
  • My question is there any way to have Not Binge Drinker to be aligned with 1147 and 27.8? – Crystal Thompson Aug 6 '18 at 1:34
  • sorry, this is no clear from your question ... how should be aligned? numbers are in two lines ... – Zarko Aug 6 '18 at 1:37
  • \documentclass[openany, oneside]{book} \usepackage{booktabs} \usepackage{caption} \usepackage{float} \usepackage{makecell} \usepackage{xcolor} \usepackage{threeparttable} \usepackage{adjustbox} \usepackage{graphicx} \usepackage{setspace} \begin{document} begin{table}[!htbp] \scriptsize \begin{adjustbox}{width=\textwidth} \begin{tabular}{r|p{6em}|l|r|r } \hline \multicolumn{1}{|l|}{\textbf{Independent Variable}} & \multicolumn{4}{c|}{\textbf{Chi- Square Results}} \\ \hline – Crystal Thompson Aug 6 '18 at 1:51
  • please, edit your question and put above code there! – Zarko Aug 6 '18 at 1:53
  • @Zarko Dearest when I see a response from the style I immediately understand that the user is you. Apparently you like the tables very much :-). Greetings. – Sebastiano Aug 6 '18 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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