表格浮动位于底部,同时在页面中间留出空白

表格浮动位于底部,同时在页面中间留出空白

我在排列页面上的浮动元素时遇到了麻烦。例如,请参见下面的屏幕截图:

为什么会这样?这个特定的小节中只有这么多文本,那么为什么 Latex 不将表格放在文本后面并开始下一个小节呢?

截屏

表格不受任何宽度限制。

\begin{table}
\caption{Effect of biofilm density on the drag and oscillation behavior. The
para\-meters used in the simulation are: $L/d=4.5$,  $U_{0}=\SI{0.4}{\meter\per\second}$ 
($Re_{D}=133$).\label{tab:Effect-of-biofilm-density}}
\begin{tabular*}{0.8\textwidth}{@{\extracolsep{\fill}}cccc>{\centering}p{0.15\textwidth}}
\toprule 
Density (\si{\kilogram\per\cubic\meter}) & $C_{D}$ (-) & Oscillation Frequency (\si{\hertz}) & Amplitude (\si{\micro\meter}) & Strouhal Number (-)\tabularnewline
\midrule 
\num{950} & \num{1.2838} & 199.6 & 169 & 0.1662\tabularnewline
\num{1000} & \num{1.2913} & 199.0 & 181 & 0.1658\tabularnewline
\num{1100} & \num{1.2950} & 196.9 & 177 & 0.1639\tabularnewline
\num{1200} & \num{1.2988} & 195.2 & 182 & 0.1625\tabularnewline
\bottomrule
\end{tabular*}
\end{table}

以下是我的序言:

\usepackage{mathptmx}
\renewcommand*{\rmdefault}{ppl}
\renewcommand*{\sfdefault}{ppl}
\newcommand\hmmax{0} % default 3


%\usepackage{floatrow} 
\usepackage{xcolor}
\definecolor{darkred}{rgb}{0.667,0.118,0.004}
\definecolor{codebg}{rgb}{0.95,0.95,0.95}
\definecolor{lgreen}{HTML}{b8b60b}

\usepackage[tocgraduated]{tocstyle} 
\usetocstyle{nopagecolumn} 


\usepackage{prettyref}
\newrefformat{eq}{Equation~\textup{(\ref{#1})}}
\newrefformat{chap}{Chapter~\ref{#1}}
\newrefformat{sec}{Section~\ref{#1}}
\newrefformat{sub}{Section~\ref{#1}}
\newrefformat{tab}{Table~\ref{#1}}
\newrefformat{fig}{Figure~\ref{#1}}


% schönerer Blocksatz!!
\usepackage{microtype}


\@ifpackageloaded{nomencl}{
\renewcommand{\nomname}{List of Notations}
\renewcommand*{\pagedeclaration}[1]{\unskip\dotfill\hyperpage{#1}}
}{}

%\setlength{\nomitemsep}{-\parsep}


%todo notes
\usepackage[colorinlistoftodos]{todonotes}
\newcommand{\todog}[1]{\todo[color=lgreen]{#1}}
\newcommand{\todor}[1]{\todo[color=red!40]{#1}}
\newcommand{\todob}[1]{\todo[color=blue!40]{#1}}
%/todo notes

\usepackage[]{titlesec}
\titleformat{\chapter}[display]{\scshape\small}{\filleft\rmfamily\fontsize{72pt}{10pt}\selectfont\textcolor{darkred}\thechapter}{1ex}{\rmfamily\Huge\itshape\filleft}[\vspace{2ex}]


\usepackage{booktabs}

%mass transfer paper
\usepackage{siunitx} 
\sisetup{inter-unit-product={}\cdot{},number-unit-product = \;}
%end mass transfer paper


%show vectors in bold
\usepackage{bm}
\DeclareRobustCommand\vec[1]{%
  \ifcat\noexpand#1\relax
    \expandafter\bm
  \else
    \expandafter\mathbf
  \fi{#1}}
%end renew commands


\usepackage[indention={.5cm},font={small,rm},format={plain},labelfont={rm,bf,up},textfont={rm,up}]{caption}

%-------center everything----------[
\usepackage{ifthen}

\renewenvironment{figure}[1][]{%
 \ifthenelse{\equal{#1}{}}{%
   \@float{figure}
 }{%
   \@float{figure}[#1]%
 }%
 \centering
}{%
 \end@float
}


\renewenvironment{table}[1][]{%
 \ifthenelse{\equal{#1}{}}{%
   \@float{table}
 }{%
   \@float{table}[#1]%
 }%
 \centering
}{%
 \end@float
}
%]----------centering-------------
\@ifpackageloaded{nomencl}{
\renewcommand{\nomname}{List of Symbols}
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{A}}{\item[\textbf{Roman Symbols}]}{%
\ifthenelse{\equal{#1}{G}}{\item[\textbf{Greek Symbols}]}{%
\ifthenelse{\equal{#1}{C}}{\item[\textbf{Abbreviations}]}{%
\ifthenelse{\equal{#1}{S}}{\item[\textbf{Subscripts}]}{%
\ifthenelse{\equal{#1}{T}}{\item[\textbf{Superscripts}]}{
\ifthenelse{\equal{#1}{Z}}{\item[\textbf{Mathematical Symbols}]}
{}
}% matches mathematical symbols
}% matches Subscripts
}% matches Superscripts
}% matches Abbreviations
}% matches Greek Symbols
}% matches Roman Symbols
}{}


% for correct jump positions whe clicking on a link to a float
%\usepackage[figure]{hypcap}

\definecolor{chaptercolor}{rgb}{.176,0,.367}

\addtokomafont{chapter}{\color{darkred}}
\addtokomafont{part}{\color{darkred}}
\addtokomafont{section}{\rmfamily\itshape}
\addtokomafont{subsection}{\rmfamily\itshape}
\addtokomafont{paragraph}{\normalfont\upshape\rmfamily\itshape}





\renewcommand*{\addparttocentry}[2]{%
  \addcontentsline{toc}{part}{\partname\nobreakspace \protect\numberline{#1}#2}%
}


\usepackage{verbatim} % Mostly for the comment environment.
\newenvironment{mylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}
\newenvironment{mytinylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\tiny\bfseries}
{\end{list}}


\usepackage{bigints}
\usepackage[font=small]{idxlayout}


%ornament
\usepackage{fourier-orns}
\newcommand*\myhrulefill{%
   \leavevmode\leaders\hrule depth-2pt height 2.4pt\hfill\kern0pt}
\newcommand\niceending[1]{%
  \begin{center}%
    \LARGE -------------------- \hspace{0.2cm} #1 \hspace{0.2cm} --------------------%
  \end{center}}
\newcommand*\nicesectionending{\niceending{\decofourright\decofourleft}}
\newcommand*\nicesubsectionending{\niceending{\aldinesmall}}
%/ornament


\usepackage{tikz}

\newenvironment{elaboration}{%
    \par
    \begin{tikzpicture}
    \node[rectangle,minimum width=0.9\textwidth] (m)
    \bgroup\begin{minipage}{0.85\textwidth}%
}{%
    \end{minipage}\egroup;
    \draw[dashed] (m.south west) rectangle (m.north east);
    \end{tikzpicture}
}


\usepackage[section]{placeins}

\clubpenalty = 10000
\widowpenalty = 10000

以下是最小工作示例:

%% LyX 2.0.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,oneside,english,titlepage, a4paper, fontsize=12pt]{scrbook}
\usepackage{mathpazo}
\usepackage{helvet}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=3.5cm,lmargin=2.5cm,rmargin=2.5cm}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\usepackage{color}
\usepackage{babel}
\usepackage{array}
\usepackage{booktabs}
\usepackage{setspace}
\onehalfspacing


\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\input{preambles/common.sty}
\usepackage{blindtext}

\makeatother

\begin{document}

\section{This is a title}

\blindtext

\begin{table}
\caption{Effect of biofilm density on the drag and oscillation behavior. The
para\-meters used in the simulation are: $L/d=4.5$,  $U_{0}=\SI{0.4}{\meter\per\second}$ 
($Re_{D}=133$).\label{tab:Effect-of-biofilm-density-1}}
\begin{tabular*}{0.8\textwidth}{@{\extracolsep{\fill}}cccc>{\centering}p{0.15\textwidth}}
\toprule 
Density (\si{\kilogram\per\cubic\meter}) & $C_{D}$ (-) & Oscillation Frequency (\si{\hertz}) & Amplitude (\si{\micro\meter}) & Strouhal Number (-)\tabularnewline
\midrule 
\num{950} & \num{1.2838} & 199.6 & 169 & 0.1662\tabularnewline
\num{1000} & \num{1.2913} & 199.0 & 181 & 0.1658\tabularnewline
\num{1100} & \num{1.2950} & 196.9 & 177 & 0.1639\tabularnewline
\num{1200} & \num{1.2988} & 195.2 & 182 & 0.1625\tabularnewline
\bottomrule
\end{tabular*}
\end{table}



\section{This is another title}

\blindtext
\end{document}

答案1

通过您的简单示例,可以明显看出:您允许 LaTeX 使用默认浮动位置,而无需指定任何内容。因此,\begin{table}...\end{table}默认为\begin{table}[tbp]...\end{table}。有关此内容的更多信息,请参见这里

以此为基础,唯一的选择是顶部 [t]或者底部 [b]页面的其自身[p]。其间的选择由以下长度/计数器控制:

  • \topfraction(浮点数的最大分数为顶部;默认为0.699
  • \topnumber(数量顶部允许浮点数;默认为2)
  • \textfraction(默认为0.199
  • \bottomfraction(浮点数的最大分数为底部;默认为0.300
  • \bottomnumber(数量底部允许浮点数;默认为1)
  • \totalnumber(每页允许的浮点数;默认值为3

定义\...number是计数器,因此可以通过 进行更改\setcounter\...fraction需要使用 来更改定义\renewcommand。从layouts包裹 文档,下图显示了这些参数之间的关系:

带浮动的页面布局

这些限制可能已经超过放置浮子在顶部 [t],导致它被放置在底部 [b](因为有足够的空间)。添加这里 [h]说明符作为主要偏好应该可以克服这个问题:

\begin{table}[htb]
  ...
\end{table}

答案2

改变路线

\begin{table}

\begin{table}[h]

解决了您的问题。但是您的示例实际上并不是 MWE,因此很难判断问题是什么。以下是我复制您的代码并使用说明符后得到的结果[h]

回答

相关内容