\makecell
我在删除单元格中的多余空间时遇到了问题。我认为这可能与使用有关\mulitcolumn
。我试图在第二列的第一行留出空白,然后将其他两个值放在两行上。
\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}} \\
表格看起来应该是这样的,单元格中没有多余的内容。
\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}%
答案1
不确定是否完全理解了你想要什么,但也许是这个,用 获得tabulatx
。不要 adjustbox
与表格一起使用——它会导致字体大小不一致:
\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}
答案2
表格是基于猜测的......因为你没有提供mwe。在上面的表格设计中,我使用了包\thead
中的宏makecell
,并将其用于第二列和第三列\multirow
单元格中单元格内容的垂直间距。代码:
\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}
编辑: 看来我第一次的猜测是错误的,希望我现在能有更多的运气:-)
\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}
或者像这样:
表体内容如下:
\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}