如何使表格单元格的值在乳胶中居中?

发布于 2024-11-16 04:58:46 字数 772 浏览 1 评论 0原文

请告诉我如何使该表中的值出现在中间。

\begin{table}[h]
    \begin{center}
\caption{Mobile IP throughput statistics}
        \begin{tabular}{ | p{2.5cm} | p{2.5cm} | p{2.5cm} | }
            \hline Speed (km/hr) & Max (packets/sec) & Sample mean (packets/sec) \\
            \hline 20  & 261.67 &  209.05\\
            \hline 70  & 262.5  &  207.91\\
            \hline 80  & 259.58 &  209.03\\ 
            \hline 90  & 260.75 &  209.47\\
            \hline 100 & 260.33 &  209.3 \\
            \hline 120 & 262.42 &  210.4 \\
            \hline 160 & 259.08 &  210.29\\                 
            \hline
        \end{tabular}
        
        \label{table:table3}
    \end{center}
\end{table}

Please tell me how to make the values in this table to appear in the centre.

\begin{table}[h]
    \begin{center}
\caption{Mobile IP throughput statistics}
        \begin{tabular}{ | p{2.5cm} | p{2.5cm} | p{2.5cm} | }
            \hline Speed (km/hr) & Max (packets/sec) & Sample mean (packets/sec) \\
            \hline 20  & 261.67 &  209.05\\
            \hline 70  & 262.5  &  207.91\\
            \hline 80  & 259.58 &  209.03\\ 
            \hline 90  & 260.75 &  209.47\\
            \hline 100 & 260.33 &  209.3 \\
            \hline 120 & 262.42 &  210.4 \\
            \hline 160 & 259.08 &  210.29\\                 
            \hline
        \end{tabular}
        
        \label{table:table3}
    \end{center}
\end{table}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薆情海 2024-11-23 04:58:46

这是一种方法。但这可能不是“正确”的方式:

\begin{tabular}{ | p{2.5cm} | p{2.5cm} | p{2.5cm} | }
  \hline \centering  Speed (km/hr) & Max (packets/sec) & Sample mean (packets/sec) \\
  \hline \centering  20 & \centering 261.67 & 209.05 \\
  \hline \centering  70 & \centering 262.5  & 207.91 \\
  \hline \centering  80 & \centering 259.58 & 209.03 \\ 
  \hline \centering  90 & \centering 260.75 & 209.47 \\
  \hline \centering 100 & \centering 260.33 & 209.3  \\
  \hline \centering 120 & \centering 262.42 & 210.4  \\
  \hline \centering 160 & \centering 259.08 & 210.29 \\                                 
  \hline
\end{tabular}

Here's one way. But it's probably not the "correct" way:

\begin{tabular}{ | p{2.5cm} | p{2.5cm} | p{2.5cm} | }
  \hline \centering  Speed (km/hr) & Max (packets/sec) & Sample mean (packets/sec) \\
  \hline \centering  20 & \centering 261.67 & 209.05 \\
  \hline \centering  70 & \centering 262.5  & 207.91 \\
  \hline \centering  80 & \centering 259.58 & 209.03 \\ 
  \hline \centering  90 & \centering 260.75 & 209.47 \\
  \hline \centering 100 & \centering 260.33 & 209.3  \\
  \hline \centering 120 & \centering 262.42 & 210.4  \\
  \hline \centering 160 & \centering 259.08 & 210.29 \\                                 
  \hline
\end{tabular}
好倦 2024-11-23 04:58:46

要让它更短一些,您还可以执行以下操作:

\usepackage{array} 放入您的头部,然后在 \begin{tabular} 表达式中编写以下:

\begin{tabular}{ | >{\centering}p{2.5cm} | >{\centering}p{2.5cm} | >{\centering}p{2.5cm} | }

不过,现在您必须使用 \tabularnewline 而不是 \\ 来声明新行。如果列的宽度不重要,您也可以直接使用,

\begin{tabular}{ |c|c|c| }

无需任何进一步的更改。

To have it a bit shorter, you could also do the following:

Put \usepackage{array} in your head, and in your \begin{tabular} expression, write the following:

\begin{tabular}{ | >{\centering}p{2.5cm} | >{\centering}p{2.5cm} | >{\centering}p{2.5cm} | }

Now you have to use \tabularnewline instead of \\ to declare a new line, though. If the width of your columns isn't important, you could also use

\begin{tabular}{ |c|c|c| }

without any further changes.

給妳壹絲溫柔 2024-11-23 04:58:46

tabularray 包可以轻松配置水平对齐方式:

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{table}[h]
    \begin{center}
        \caption{Mobile IP throughput statistics}
        \begin{tblr}{
          colspec={Q[2.5cm] Q[2.5cm] Q[2.5cm]},
          columns={halign=c},
          vlines,
          hlines
        }
          Speed (km/hr) & Max (packets/sec) & Sample mean (packets/sec) \\
          20  & 261.67 &  209.05\\
          70  & 262.5  &  207.91\\
          80  & 259.58 &  209.03\\ 
          90  & 260.75 &  209.47\\
          100 & 260.33 &  209.3 \\
          120 & 262.42 &  210.4 \\
          160 & 259.08 &  210.29\\                 
        \end{tblr}
        \label{table:table3}
    \end{center}
\end{table}

\end{document}

The tabularray package makes it easy to configure the horizontal alignment:

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{table}[h]
    \begin{center}
        \caption{Mobile IP throughput statistics}
        \begin{tblr}{
          colspec={Q[2.5cm] Q[2.5cm] Q[2.5cm]},
          columns={halign=c},
          vlines,
          hlines
        }
          Speed (km/hr) & Max (packets/sec) & Sample mean (packets/sec) \\
          20  & 261.67 &  209.05\\
          70  & 262.5  &  207.91\\
          80  & 259.58 &  209.03\\ 
          90  & 260.75 &  209.47\\
          100 & 260.33 &  209.3 \\
          120 & 262.42 &  210.4 \\
          160 & 259.08 &  210.29\\                 
        \end{tblr}
        \label{table:table3}
    \end{center}
\end{table}

\end{document}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文