2

I want to create a table like the following picture enter image description here

I tried with this code basically from this post compact bulleted points in table

\usepackage{booktabs,tabularx}
\newcolumntype{T}{>{\raggedright\arraybackslash}p{5.354cm}}
\begin{table*}
\caption{The table caption}

\begin{tabularx}{\textwidth}{|T|T|T|}
\hline
Column 1 & Column2 & Column 3\\
\hline
Multiple column and column & 
  \begin{tabular}[t]{ @{\makebox[1.5em][l]{\textbullet}} 
   p{\dimexpr\linewidth-1.5em} @{} }
multiline item text multiline item text multiline item text multiline item 
  text multiline item text \\
multiline item text multiline item text
\end{tabular}
&
\begin{tabular}[t]{ @{\makebox[1.5em][l]{\textbullet}} p{\dimexpr\linewidth- 
1.5em} @{} }
multiline item text multiline item text multiline item text multiline item 
 text multiline item text \\
multiline item text multiline item text
\end{tabular} \\
\hline

\end{tabularx}
\end{table*}

The result is enter image description here But the problem is that there is some unnecessary space in the first column. I am not expert in latex. Is there any convenient and efficient way to make this type of table in latex?

Bernard
  • 271,350
  • Welcome to TeX.SE! You are setting the width of all columns, including the first one, explicitly. You could just choose a smaller width for the first column if you do not want to waste space. –  Sep 08 '18 at 20:20
  • welcome to tec.se! dsee http://tex.stackexchange.com/questions/347253/ (actually your question is duplicate to this and many other similar :-) ) – Zarko Sep 08 '18 at 20:21
  • BTW, you are not supposed to use tabularx here since you do not have any X type column. You could simply define a smaller column \newcolumntype{A}{>{\raggedright\arraybackslash}p{2.354cm}} and then do \begin{tabular}{|A|T|T|} (and of course end the thing with \end{tabular}). –  Sep 08 '18 at 20:32
  • @Zarko Did you read the question? It is written "But the problem is that there is some unnecessary space in the first column." I am not sure if your answer helps with that. Am I missing something? –  Sep 08 '18 at 20:36
  • @marmot, i check my answer again. there is no unnecessary space. it seems that op like to have first column of the l type (this has sense, if the text is short an in one column only. i suggest you that you write an answer and show this possibilities. – Zarko Sep 08 '18 at 21:45
  • @Zarko I was interpreting this as a simple "The left column has to much space", which can be cured by making it smaller. And no, I do not intend to write an answer. –  Sep 08 '18 at 21:47

2 Answers2

3

I propose this simpler code, based on tabularx, with a customised itemize environment in the last two columns:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{enumitem}
\usepackage{tabularx, caption}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

\begin{document}

\begin{table*}
\caption{The table caption}
\setlist[itemize]{wide=0pt, leftmargin=*, itemsep=0pt, topsep=0pt, after=\vspace*{-\baselineskip}, rightmargin=-\leftmargini}
\setlength{\extrarowheight}{3pt}
\begin{tabularx}{\textwidth}{|>{\hsize=0.6\hsize}X|*{2}{>{\hsize=1.2\hsize\compress\arraybackslash}X|}}
\hline
Column 1 & Column2 & Column 3\\
\hline
Multiple column and column &
\begin{itemize}
 \item
multiline item text multiline item text multiline item text multiline item
  text multiline item text
\item
multiline item text multiline item text
\end{itemize}
&
\begin{itemize}
\item
multiline item text multiline item text multiline item text multiline item
 text multiline item text
 \item
multiline item text multiline item text
\end{itemize}
 \\
\hline
\end{tabularx}
\end{table*}

\end{document}

enter image description here

Bernard
  • 271,350
2

let me extend my comment to an answer:

  • you provide only code snippet of table, so actual document layout is not known. therefore i use document with page borders determined by the `geometry package
  • answer is based on my answer to question "items list inside table cell are not well aligned".
  • in comparison to it i made the following changes:

    • from your question i conclude, that in the cells of the first columns you have short one line text. for such text is appropriate to use the l column type
    • since you use the tabularx table environment with left aligned columns' headers, i accordingly change definitions of I column and command mch:

      \documentclass{article}
      \usepackage[showframe,
                  a4paper]{geometry}
      \usepackage{booktabs, tabularx}
      
      % added packages and column definitions
      \usepackage{ragged2e}           % for smart align of cells' content
      
          \usepackage{enumitem}       % for nice list
      \newcolumntype{I}{>{\RaggedRight\arraybackslash%            % <-- for lists in columns
                             \itemize}X<{\enditemize}}
      \newcommand\mch[1]{\multicolumn{1}{l}{\small{#1}}}  % <-- for columns headers
      
      \begin{document}
      
          \begin{table}
          \setlength\tabcolsep{3pt}
          \setlist[itemize]{nosep,        % <-- new list setup
                           leftmargin = *,
                           before     = \vspace{-0.6\baselineskip},
                           after      = \vspace{-\baselineskip}
                           }
      \caption{The table caption}
          \label{tab:itemize}
      \begin{tabularx}{\linewidth}{ >{\RaggedRight}p{0.2\linewidth}  *{2}{I} }
          \toprule
      Column 1 & \mch{Column 2} & \mch{Column 3}                          \\
          \midrule
      Multiple column and column
          &   \item   multi line item text multi line item text multi line item text multi line item
        text multi line item text
              \item   x x x x x x x x x x x x x x x x x x x x x x x x x
              &   \item   multiline item text multiline item text multiline item text multiline item
       text multiline item text
                  \item   x x x x x x x x x x x x x x x x x x x x x x x x \\
          \bottomrule
      \end{tabularx}
      \end{table}
      \end{document}
      

enter image description here

in the case, that texts in the first column are longer and had to be broken into more lines, than instead of l column you should use p{<width> column type and determine its width according to your taste. in this case the columns I will adopt to the rest of the table width automatically. for example with

\begin{tabularx}{\linewidth}{ >{\RaggedRight}p{0.2\linewidth}  *{2}{I} }

you will obtain:

enter image description here

Zarko
  • 296,517
  • Hello, @Zarko, I have used "longtable" according to your answer in https://tex.stackexchange.com/questions/347253/items-list-inside-table-cell-are-not-well-aligned. But problem is that my article is two column in which longtable not work. Is there any way to use supertabular/xtab with your code? – Bloodstone Programmer Sep 11 '18 at 07:00
  • @BloodstoneProgrammer, i'm sorry, but i'm not familiar with this two packages. table is two column wide, so it has to be span over two columns with use table*. if table is to long for one page, than i would rather split it into two part where for the first i will use [!b] placement specifier and for the second [!t]. – Zarko Sep 11 '18 at 07:15
  • @BloodstoneProgrammer: You can try to nest your longtable in a strip environment from the cuted package (ncctools bundle) which leaves the two-column mode. – Bernard Sep 11 '18 at 10:22
  • @Bernard, good idea. i forgot on this package :-(. thank you very much for the info. – Zarko Sep 11 '18 at 14:01