# Adding new column to table

Given the following table, I would like to add a further column:

\begin{table}[H]
\begin{tabularx}{\textwidth}{|X|l|}
\hline

Total number of atoms & 426 \\
Number of electrons & 260 \\

\hline
\end{tabularx}
\caption{test }
\label{t:stats}
\end{table}


I assumed it would be something like:

\begin{table}[H]
\begin{tabularx}{\textwidth}{|X|l|}
\hline

Total number of atoms & 426 & 520 \\
Number of electrons & 260 & 118 \\

\hline
\end{tabularx}
\caption{test }
\label{t:stats}
\end{table}


..but this does not work. Thanks

• \begin{tabularx}{\textwidth}{|X|l|l|}. But why the X column? Just to make reading difficult? – egreg Mar 5 '18 at 18:28
• Did not know that it makes reading more difficult - how so? – Pegah Mar 5 '18 at 18:40
• It moves the data far from their description. So, unless typesetting in double column, I'd not do it. – egreg Mar 5 '18 at 18:46

That's because most tabular-and-friends require you to update the column specification as well:

\begin{tabular}{<col spec>}
\end{tabular}


or

\begin{tabularx}{<width>}{<col spec>}
\end{tabularx}


So, for adding another column to the right within your tabularx from

\begin{tabularx}{<width>}{ | X | l | }
\end{tabularx}


you would need (say)

\begin{tabularx}{<width>}{ | X | l | r | }

Here r/l/c/p{<len>} denotes a right/left/centre-aligned column, while p{<len>} fits a paragraph of width <len>. Other options are also available, depending on the packages you're loading.
• @Pegah: First, using tabularx puts the table as wide as <width>. If your row-wise content falls far short of <width>, it's better to just use a regular tabular (without a <width> specification). Second, here is how I'd post your table, using booktabs and without tabularx. – Werner Mar 5 '18 at 18:52