I am trying to write a macro which will allow me to place work / educational experiences neatly on a page for a CV. To do this, I have designed a table, with three columns, and total width = \textwidth.

The text in the first and second columns should be left-aligned, the text in the last column should be right aligned. Importantly, the text in the middle columns should be aligned for all tables in the document. Currently, the text in the middle columns seems to float and is not aligned across the tables in the document.

Assuming this is due to dynamic column widths, how can I force a specific width (e.g. 30% of \textwidth) to the left-column, so that the middle column will be aligned across all tables?

The macro should be able to be saved separately in a .sty file, and loaded into a .tex document of \documentclass{article}.

My LaTeX macro below:

% Define a macro to build a table (4 args: dates, institution, position, description)

% Put the first three args in a table
    \textbf{#1} & \textbf{#2} & \textbf{#3}

% Description with no hanging and in smaller text
\noindent \small #4

% Back to normal size
\normalsize \par

% Some space
  • 2
    Welcome to tex.sx. It's also necessary to know what document class you're using, since that may also define some things affecting what you're trying to do, For best results, provide a small compilable example that shows what you're getting now. It should begin with \documentclass and end with \end{document}. Then a potential helper will have something to experiment with, without guessing. Dec 11, 2022 at 15:32
  • Thanks Barbara.. I added the documentclass now. The issue is more to do with the way that table sizings are calculated in tabular vs tabular*; I think I might require some functionality from both (ability to set the total width alongside the ability to set individual column widths). I think it might also be helpful, whilst designing this, to see the table lines drawn.
    – Zac
    Dec 11, 2022 at 16:51

1 Answer 1


The following might be more in line with what you're after:

enter image description here



% Define a macro to build a table (4 args: dates, institution, position, description)
\NewDocumentCommand{\education}{ m m m m }{
  % Put the first three args in a table
  \noindent\begin{tabularx}{\linewidth}{@{} p{.15\linewidth} X wr{.2\linewidth} @{} }
    \bfseries #1% Date 
      & \bfseries #2% Institution
      & \bfseries #3% Position
  % Description with no hanging and in smaller text
  \noindent{\small #4\par}%
  % Some space


  {Date 1}{Institution 1}{Position 1}{Lorem ipsum}

  {Date 2}{Instituion 2 Institution}{Position 2}{Lorem ipsum}


The main suggestion would be to consider using tabularx for spreading paragraph-style columns with dynamic widths across the remainder of your table width via an X-column. So, specify the known/fixed-width content using p{<len>} or wr{<len>} (fixed-width, right-aligned) and insert X for the column you want an automatic width calculation to fill the table.

  • Thanks Werner, that looks good. But sorry I should have mentioned that in fact I am trying to store this macro (and others) in a separate .sty file. Will this still work given the references to \linewidth?
    – Zac
    Dec 11, 2022 at 17:32
  • @Zac: Sure; the table with - \linewidth - will be established at the time of the call, which would depend on where it's placed in your document, not whether it's placed in a .sty.
    – Werner
    Dec 11, 2022 at 17:40
  • I am unable to compile this: I get "..../macros.sty:114: LaTeX Error: Missing \begin{document}.". I don't see why it want's a document in the .sty file? (There is a \begin{document} in the .tex file).
    – Zac
    Dec 11, 2022 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .