3

I am trying to make a table but I face a few predicaments. The code I have written is so far:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage[table]{xcolor}
\definecolor{mycolor}{RGB}{0, 85, 128}
\definecolor{mycolor1}{RGB}{255, 85, 128}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{2.5}
\begin{document}



\newcolumntype{s}{>{\columncolor[HTML]{AABBED}} p{2cm}}

\arrayrulecolor{mycolor1}

\begin{tabular}{ |s|p{1.3cm}|p{1.3cm}||p{1.3cm}||p{1.3cm}||p{1.3cm}||p{1.3cm}| }

    \hline
    \rowcolor{mycolor} \multicolumn{6}{|c|}{Country List} \\
    \hline
    Authors&Energy Efficient&Network Efficient&Performance Increase&Power Efficient&Workload Balancing\\
    \hline
    Afghanistan & AF &AFG&A&b&c \\
%   \rowcolor{gray}
    Aland Islands & AX & ALA&A&b&c  \\
    Albania   &AL & ALB&A&b&c  \\
    Algeria  &DZ & DZA&A&b&c  \\
    American Samoa & AS & ASM&A&b&c  \\
    Andorra & AD & AND&A&b&c \\%\cellcolor[HTML]{AA0044} AND    \\
    Angola & AO & AGO&A&b&c  \\
    \hline
\end{tabular}
\end{document}

which results in the follwing: enter image description here

I want to make the following changes:

  1. Resize the table in such a way that it is just in the middle of the page
  2. Double column separator line. It should be single like the rest of the table, see figure:

enter image description here

1

Two main suggestions:

  • To make the table fit inside the width of the textblock, (a) use a tabularx environment instead of a tabular environment and (b) prefix a \noindent instruction to the tabularx environment.

  • To avoid getting double vertical lines, change all instances of || to |.

Some further suggestions:

  • Center the entries in the five (not six) data columns.

  • Allow hyphenation of long words in the header cells.

  • Your settings for the parameters \arraystretch and \tabcolsep seem overly generous. Smaller values work better, I'd say.

These suggestions are implemented in the following, revised version of your code.

enter image description here

The color you've chosen for the header row that contains the words "Country List" definitely seems to dark. I have no idea what color schemes you are allowed (or required) to implement, but I trust you'll manage to come up with a color for the header row that makes it easier to read the words "Country List".

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[table]{xcolor}
\definecolor{mycolor}{RGB}{0, 85, 128}    % maybe too dark?
\definecolor{mycolor1}{RGB}{255, 85, 128}
\arrayrulecolor{mycolor1}

\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{4pt}     % 18pt seems extravagant
\renewcommand{\arraystretch}{2} % 2.5 seems excessive

\usepackage{tabularx,ragged2e}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\newcolumntype{s}{>{\columncolor[HTML]{AABBED}\raggedright}p{2cm}}

\begin{document}

\noindent % <-- important
\begin{tabularx}{\textwidth}{ |s| *{5}{C|} }
\hline
    \rowcolor{mycolor} \multicolumn{6}{|c|}{Country List} \\
\hline
   Authors & Energy Efficient & Network Efficient & Performance Increase
   & Power Efficient & Workload Balancing\\
\hline
    Afghanistan    & AF &AFG&A&b&c \\
    %   \rowcolor{gray}
    Aland Islands  & AX & ALA&A&b&c  \\
    Albania        & AL & ALB&A&b&c  \\
    Algeria        & DZ & DZA&A&b&c  \\
    American Samoa & AS & ASM&A&b&c  \\
    Andorra        & AD & AND&A&b&c \\%\cellcolor[HTML]{AA0044} AND    \\
    Angola         & AO & AGO&A&b&c  \\
\hline
\end{tabularx}

\end{document} 
1

You have physical constraints, text width and size of each box around each letter + empty space padding.

Anyway, to get started:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage[table]{xcolor}
\definecolor{mycolor}{RGB}{0, 85, 128}
\definecolor{mycolor1}{RGB}{255, 85, 128}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{2.5}
\begin{document}



\newcolumntype{s}{>{\columncolor[HTML]{AABBED}} p{2cm}}

\arrayrulecolor{mycolor1}


\begin{tabular}{ |s|p{.06\textwidth}|p{.06\textwidth}|p{.06\textwidth}|p{.06\textwidth}|p{.06\textwidth}|p{.06\textwidth}| }

    \hline
    \rowcolor{mycolor} \multicolumn{6}{|c|}{Country List} \\
    \hline
    Authors&Energy Efficient&Network Efficient&Performance Increase&Power Efficient&Workload Balancing\\
    \hline
    Afghanistan & AF &AFG&A&b&c \\
%   \rowcolor{gray}
    Aland Islands & AX & ALA&A&b&c  \\
    Albania   &AL & ALB&A&b&c  \\
    Algeria  &DZ & DZA&A&b&c  \\
    American Samoa & AS & ASM&A&b&c  \\
    Andorra & AD & AND&A&b&c \\%\cellcolor[HTML]{AA0044} AND    \\
    Angola & AO & AGO&A&b&c  \\
    \hline
\end{tabular}


\end{document}
  • Does your code ensure that the tabular material fits inside the width of the textblock? – Mico Nov 21 '17 at 7:24
  • Your answer is correct and there is no mistake at all. but I had to mark @Mico right because his is the one I want. – Saad Nov 21 '17 at 7:34
  • 2
    Yea totally! Mico‘s answer makes mine look weak. I whipped it up on the train (hence -to get started-). :) I can add some tips later anyway for posterity, because I used to have these problems. – Jonathan Komar Nov 21 '17 at 7:36

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.