0

How do I create a table like this one: enter image description here

  • 2
    Hi user171766 and welcome to TeX.SX. In its current form, your question might not receive many answers. Please take a look at the How to Ask-page and try to improve your question according to the guidance found there. This may require you to show some effort on your part in terms of attempting a solution. If you have questions about what to do or if you don't quite understand what this means, please ask for clarification using the add comment function. – BambOo Oct 4 '18 at 15:53
2

Generally, we are not a document creation service. To get the best possible solution, it is best for you to show us what you are able to do. Also, there is usually not just one way to create a particular appearance: even a table can be created in quite a variety of ways.

Be that as it may, perhaps you don't even know how to get started. So, I'll give you some basic tools here to help you move forward. However, this is not a "solution" so much as a jumping off point for you. Using the details I present here, you will have the tools you need to create the desired table.

Creating a table using the tabular environment.

A tabular environment is a great place to start to creating a table like what you've shared with us. The basic syntax is as follows:

\begin{tabular}{<column_configuration_identifiers>}
  .... column content where individual columns are
       separated by `&` and each row ends with `\\`
\end{tabular}

Here's an example that illustrates some of these details

enter image description here

This was created with the following code:

\documentclass{article}
\usepackage[margin=1in]{geometry}

\begin{document}

\begin{tabular}{|l|c|r|}\hline
  Header 1 & Header 2 & Header 3 \\\hline
  \parbox[t]{2in}{%%
  ARMA virumque cano, Troiae qui primus ab oris
  Italiam, fato profugus, Laviniaque venit
  litora, multum ille et terris iactatus et alto
  vi superum saevae memorem Iunonis ob iram;
  multa quoque et bello passus, dum conderet urbem,
  inferretque deos Latio, genus unde Latinum,
  Albanique patres, atque altae moenia Romae.}
  &
  \parbox[t]{2in}{%%
    Musa, mihi causas memora, quo numine laeso,
    quidve dolens, regina deum tot volvere casus
    insignem pietate virum, tot adire labores
    impulerit.  Tantaene animis caelestibus irae?}
  & 
  \parbox[t]{2in}{\centering
    Urbs antiqua fuit, Tyrii tenuere coloni,
    Karthago, Italiam contra Tiberinaque longe
    ostia, dives opum studiisque asperrima belli;
    quam Iuno fertur terris magis omnibus unam
    posthabita coluisse Samo; hic illius arma,
    hic currus fuit; hoc regnum dea gentibus esse,
    si qua fata sinant, iam tum tenditque fovetque.
  }
  \\\hline  
\end{tabular}

\end{document}

Granted, it's not quite the appearance you want, but it does show you what you can do.

Details regarding this example

There are a variety of column style identifiers:

  • l aligns the content of each cell in the given column on the left.
  • c centers all entries in the column
  • r aligns the content of each cell in the column to the right.
  • | indicates that a vertical line should be drawn between the columns

There are some other styles, but I'll hold off on mentioning them until further down.

Your table content seems to have "paragraphs" of information in each of the columns. One approach to handling this is to use a \parbox. It's basic syntax is

\parbox[<optional_alignment_identifier>]{<width>}{<content>}

Within the \parbox the alignment specified by the tabular header is disregarded.

There is a column identifier p which indicates that each cell of the column is to be formatted as a paragraph. The syntax is

p{<width>}

The above table could have been created with the following code:

\begin{tabular}{|p{2in}|p{2in}|p{2in}|}\hline
  Header 1 & \hspace{\fill} Header 2 \hspace{\fill} & \hspace{\fill} Header 3 \\\hline
    ARMA virumque cano, Troiae qui primus ab oris
    Italiam, fato profugus, Laviniaque venit
    litora, multum ille et terris iactatus et alto
    vi superum saevae memorem Iunonis ob iram;
    multa quoque et bello passus, dum conderet urbem,
    inferretque deos Latio, genus unde Latinum,
    Albanique patres, atque altae moenia Romae.
  &
    Musa, mihi causas memora, quo numine laeso,
    quidve dolens, regina deum tot volvere casus
    insignem pietate virum, tot adire labores
    impulerit.  Tantaene animis caelestibus irae?
  & 
    Urbs antiqua fuit, Tyrii tenuere coloni,
    Karthago, Italiam contra Tiberinaque longe
    ostia, dives opum studiisque asperrima belli;
    quam Iuno fertur terris magis omnibus unam
    posthabita coluisse Samo; hic illius arma,
    hic currus fuit; hoc regnum dea gentibus esse,
    si qua fata sinant, iam tum tenditque fovetque.
  \\\hline  
