![将表格置于单元格边界的中心吗?](https://linux22.com/image/352073/%E5%B0%86%E8%A1%A8%E6%A0%BC%E7%BD%AE%E4%BA%8E%E5%8D%95%E5%85%83%E6%A0%BC%E8%BE%B9%E7%95%8C%E7%9A%84%E4%B8%AD%E5%BF%83%E5%90%97%EF%BC%9F.png)
我有下表:
\documentclass[ebook]{memoir}
\begin{document}
\begin{center}
\begin{tabular}{rl}
First edition: & 2014 \\
Second edition: & 2015 \\
Third edition: & 2017 \\
\end{tabular}
1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1
center
\end{center}
\end{document}
我希望表格以 & 为中心,而不是以表格宽度为中心。从技术上讲,它会偏离中心,但视觉上看起来更好(空白处将位于 0 上方)。
有没有一种简单的方法可以做到这一点,而无需缩小页面并手动调整?
答案1
eqparbox
将\eqmakebox[<tag>][<align>]{<stuff>}
所有的集合<stuff>
放在<tag>
相同宽度的盒子中。此外,您可以指定<align>
适合您需求的选项:
\documentclass{article}
\usepackage{eqparbox}
\begin{document}
\begin{center}
\begin{tabular}{ r | l }
First edition: & 2014 \\
\eqmakebox[widest][r]{Second edition:} & \eqmakebox[widest][l]{2015} \\
Third edition: & 2017
\end{tabular}
1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1
\end{center}
\end{document}
由于此过程使用文件,因此每次更改(框的宽度)时都.aux
需要至少两次编译。<stuff>
答案2
像这样?
\documentclass[ebook]{memoir}
\begin{document}
\begin{tabularx}{0.8\linewidth}{>{\raggedleft}XX}
First edition: & 2014 \\
Second edition: & 2015 \\
Third edition: & 2017 \\
\multicolumn{2}{c}{1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1}\\
\multicolumn{2}{c}{center}
\end{tabularx}
\end{document}
**Edit:**
Ups! At upload of codes I by mistake load the same code twice. The second one should be as in now the code above. With comparison of result of Werner and my solution I don't see any difference (above is Werner solution, below is my):
\documentclass{memoir}
\usepackage{eqparbox}
\usepackage{showframe}
\begin{document}
\begin{center}
\begin{tabular}{ r | l }
First edition: & 2014 \\
\eqmakebox[widest][r]{Second edition:} & \eqmakebox[widest][l]{2015} \\
Third edition: & 2017
\end{tabular}
1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1
\begin{tabularx}{.8\linewidth}{>{\raggedleft}XX}
First edition: & 2014 \\
Second edition: & 2015 \\
Third edition: & 2017 \\
\end{tabularx}
\end{center}
\end{document}[![enter image description here][2]][2]