[ACCEPTED]-Getting two tables in LaTeX to have the same (right-aligned) column width-tabular
If you use the array
package, you can put the 3 \hfill
in the header as follows, so you don't 2 have to remember to put it (or a \parbox
) in each 1 row.
\documentclass{article}
\usepackage{multicol}
\usepackage{array}
\begin{document}
\section{Work Experience}
\begin{tabular}{>{\hfill}p{5cm}|p{11cm}}
Current & Your job at Your Company, Town \\
Jan 2009 & What your company does \\
& A description of what you do\\
\multicolumn{2}{c}{}
\end{tabular}
\section{Education}
\begin{tabular}{>{\hfill}p{5cm}|p{11cm}}
Slightly wider first column & University, Town \\
Jan 2009 & Thesis subject \\
& A description of what you did\\
\multicolumn{2}{c}{}
\end{tabular}
\end{document}
to give:
alt text http://www.freeimagehosting.net/uploads/5e29f675e3.jpg
Here's a variant of @RTBarnard's answer 2 using the tabularx
package:
\documentclass[a4paper,twoside,draft,12pt]{article}
\usepackage{tabularx}
\begin{document}
\section{Work Experience}
\begin{tabularx}{\textwidth}{>{\raggedleft}X|p{8cm}}
Current & Your job at Your Company, Town \\
Jan 2009 & What your company does \\
& A description of what you do\\
\end{tabularx}
\section{Education}
\begin{tabularx}{\textwidth}{>{\raggedleft}X|p{8cm}}
Somewhat wider than first column,
overflowing into additional lines & University, Town \\
Jan 2009 & Thesis subject \\
& A description of what you did\\
\end{tabularx}
\end{document}
Notes:
- Why
tabularx
? Because it's often easier to know the width you have available for the whole table, and to let TeX calculate the unknown column widths. - The first parameter is the overall table width. Here, I've specified
\textwidth
to fill the width of typeblock, but you can change that to whatever measure you need. - I've used
\raggedright
rather than\hfill
: if the item flows onto a second line,\hfill
will only right-align the first line of the paragraph. - Was the
\multicol
significant? I've removed it to keep the answer as simple as possible.
Run with XeTeX 1 under TeXLive.
Here's one solution of many possibilities:
\begin{tabular}{r|p{11cm}}
\parbox{11cm}{\hfill Current} & Your job at Your Company, Town \\
Jan 2009 & What your company does \\
& A description of what you do\\
\multicolumn{2}{c}{}\
\end{tabular}
Basically, create 2 a \parbox
with the desired width and put an \hfill
at 1 the left.
You can give both p{width} options, and 1 start each cell in the left with an \hfill
.
You can use array
package to specify a fill command 1 for each row in your first column:
\begin{tabular}{>{\hfill}p{11cm}|p{11cm}|}
For example:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{>{\hfill}p{5cm}|p{11cm}|}
This is a test & test
\end{tabular}
\begin{tabular}{>{\hfill}p{5cm}|p{11cm}|}
Test & this is a test
\end{tabular}
\end{document}
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.