LaTeX 表格浮动问题

LaTeX 表格浮动问题

表格不必要地浮动到下一页。我希望将其放置在指定的位置。

\renewcommand{\familydefault}{\sfdefault}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage[scaled=1]{helvet}
\usepackage[helvet]{sfmath}
\usepackage{graphicx}
\setcounter{chapter}{0}
\frontmatter
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\begin{document}
\chapter{Exponents}
\begin{multicols}{2}
\renewcommand{\theenumii}{\Alph{enumii}}
\begin{enumerate}
\item
\begin{table*}[!htbp]
\begin{tabular}{cc|c|c|c|c}
    \cline{3-5}
    &        & \multicolumn{3}{c|}{Course}       &                            
   \\ \cline{3-6} 
    &        & Algebra I & Geometry & Algebra II & \multicolumn{1}{c|} 
{Total} \\ \hline
    \multicolumn{1}{|c|}{\multirow{2}{*}{Gender}} & Female & 35        & 53       & 62         & \multicolumn{1}{c|}{150}   \\ \cline{2-6} 
    \multicolumn{1}{|c|}{}                        & Male   & 44        & 59       & 57         & \multicolumn{1}{c|}{160}   \\ \hline
    \multicolumn{2}{|c|}{Total}                            & 79        & 112      & 119        & \multicolumn{1}{c|}{310}   \\ \hline
\end{tabular}
\end{table*}
A group of tenth-grade students responded to a survey that asked which math 
course they were currently enrolled in. The survey data were broken down as 
she able above. Which of the following categories accounts for approximately 
19 percent of all the survey respondents?
\begin{enumerate}
\item   Females taking Geometry
\item   Females taking Algebra II
\item   Males taking Geometry
\item   Males taking Algebra I
\end{enumerate}
\item
Which of the following expressions is equivalent to 
$ \sqrt[3]{a}\cdot a \cdot \sqrt[5]{a^2} $  for $a > 0$ ? 
\\
\begin{enumerate}
\item $a^\frac{2}{15}$\\
\item $a^\frac{6}{15}$\\
\item $a^\frac{11}{15}$\\
\item $a^\frac{26}{15}$\\
\end{enumerate}
\item
$$ \sqrt{16y^2} $$  
If $x>0$, which of the following is equivalent to the given expression?\\
\begin{enumerate}
\item $4y$\\
\item $4y^2$\\
\item $32y$\\
\item $32y^2$\\
\end{enumerate}
\end{enumerate}
\end{multicols}
\end{document}

答案1

我的回答仅关注您帖子的一个方面:如何使表格材料适合列的宽度。

您尚未指明您使用的文档类别、字体大小或页面和文本块尺寸。因此,以下解决方案可能无法完全满足您的格式需求。如果不满足,请随时提供有关缺失信息的更多详细信息。

以下屏幕截图显示了您的原始tabular环境(包含大量垂直和水平线)以及拟议的新tabular*环境。前者显然比 宽得多\columnwidth。后者环境占用的水平空间要少得多,主要是因为它使用 5 列而不是 6 列。相反,新提出的解决方案 (a) 将数字与各自的(隐式)小数点对齐,并且 (b) 努力提供更“开放”的外观,主要是通过省略所有垂直线并使用更少但间距适当的水平线。第二个解决方案还旨在提供信息丰富的标题。

在此处输入图片描述

\documentclass[twocolumn]{article}  % ?
\renewcommand{\familydefault}{\sfdefault}
\usepackage{booktabs,siunitx,multirow}
\usepackage[skip=0.333\baselineskip]{caption} % optional
\begin{document}

\begin{table}

\caption{Original solution}
\begin{tabular}{cc|c|c|c|c}
    \cline{3-5}
    &        & \multicolumn{3}{c|}{Course}       &                            
   \\ \cline{3-6} 
    &        & Algebra I & Geometry & Algebra II & \multicolumn{1}{c|} 
{Total} \\ \hline
    \multicolumn{1}{|c|}{\multirow{2}{*}{Gender}} & Female & 35        & 53       & 62         & \multicolumn{1}{c|}{150}   \\ \cline{2-6} 
    \multicolumn{1}{|c|}{}                        & Male   & 44        & 59       & 57         & \multicolumn{1}{c|}{160}   \\ \hline
    \multicolumn{2}{|c|}{Total}                            & 79        & 112      & 119        & \multicolumn{1}{c|}{310}   \\ \hline
\end{tabular}

\vspace{1cm}

\caption{Student enrolments, by gender and course}
\setlength\tabcolsep{0pt} % make LaTeX figure out amount of inter-column whitespace
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}l *{4}{S[table-format=3.0]}}
\toprule
Gender & \multicolumn{3}{c}{Course} & {Total} \\ 
\cmidrule{2-4} 
       & {Algebra I} & {Geometry} & {Algebra II} \\ 
\midrule
Female & 35 & 53 &  62 & 150 \\  
Male   & 44 & 59 &  57 & 160 \\ 
\addlinespace
Total  & 79 &112 & 119 & 310 \\ 
\bottomrule
\end{tabular*}

\end{table}
\end{document}

相关内容