0

I have a two-column tabular* environment and I wish to automatically adjust the width of the first cell of each row to its content. How do I remove the horizontal space "x" in the attached image?

MWE is as follows:

\documentclass{article} % 
\usepackage{tabularx}
\usepackage{blindtext}
\setlength\tabcolsep{1pt}
\newenvironment{twenty}{%
    \begin{tabular*}
    {\textwidth}{ll}}{%
    \end{tabular*}}
\newcommand{\twentyitem}[4]{%
{#1}&\parbox[t]{0.75\textwidth}{%
        \textbf{#2}%
        \hfill%
        {#3}\\%
        #4\vspace{\parsep}}\\}

\begin{document}
\begin{twenty}
    \twentyitem{2017 Sept~-~%\dots
    a very long date here}{ABC Position}{City, Country}%
    {\blindtext}    
    \twentyitem{2015 May~-~%\dots
    2017 Sept}{XYZ Position}{City, Country}%
    {\blindtext}    
\end{twenty}    
\end{document}

enter image description here

  • 1
    In my opinion, that is not a good way to write a CV. – user156344 Apr 6 '19 at 8:26
  • \begin{tabular*}{\textwidth}{ll}} can not work, you are specifying the table be stretched but adding no flexibility. If you use tabular* you have to use \extracolsep to add stretchy space between the columns. – David Carlisle Apr 6 '19 at 9:51
2

Here is a solution using a new tabularx environment for every entry:

\documentclass{article}
\usepackage{tabularx}
\usepackage{blindtext}

\newcommand{\myentry}[4]{\begin{tabularx}{\textwidth}{lX}#1 & \textbf{#2} \hfill #3 \newline #4 \\ \end{tabularx}}

\begin{document}
\noindent
\myentry{2017 Sept - a very long date here}{ABC position}{City, Country}{\blindtext}
\myentry{2015 May~-~2017 Sept}{XYZ Position}{City, Country}{\blindtext}
\end{document}

enter image description here

| improve this answer | |
2

I would use right alignment for the first column.

\documentclass{article} %
\usepackage{tabularx}
\usepackage{blindtext}
\setlength\tabcolsep{1pt}
\newenvironment{twenty}{%
    \begin{tabular*}
    {\textwidth}{rl}}{%
    \end{tabular*}}
\newcommand{\twentyitem}[4]{%
{#1}&\parbox[t]{0.75\textwidth}{%
        \textbf{#2}%
        \hfill%
        {#3}\\%
        #4\vspace{\parsep}}\\}

\begin{document}
\begin{twenty}
    \twentyitem{2017 Sept~-~%\dots
    a very long date here}{ABC Position}{City, Country}%
    {\blindtext}
    \twentyitem{2015 May~-~%\dots
    2017 Sept}{XYZ Position}{City, Country}%
    {\blindtext}
\end{twenty}
\end{document} 

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.