表格未定位到代码指示的文本位置

表格未定位到代码指示的文本位置

我是 Latex 新手。我正在写论文,遇到了以下情况:

texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext**:**
\begin{table}[h]
\begin{center} 
\noindent\begin{tabular}{|c|c|c|}
     \hline
     \rowcolor{gray!50}
     \bfseries Specifiche Tecniche & \bfseries Bluetooth BR & \bfseries Bletooth Low Energy \\
     \hline
     Frequenza & Tra $2400$ e $2483.5$ MHz & Tra $2400$ e $2483.5$ MHz \\
     \hline
     Data Channel & $79$ & $37$ \\
     \hline
     Advertising Channel & $32$ & $3$ \\
     \hline
     Criptaggio & $64/128 bit$ & AES $128$ bit \\
     \hline
     Range & $100$ m & $> 100$m \\
     \hline
     Throughput & $0.7-2.1$ Mbit/s & $< 0.3$ Mbit/s \\
     \hline
     Latenza di Connessione &   $ \approx 100$ ms   & $6$ ms \\
     \hline
     Tempo minimo di invio dati & $100$ ms & $3$ ms \\
     \hline
     Potenza di consumo & $1$ W & Tra $0.01$ a $0.5$ W \\
     \hline
     Picco di corrente  & $22-40$ mA & $10-30$ mA \\
     \hline
\end{tabular}
\caption[Differenze tra Bluetooth BR \& Bluetooth 4.0]{Differenze tra Bluetooth BR \& Bluetooth 4.0}
\label{tab:my_label}
\end{center}
\end{table} \\
othertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertextothertext.

问题是我会将表放在这一点,然后编译器会将其定位在下一页的开头。

(PS:抱歉我的英文不好)

答案1

如果您不希望表格材料“浮动”(在 LaTeX 中这个词的含义),请不要将其放在浮动环境中,例如table。请学会适应 LaTeX 的浮动放置算法——通常情况下,它非常好。如果必须,请提供[h!]定位说明符。如果表格仍然不适合页面,则可能是该页面上没有足够的空间来容纳表格。

我还有另外两个建议:

  • 从表格材料中省略所有垂直线和大多数水平线,并使用包的线条绘制宏booktabs来绘制剩余的水平线。

  • 使用包的\num和宏分别表示标量和带单位的数字。\SIsiunitx

进行这些调整的结果显示在下面的屏幕截图中。

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage[binary-units,per-mode=symbol]{siunitx}
\usepackage[italian]{babel}
\begin{document}

\begin{table}[h!]
\renewcommand\arraystretch{1.1}
\setlength\tabcolsep{5pt} % default: 6pt
\centering % not '\begin{center}...\end{center}'
\begin{tabular}{lcc}
\rowcolor{gray!30}
\bfseries Specifiche Tecniche & \bfseries Bluetooth BR & \bfseries Bluetooth Low Energy \\ 
\addlinespace

Frequenza  & \num{2400}--\SI{2483.5}{\mega\hertz} &  \num{2400}--\SI{2483.5}{\mega\hertz} \\

Data Channel & 79 & 37 \\

Advertising Channel & 32 & 3 \\

Criptaggio & \SI{64/128}{\bit} & AES \SI{128}{\bit} \\

Range & \SI{100}{\meter} & ${}>\SI{100}{\meter}$ \\

Throughput & \num{0.7}--\SI{2.1}{\mega\bit\per\second} & ${}< 0.3$ Mbit/s \\

Latenza di Connessione & ${}\approx \SI{100}{\milli\second}$  & \SI{6}{\milli\second} \\

Tempo minimo di invio dati & \SI{100}{\milli\second} & \SI{3}{\milli\second} \\

Potenza di consumo & \SI{1}{\watt} & \num{0.01}--\SI{0.5}{\watt} \\

Picco di corrente  & \num{22}--\SI{40}{\milli\ampere} & \num{10}--\SI{30}{\milli\ampere} \\
\bottomrule
\end{tabular}
\caption[Differenze tra Bluetooth BR e Bluetooth 4.0]{Differenze tra Bluetooth BR e Bluetooth 4.0}
\label{tab:my_label}
\end{table} 
\end{document}

答案2

[解决] 感谢 sharelatex 的指导https://it.sharelatex.com/learn/Positioning_images_and_tables- 定位表部分我使用了参数 H 而不是 Mico 建议的 h!。为此,我的新代码是:

 \begin{table}[H]
\centering
\begin{tabular}{|c|c|c|}
     \hline
     \rowcolor{gray!50}
     \bfseries Specifiche Tecniche & \bfseries Bluetooth BR & \bfseries Bletooth Low Energy \\
     \hline
     Frequenza & Tra $2400$ e $2483.5$ MHz & Tra $2400$ e $2483.5$ MHz \\
     \hline
     Data Channel & $79$ & $37$ \\
     \hline
     Advertising Channel & $32$ & $3$ \\
     \hline
     Criptaggio & $64/128 bit$ & AES $128$ bit \\
     \hline
     Range & $100$ m & $> 100$m \\
     \hline
     Throughput & $0.7-2.1$ Mbit/s & $< 0.3$ Mbit/s \\
     \hline
     Latenza di Connessione &   $ \approx 100$ ms   & $6$ ms \\
     \hline
     Tempo minimo di invio dati & $100$ ms & $3$ ms \\
     \hline
     Potenza di consumo & $1$ W & Tra $0.01$ a $0.5$ W \\
     \hline
     Picco di corrente  & $22-40$ mA & $10-30$ mA \\
     \hline
\end{tabular}
\caption[Differenze tra Bluetooth BR \& Bluetooth 4.0]{Differenze tra Bluetooth BR \& Bluetooth 4.0}
\label{tab:my_label}

\end{table}

致以最诚挚的问候并感谢大家

相关内容