[Tex/LaTex] How to make such a nice table in LaTeX

tables

Below is an example, it seems rather complex for me. I can only make a table with dark lines, and don't know how to make the dark lines hollow ones.

Is there a way to embed such a fancy table in LaTeX?

enter image description here

Best Answer

Here is why every one says " get rid of vertical lines". Double lines everywhere add further to disaster.

\documentclass{article}
\usepackage{hhline}
\usepackage{caption}
\usepackage{booktabs}
\begin{document}
\begin{table}[htb]
\centering
\sffamily
\captionsetup{font={bf,sf},skip=0.5ex}
\caption*{Access Levels}
\begin{tabular}{||*{5}{l||}}
\hhline{|t:=:t:=:t:=:t:=:t:=:t|}
 \bfseries Modifier              & \bfseries Class & \bfseries Package & \bfseries Subclass & \bfseries World \\
\hhline{|:=::=::=::=::=:|}
\texttt{public}                  & Y               & Y                 & Y                  & Y               \\
\hhline{|:=::=::=::=::=:|}
\texttt{protected}               & Y               & Y                 & Y                  & N               \\
\hhline{|:=::=::=::=::=:|}
\itshape no modifier             & Y               & Y                 & N                  & N               \\
\hhline{|:=::=::=::=::=:|}
\texttt{private}                 & Y               & N                 & N                  & N               \\
\hhline{|b:=:b:=:b:=:b:=:b:=:b|}                                                                              
\end{tabular}
\end{table}

\begin{table}[htb]
\centering
\sffamily
\captionsetup{font={bf,sf},skip=0.5ex}
\caption*{Access Levels}
\begin{tabular}{l*{4}{c}}
\toprule
 \bfseries Modifier  & \bfseries Class & \bfseries Package & \bfseries Subclass & \bfseries World \\
\midrule
\texttt{public}      & Y               & Y                 & Y                  & Y               \\
\texttt{protected}   & Y               & Y                 & Y                  & N               \\
\itshape no modifier & Y               & Y                 & N                  & N               \\
\texttt{private}     & Y               & N                 & N                  & N               \\ \bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

Decide yourself which one looks good. I like the second one.

As noted by touhami, adding \setlength\tabcolsep{1pt} produces a look more similar to the image in the question, but it is cramped IMO.

You may want to use colours to make Y and N conspicuous.

\documentclass{article}
\usepackage{hhline}
\usepackage{caption}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\newcommand*{\myred}{\cellcolor{red!50}}
\newcommand*{\mygreen}{\cellcolor{green!50}}
\newcommand*{\mycolor}{\cellcolor{olive!40}}
\begin{document}
\begin{table}[htb]
\arrayrulecolor{white}
\doublerulesepcolor{gray!20}
\centering
\sffamily
\captionsetup{font={bf,sf},skip=0.5ex}
\caption*{Access Levels}
\begin{tabular}{||*{5}{c||}}
\hhline{|t:=:t:=:t:=:t:=:t:=:t|}
\rowcolor{blue!30}
\bfseries Modifier               & \bfseries Class & \bfseries Package & \bfseries Subclass & \bfseries World \\ \hhline{|:=::=::=::=::=:|}
\mycolor\texttt{public}          & \mygreen Y      & \mygreen Y        & \mygreen Y         & \mygreen Y      \\
\hhline{|:=::=::=::=::=:|}
\mycolor\texttt{protected}       & \mygreen Y      & \mygreen Y        & \mygreen Y         & \myred N        \\
\hhline{|:=::=::=::=::=:|}
\mycolor\itshape no modifier     & \mygreen Y      & \mygreen Y        & \myred N           & \myred N        \\
\hhline{|:=::=::=::=::=:|}
\mycolor\texttt{private}         & \mygreen Y      & \myred N          & \myred N           & \myred N        \\
\hhline{|b:=:b:=:b:=:b:=:b:=:b|}
\end{tabular}
\end{table}

\end{document}

enter image description here

Related Question