2

How do you create a comparison table like this?

enter image description here

In particular, the slanted labels that save space, and the circles / half-filled circles. These kinds of tables seem fairly common --- is there a special package for creating tables like this?

Also, I think there already is a question about exactly the same kind of table, but unfortunately it had a title as vague as this one, so I wasn't able to find it.

2
  • 3
    and what you try so far? questions "do-it-for-me" is not likely to be answered here. see, if package makecell can help you to type slanted text.
    – Zarko
    Jun 30, 2017 at 22:35
  • 3
    There's no dedicated package, as far as I know, but a number of packages that will let you build such tables: makecell, mentioned by @Zarko, array, rotating, booktabs, threeparttable and wasy for the half-filled bullets.
    – Bernard
    Jun 30, 2017 at 22:53

1 Answer 1

12

Here's a partial reconstruction of the table.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{booktabs}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{threeparttable}
\usepackage{wasysym}

\begin{document}
\begin{table}
\footnotesize
\newcommand*\rot[1]{\hbox to1em{\hss\rotatebox[origin=br]{-60}{#1}}}
\newcommand*\feature[1]{\ifcase#1 -\or\LEFTcircle\or\CIRCLE\fi}
\newcommand*\f[3]{\feature#1&\feature#2&\feature#3}
\makeatletter
\newcommand*\ex[9]{#1\tnote{#2}&#3&%
    \f#4&\f#5&\f#6&\f#7&\f#8&\f#9&\expandafter\f\@firstofone
}
\makeatother
\newcolumntype{G}{c@{}c@{}c}
\begin{threeparttable}
\caption{Table caption here}
\label{tab:features}
\begin{tabular}{@{}lc GG !{\kern1em} GGG !{\kern1em} GG@{}}
\toprule
Scheme  & Example & \multicolumn{6}{c}{Security Features} & \multicolumn{9}{c}{Usability} & \multicolumn{6}{c}{Adoption}\\
\midrule
% rotated items
&& \rot{Network MitM Prevented}
 & \rot{Operator MitM Prevented}
 & \rot{Operator MitM Detected}
 %
 & \rot{Operator Accountability}
 & \rot{Key Revocation Possible}
 & \rot{Privacy Preserving}
 %
 & \rot{Automatic Key Initialization}
 & \rot{Low Key Maintenance}
 & \rot{Easy Key Discovery}
 %
 & \rot{Easy Key Recover}
 & \rot{In-Band}
 & \rot{No Shared Secrets}
 %
 & \rot{Alert-less Key Renewal}
 & \rot{Immediate Enrollment}
 & \rot{Inattentive User Resistant}
 %
 & \rot{Multiple Key Support}
 & \rot{No Service Provider}
 & \rot{No Auditing Required}
 %
 & \rot{No Name Squatting}
 & \rot{Asynchronous}
 & \rot{Scalable}\\
\midrule
\ex{Opportunistic Encryption}{\dag*}{TCPCrypt}            {000}{002} {222}{222}{222} {222}{222}\\
\ex{+TOFU (Strict)}{\dag}{-}                              {111}{102} {222}{022}{022} {022}{222}\\
\ex{+TOFU}{\dag*}{TextSecure}                             {111}{102} {222}{222}{020} {022}{222}\\
\midrule
\ex{Key Fringerprint Verification}{\dag*}{Threema}        {222}{212} {000}{002}{000} {022}{222}\\
\ex{+Short Auth Strings (Out-of-Band}{\dag*}{SilentText}  {222}{212} {000}{002}{000} {002}{202}\\
\ex{+Short Auth Strings (In-Band/Voice/Video}{\dag*}{ZRTP}{222}{212} {000}{012}{000} {022}{202}\\
\ex{+Socialist Millionaire (SMP)}{\dag*}{OTR}             {222}{212} {000}{020}{000} {022}{202}\\
\ex{+Mandatory Verification}{\dag*}{SafeSlinger}          {222}{212} {000}{020}{022} {022}{202}\\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item \hfil$\feature2=\text{provides property}$; $\feature1=\text{partially provides property}$;
$\text{\feature0}=\text{does not provide property}$;
\item \hfil\textsuperscript{\dag}has academic publication;
\textsuperscript{*}end-user tool available
\end{tablenotes}    \end{threeparttable}

\end{table}

See~\ref{tab:features}.
\end{document}

enter image description here

Some comments.

  1. I defined \rot to handle rotating the slanted labels. It uses \rotatebox[origin=br]{-60} to rotate the label -60 degrees about the bottom right corner. That is placed inside an \hbox that's 1em wide with infinite shrinkability on the left so that the label protrudes out the left side of the box.
  2. I didn't want to type \LEFTcircle and \CIRCLE from the wasysym package over and over, so I defined \feature which takes a single argument (in this case, 0, 1, or 2) and produces the appropriate symbol. (Based on the footnotes, I probably should have called it \property instead.)
  3. The main part of the table is grouped into groups of 3 which are themselves grouped into 2 or 3 groups of 3. Using the array package, I created a new column type G (for group) that corresponds to three centered columns with no intercolumn space. I also defined \f which takes three digits and produces the three features (properties) for a group. (I probably should have gone with \g to stick with group rather than \f for features.)
  4. To get extra space between the groups of groups, I used the array specifier ! to insert an extra \kern1em between those columns.
  5. Each row logically consists of 10 parts: the scheme, the table note symbols, the example, and seven groups of 3. TeX only supports macros with up to 9 arguments, so when I created \ex (which was to stand for example, but on reflection, something related to scheme would have been better) which takes 9 arguments. The first 3 correspond to the scheme, marks, and example. The remaining 6 expect 3 digits to pass to \f. Finally, the 10th braced group is unbraced using \@firstofone and then passed to \f. I admit, that's kind of a hack, but it makes using \ex easier.
  6. threeparttable consists of a caption, the tabular, and the tablenotes below.
  7. The tabular itself is pretty straight-forward. I've used booktabs's \toprule, \midrule, and \bottomrule to typeset the horizontal rules. (This looks much better than \hline.)
  8. The table notes are centered in your example. I had to work a little bit to get that here. In particular, I added some \hfils. I think it would look better to not center the notes.
  9. Scheme is indented slightly for some reason in your example. I didn't understand the point of that, so I didn't do it. Adding \quad (or some other horizontal spacing command) could reproduce that.
  10. If I were creating this table, I would typeset the "Example" column left-aligned. I might also replace the - in that column with None or maybe just leave it blank. I'd probably also replace the - in the main columns with an en dash. I just think it looks better. Conveniently, you only have to replace - with -- in \feature to change it everywhere, including the table notes.

Some metacomments.

  1. To find individual symbols, you should look in the symbols-a4 document (run texdoc symbols-a4).
  2. Generally speaking, asking TeX SX to reproduce some particular image doesn't work out too well. (I was just curious to learn about threeparttable which I'd never used before so I took a stab at it.) Posting a minimal example demonstrating what you've tried and asking about particular elements you are stuck on works best. E.g., "How do I rotate the text in a cell of a table?"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .