具有不同水平对齐方式的表格

具有不同水平对齐方式的表格

我想要一个包含三列的简单表格,其中第一列左对齐,第二列居中对齐,最后一列右对齐。为此,我尝试使用,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}

相关内容