开发者

How to align times by their colon in a LaTeX-tabular?

开发者 https://www.devze.com 2022-12-22 14:45 出处:网络
I have a tabular of the times I 开发者_StackOverflow中文版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 co

I have a tabular of the times I 开发者_StackOverflow中文版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?


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

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


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}


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}
0

精彩评论

暂无评论...
验证码 换一张
取 消