[Tex/LaTex] Reducing space between columns manually

spacingtables

I'm working on a table in report documentclass. Here's some of my code below:

\documentclass[12pt]{report}

\usepackage[table]{xcolor} 

\setlength{\arrayrulewidth}{1mm}

\renewcommand{\arraystretch}{1.5} 


\begin{document}


\begin{table}
\begin{tabular}{l p{6cm} c m{3cm} r m{3cm}  }
\hline \\ 
 Country &   Parameter A & Parameter B  \\ [0.5ex]
\hline 

Quantity of x  &    0.8   & 25.6  \\ 

Quantity of y  &    100   & 9.4   \\  

Quantity of z  &    10    & 12.6   \\ 

Quantity of a  &  100   & 30    \\ 




\hline
\end{tabular}
\caption{Table 1}

\end{table}

\end{document}

My problem is that columns 2 and 3 are too wide apart. How can I get them to be a little closer together whilst giving more space to column 1 as I have more writing to do in column 1? I've read quite a lot of answers online and on this forum but I guess I'm missing something very fundamental here. I've played around a lot with \begin{tabular}{l p{6cm} c m{3cm} r m{3cm} } but all to no avail.

Best Answer

As mentioned in comment, you have declared too many columns in your table. I deleted three of them. If you want to write long text in one column, you may use a p{width} column in order to control it to your needs.

Here is your table how I would recommend to type it:

% arara: pdflatex

\documentclass[12pt]{report}
\usepackage{lmodern}
\usepackage{microtype} % for better kerning in narrow columns
\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}

\begin{document}    
    \begin{table}
        \centering
        \begin{tabular}{p{3cm}S[table-format=3.1]S[table-format=2.1]} % adapt this 3cm to your needs
            \toprule 
            Country         & {Parameter A} & {Parameter B} \\
            \midrule            
            Quantity of $x$ & 0.8           & 25.6          \\          
            Quantity of $y$ & 100           & 9.4           \\              
            Quantity of $z$ & 10            & 12.6          \\                      
            Quantity of $a$ and some more writing if you like & 100 & 30 \\             
            \bottomrule
        \end{tabular}
        \caption{Table 1}       
    \end{table} 
\end{document}

enter image description here

I included the package microtype here in order to get a better kerning in narrow cells with long text. If you are having that much space, you could just adapt the width of the first column until it looks nice to you. If you are getting ugly results like in my screenshot or if you want all the "Quantity of..." aligned horizontally, you should make the last cell (or the first row) ragged right (thanks to Barbara Beeton for this objection).

This could look like \multicolumn{1}{>{\raggedright}p{3cm}}{Quantity of $a$ and some more writing if you like}, which yields:

enter image description here

Related Question