1

I need to create an array like this with latex: enter image description here

I try by using this code by I failed:

\begin{table}
\begin{center}
\begin{tabular}{|l|c|}
  \hline
  Security mode & Security provided \\
  \hline
  \hline
  No Security & Data is not encrypted \\
  \hline
  AES-CBC-MAC-32 & Data is not encrypted\\
  \hline  
  AES-CBC-MAC-64 & Data is not encrypted\\
  \hline  
  AES-CBC-MAC-128 & Data is not encrypted\\
  \hline  
  AES-CTR & Data is encrypted\\
  \hline  
  AES-CCM-32 & Data is encrypted\\
  \hline  
  AES-CCM-64 & Data is encrypted\\
  \hline  
  AES-CCM-128 & Data is encrypted\\
  \hline
\end{tabular}

\caption{\label{tab:tab1}Security modes in the IEEE802.15.4e Standard.}
\end{center}
\end{table}
LonLon
  • 442
Sony
  • 37
  • The code works for me, it produces a table. What do you mean by "failed"? Do you get an error? What does the output look like? – LonLon Nov 09 '18 at 09:01
  • @FLonLon It works for me too, but i need to have the table in the figure. – Sony Nov 09 '18 at 09:02
  • @FLonLon I failed to have the same. – Sony Nov 09 '18 at 09:02
  • 1
    you mean the grey colour at the top? or the caption on the top instead of bottom? – LonLon Nov 09 '18 at 09:03
  • yes exactly, I want the same format – Sony Nov 09 '18 at 09:03
  • 2
    Ah, I see. You can find a solution to colour the cells here: https://tex.stackexchange.com/questions/94799/how-do-i-color-table-columns/ and you can move the caption to the top by literally just moving the \caption command before the \begin{tabular} – LonLon Nov 09 '18 at 09:05

1 Answers1

0

To achieve a table such as this, you need to adjust the following:

  1. Background colour of the top row. Packages: xcolor + colortbl
  2. The double horizontal line at the top. Package: hhline
  3. The format of the caption. Package: caption

You define a light grey colour with \definecolor{mygrey}{rgb}{211,211,211} and in the table you then use \rowcolor{mygrey}. The double horizontal lines are achieved by using \hhline{==}. The caption is formatted through two commands:

  1. \captionsetup{justification=centering,singlelinecheck=false,labelfont=sc,labelsep = newline} It centers the caption, turns font into small-caps, and provides a new line after the name
  2. \renewcommand*\thetable{\Roman{table}} This changes the table numbering to Roman numerals.

This code will work:

\documentclass{article}
\usepackage{xcolor,colortbl,hhline,caption}
\definecolor{mg}{RGB}{211,211,211}
\captionsetup{justification=centering,singlelinecheck=false,labelfont=sc,labelsep = newline}
    \renewcommand*\thetable{\Roman{table}}
\begin{document}
\begin{table}
    \begin{center}
    \caption{\label{tab:tab1}
    \scshape{{Security modes in the IEEE802.15.4e Standard.}}}
        \begin{tabular}{l|c}
            \hhline{==}
            \rowcolor{mg}
            Security mode & Security provided \\\hline
            \hhline{==}
            No Security & Data is not encrypted \\\hline
            AES-CBC-MAC-32 & Data is not encrypted\\\hline  
            AES-CBC-MAC-64 & Data is not encrypted\\\hline  
            AES-CBC-MAC-128 & Data is not encrypted\\\hline  
            AES-CTR & Data is encrypted\\\hline  
            AES-CCM-32 & Data is encrypted\\\hline  
            AES-CCM-64 & Data is encrypted\\\hline  
            AES-CCM-128 & Data is encrypted\\\hline
        \end{tabular}
    \end{center}
\end{table}
\end{document}

Output:

table formatted in the way the OP wants

LonLon
  • 442