![具有不同水平对齐方式的表格](https://linux22.com/image/368918/%E5%85%B7%E6%9C%89%E4%B8%8D%E5%90%8C%E6%B0%B4%E5%B9%B3%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F%E7%9A%84%E8%A1%A8%E6%A0%BC.png)
我想要一个包含三列的简单表格,其中第一列左对齐,第二列居中对齐,最后一列右对齐。为此,我尝试使用,tabularx
但我无法让它工作。这是 MWE:
\documentclass{article}
\usepackage{tabularx}
\usepackage{hyperref}
\begin{document}
\begin{tabularx}{\linewidth}{>{\raggedright}m{0.33\linewidth}>{\centering}m{0.33\linewidth}>{\raggedleft}m{0.33\linewidth}}
{\Large First Author} & {\Large Second Author} & {\Large Third Author} \\
{ First Institution, which can be very long} & {Second Institution, which can also be very long} & {Third Institution, which can be very long as well and I need to prevent hyphenation} \\
\href{mailto:[email protected]}{[email protected]} & \href{mailto:[email protected]}{[email protected]} & \href{mailto:[email protected]}{[email protected]} \\
\end{tabularx}
\end{document}
机构名称太长,所以我不能用连字符连接。我做错了什么?
答案1
你应该:
tabularx
如果没有列则不能使用X
(这里不需要)- 使用
\arraybackslash
- 也许可以减少列宽,因为它可能会加起来大于文本宽度
梅威瑟:
\documentclass{article}
\usepackage{array}
\usepackage{hyperref}
\begin{document}
\begin{tabular}{>{\raggedright\arraybackslash}m{0.33\linewidth}>{\centering\arraybackslash}m{0.33\linewidth}>{\raggedleft\arraybackslash}m{0.33\linewidth}}
{\Large First Author} & {\Large Second Author} & {\Large Third Author} \\
{ First Institution, which can be very long} & {Second Institution, which can also be very long} & {Third Institution, which can be very long as well and I need to prevent hyphenation} \\
\href{mailto:[email protected]}{[email protected]} & \href{mailto:[email protected]}{[email protected]} & \href{mailto:[email protected]}{[email protected]} \\
\end{tabular}
\end{document}
或者,您可以使用tabularx
(优点:自动列宽),然后使用重新定义的列类型X
:
\documentclass{article}
\usepackage{tabularx}
\usepackage{hyperref}
\begin{document}
\begingroup
\renewcommand*{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash}X>{\centering\arraybackslash}X>{\raggedleft\arraybackslash}X}
{\Large First Author} & {\Large Second Author} & {\Large Third Author} \\
{ First Institution, which can be very long} & {Second Institution, which can also be very long} & {Third Institution, which can be very long as well and I need to prevent hyphenation} \\
\href{mailto:[email protected]}{[email protected]} & \href{mailto:[email protected]}{[email protected]} & \href{mailto:[email protected]}{[email protected]} \\
\end{tabularx}
\endgroup
\end{document}