# tabularx automatic line break and aligned over several tables

I found here a solution to the problem of having an automatic line break:

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


Now I have two similar tables within the same page and would like to align them after the first column. How can this be achieved, i.e. how do I have to modify the above command?

• don't use tabularx just use a standard tabular with p{2cm}p{7cm} or whatever widths you need, then naturally all tables using that preamble will align. – David Carlisle Oct 31 '15 at 21:16
• @DavidCarlisle how can I use the automatic line break with tabular? – m. th Oct 31 '15 at 21:18
• @user8 - The p column type gives you automatic line breaks as well. In fact, the X column type is based on the p column type. – Mico Oct 31 '15 at 21:18

## 1 Answer

Using the p-column type for the first 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}