如何在 LaTeX 表格中按冒号对齐时间?

发布于 2024-08-24 15:17:26 字数 101 浏览 3 评论 0原文

我有一个我在 LaTeX 中的时间表格。

这些时间的形式为 4:00 或 12:00,且长度不同。我想通过冒号垂直对齐这些时间。 LaTeX 有没有好的方法可以做到这一点?

I have a tabular of the times I in LaTeX.

These times are in the form 4:00 or 12:00 and this have different lengths. I would like to vertically align these times by their colon. Is there a nice way to do this in LaTeX?

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

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

发布评论

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

评论(3

听你说爱我 2024-08-31 15:17:26

您可以使用 @{},或者在您的情况下使用 @{:} 作为列分隔符。

\begin{tabular}{l|r@{:}l}
  first & 12 & 00 \\
  second & 4 & 00 \\
\end{tabular}

You can use @{}, or in your case @{:} as a column delimiter.

\begin{tabular}{l|r@{:}l}
  first & 12 & 00 \\
  second & 4 & 00 \\
\end{tabular}
尛丟丟 2024-08-31 15:17:26

或多或少像这样:

\begin{tabular}{r@{:}l}
12&44\\
2&01\\
22&11
\end{tabular}

您可能想在“:”周围引入一些非常小的空格,例如 \hspace{1pt}

More or less like this:

\begin{tabular}{r@{:}l}
12&44\\
2&01\\
22&11
\end{tabular}

You may want to introduce some very small space around the ":", like \hspace{1pt}

友欢 2024-08-31 15:17:26

您可以使用该包
\usepackage{dcolumn}

通常您使用它来对齐浮点数,但是如果您将分隔符定义为 : 并将位数定义为 2 ,则可以使用它

\begin{tabular}{D{:}{:}{2}cc}
7:44 & wake-up & home\\
13:01 & meeting & work\\
20:00 & movie & home
\end{tabular}

You can use the package
\usepackage{dcolumn}.

Normaly you use it to align floating numbers, but you can use it if you define the delimiter as : an the number of digits as 2

\begin{tabular}{D{:}{:}{2}cc}
7:44 & wake-up & home\\
13:01 & meeting & work\\
20:00 & movie & home
\end{tabular}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文