tabularx 自动换行并在多个表上对齐

tabularx 自动换行并在多个表上对齐

我发现这里解决自动换行问题的方法:

\documentclass{article}
\usepackage{tabularx}
\usepackage{listliketab}
\usepackage{lipsum} % only for this example
\begin{document}
\lipsum[2]
\medskip

\noindent
\begin{tabularx}{\linewidth}{@{}>{\bfseries}l@{\hspace{.5em}}X@{}}
    2009--present & very long text 1, very long text 2, very long text 3, very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10 \\
    2009          & Masters                                                                                                                                                                              \\
    2006          & Bachelors
\end{tabularx}

 \end{document}

现在我在同一页中有两个相似的表格,我想将它们在第一列后对齐。如何实现这一点?即我该如何修改上述命令?

答案1

p对第一列使用-column 类型:

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{ltablex}
\usepackage{lipsum} % only for this example
\begin{document}
\lipsum[2]
\medskip

\noindent
\begin{tabularx}{\linewidth}{@{}>{\bfseries}p{2.5cm}@{\hspace{.5em}}X@{}}
    2009--present & very long text 1, very long text 2, very long text 3, very long text 
    4, very long text 5, very long text 6, very long text 7, very long text 8, very long 
    text 9, very long text 10 \lipsum[5]\\
    2009          &  Masters  \\
    2006          & Bachelors \lipsum[6]
\end{tabularx}

\noindent
\begin{tabularx}{\linewidth}{@{}>{\bfseries}p{2.5cm}@{\hspace{.5em}}X@{}}
    2009          &  Masters  \\
    2006          & Bachelors \lipsum[6]
\end{tabularx}  
\end{document}

相关内容