\end{tabular}

Creating lists

It would be well worth your time to read up on list environments. I'll illustrate enumitem.

In the preamble, you can call the package

\usepackage{enumitem}

And then you can create a new list as follows:

\newlist{mylist}{itemize}{4}
\setlist[mylist]{%%
  label=$\diamond$,
  topsep=0pt,
  itemsep=0pt,
  parsep=0pt, 
  labelwidth=*,
  leftmargin=8pt,
  labelindent=6pt,
 }

Using this I can create a list as follows:

hic currus fuit; hoc regnum dea gentibus esse,
si qua fata sinant, iam tum tenditque fovetque.
\begin{mylist}
  \item Hello
  \begin{mylist}
    \item apple
    \item banana
    \item carp
  \end{mylist}
  \item world
\end{mylist}

which creates:

enter image description here

Now what?

You now have all the tools you need to create the table you want. See what you can put together.

What to do if you still get stuck

Post a new question and show us what you've been able to put together. We'll be happy to help you.

1

Typing in such a table can be boring and it's more fun to define a handy syntax for the purpose.

The headers are given as an argument to \begin{columntabular}. Next each column is typed in, with each item prefixed by \lv[<number>] that states the level of indentation.

At the end of a column, the \nextcolumn command should be inserted.

\documentclass{article}
\usepackage{xparse,environ}

\ExplSyntaxOn

\NewEnviron{columntabular}[1]
 {% #1 is the list of headers
  \egreg_coltab:nV { #1 } \BODY
 }

\NewDocumentCommand{\lv}{O{0}}
 {
  \bool_if:NTF \l_egreg_coltab_start_bool
   { \bool_set_false:N \l_egreg_coltab_start_bool }
   { \\ \hspace*{#1em} }
  \ignorespaces
 }

\bool_new:N \l_egreg_coltab_start_bool
\seq_new:N \l_egreg_coltab_header_seq
\seq_new:N \l_egreg_coltab_columns_seq
\seq_new:N \l_egreg_coltab_body_seq

\cs_new_protected:Nn \egreg_coltab:nn
 {
  \cs_set_eq:NN \par \scan_stop:
  % gather the header
  \seq_set_split:Nnn \l_egreg_coltab_header_seq { & } { #1 }
  % gather the body
  \seq_set_split:Nnn \l_egreg_coltab_columns_seq { \nextcolumn } { #2 }
  % massage the body
  \seq_clear:N \l_egreg_coltab_body_seq
  \seq_map_inline:Nn \l_egreg_coltab_columns_seq
   {
    \seq_put_right:Nn \l_egreg_coltab_body_seq
     {
      \begin{tabular}[t]{@{}l@{}}
      \bool_set_true:N \l_egreg_coltab_start_bool
      ##1
      \end{tabular}
     }
   }
  % produce the table
  \begin{tabular}{| *{\seq_count:N \l_egreg_coltab_header_seq}{l|}}
  \hline
  \seq_use:Nn \l_egreg_coltab_header_seq { & } \\
  \hline
  \seq_use:Nn \l_egreg_coltab_body_seq { & } \\
  \hline
  \end{tabular}
 }
\cs_generate_variant:Nn \egreg_coltab:nn { nV }

\ExplSyntaxOff

\begin{document}

\begin{columntabular}{Representation & Evaluation & Optimization}
\lv[0] Instances
\lv[1] $K$-nearest neighbor
\lv[1] Support vector machines
\lv[0] Hyperplanes
\lv[1] Naive Bayes
\lv[1] Logistic regression
\nextcolumn
\lv[0] Accuracy/Error rate
\lv[0] Precision and recall
\lv[0] Squared error
\nextcolumn
\lv[0] Continuous optimization
\lv[1] Unconstrained
\lv[2] Gradient descent
\lv[2] Conjugate gradient
\lv[1] Constrained
\lv[2] Linear programming
\end{columntabular}

\end{document}

enter image description here

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.