1

I'm interested of th Following Question How can I draw this table 1?

I would like to know how can I use itemize inside 'itemize' inside table I tried code of @Zarko but with no luck besides I wonder why I can't get all 4 borders around the gray title section

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{enumitem}

\begin{document}
    \begin{center}
\setlist[itemize]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textendash,
                  before=\vspace{-0.6\baselineskip},
                  after=\vspace{-\baselineskip}
                  }
\bfseries
\begin{tabularx}{\linewidth}{ | l | X | }
    \hline
\multicolumn{2}{|>{\centering\arraybackslash}p{\dimexpr\linewidth-2\tabcolsep}|}{\cellcolor{gray!30}
    Very long text here and centered
    Very long text here and centered
    Very long text here and centered}    \\
    \hline
\multicolumn{2}{c}{}                    \\
    \hline
Description &   \begin{itemize}
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \end{itemize}          \\
    \hline
Addition    & long text bla bla bla bla long text bla bla bla bla\\
    \hline
\end{tabularx}
    \end{center}
\end{document}
3
  • In order to get the vertical spacing around the itemize environment (top and bottom) inside of a table cell right, one has to add negative spaces (before and after options of setlist). They interfere with the nested itemize enviroment.
    – leandriis
    Apr 17 '18 at 18:03
  • @leandriis Could you please write answer to show me that
    – Educ
    Apr 17 '18 at 18:04
  • I do get all 4 borders around the gray title section, but some get invisible at smaller display sizes due to the required scaling and the gray background (probably rounding errors)
    – remco
    Apr 17 '18 at 18:07
2

bases on my answer on the question how-can-i-draw-this-table-1:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{center}{%
    \setlist[itemize,1]{nosep,
                        topsep     = 0pt,
                        partopsep  = 0pt,
                        leftmargin = *,
                        label      = \textendash,
                        before     = \vspace{-0.6\baselineskip},
                        after      = \vspace{-\baselineskip}
                        }
    \setlist[itemize]{  nosep,
                        leftmargin=*,
                        label = $\bullet$
                      } }

\begin{document}
    \begin{center}
\bfseries
\begin{tabularx}{\linewidth}{ | l | X | }
    \hline
\multicolumn{2}{|>{\centering\arraybackslash}%
                 p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth\relax}|}{\cellcolor{gray!30}
    Very long text here and centered
    Very long text here and centered
    Very long text here and centered}    \\
    \hline
\multicolumn{2}{c}{}                    \\
    \hline
Description &   \begin{itemize}
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                    \begin{itemize}
                    \item   long text bla bla bla bla
                    \item   long text bla bla bla bla
                    \end{itemize}
                \end{itemize}          \\
    \hline
Addition    & long text bla bla bla bla long text bla bla bla bla\\
    \hline
\end{tabularx}
    \end{center}
\end{document}

enter image description here

5
  • I can't see the borders until I zoom pdf is there any possible to be showing without zooming
    – Educ
    Apr 17 '18 at 19:44
  • this seems to be problem of your pdf viewer. i can see borders very well in Sumatra as well in Adobe Reader DC. now i notice, that the calculation of multicolumn has error: i forgot to consider \arrayrulewidth. now is corrected. if you like to have thicker array rules, you can change them with \setlength\arrayrulewidth{<desired thikness>}
    – Zarko
    Apr 17 '18 at 19:54
  • with your new update I got problem
    – Educ
    Apr 17 '18 at 19:58
  • ups, one r in word \arrayrulewidth was lost :-(. sorry for any inconvenience. now corrected
    – Zarko
    Apr 17 '18 at 20:01
2

Here is a code with a nested itemize, and various improvements and simplifications:

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage[table, svgnames]{xcolor}
    \usepackage{tabularx, hhline}
    \usepackage{enumitem}
        \makeatletter
        \newcommand*{\compress}{\@minipagetrue}
        \makeatother
     \renewcommand{\tabularxcolumn}[1]{ >{\arraybackslash\compress}p{#1}}

    \begin{document}
        \begin{center}
    \setlist[itemize]{wide=0pt, nosep, leftmargin= * }
    \setlist[itemize, 1]{ label=\textendash, after=\vspace{-\baselineskip}}
    \setlist[itemize, 2]{ label=\textgreater}
    \setlength{\doublerulesep}{12pt}
    \setlength{\extrarowheight}{2pt}
    \bfseries
    \begin{tabularx}{\linewidth}{ | l | X | }
        \hhline{--}
    \rowcolor{WhiteSmoke!70!Lavender}\multicolumn{2}{|>{\centering\arraybackslash}p{\dimexpr\linewidth-2\tabcolsep}|}{%
        Very long text here and centered
        Very long text here and centered
        Very long text here and centered} \\
     % \hline \noalign{\vspace*{12pt}}
    %\multicolumn{2}{c}{} \\
        \hhline{==}
    Description & \begin{itemize}
                    \item long text bla bla bla bla
                    \item long text bla bla bla bla
                    \begin{itemize}[]
                    \item long text bla bla bla bla
                    \item long text bla bla bla bla
                    \item long text bla bla bla bla
                    \item long text bla bla bla bla
                    \end{itemize}
                    \item long text bla bla bla bla
                    \item long text bla bla bla bla
                    \end{itemize} \\
        \hhline{--}
    Addition & long text bla bla bla bla long text bla bla bla bla\\
        \hhline{--}
    \end{tabularx}
        \end{center}

    \end{document} 

1
  • The first table does not include the before and after options in order to correct the spacing above and below the itemize environment.

  • The second table includes these options. As one can see, the negative vspaces interfere with nested itemize environments, as they add up.

  • The third table does again not contain the before and after options, but includes some manual adjustments in order to get rid of the unnecessary white space above and below the first level itemize environment.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{enumitem}

\begin{document}
    \begin{center}
\setlist[itemize]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textendash,
                  %before=\vspace{-0.6\baselineskip},
                  %after=\vspace{-\baselineskip}
                  }

\begin{tabularx}{\linewidth}{ | l | X | }
    \hline
Description &   \begin{itemize}
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                  \begin{itemize}
                  \item short text
                  \item short text
                  \end{itemize}
                \end{itemize}          \\
    \hline
Addition    & long text bla bla bla bla long text bla bla bla bla\\
    \hline
\end{tabularx}
    \end{center}

\begin{center}
\setlist[itemize]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textendash,
                  before=\vspace{-0.6\baselineskip},
                  after=\vspace{-\baselineskip}
                  }

\begin{tabularx}{\linewidth}{ | l | X | }
    \hline
Description &   \begin{itemize} 
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                  \begin{itemize}
                  \item short text
                  \item short text
                  \end{itemize}
                \end{itemize}          \\
    \hline
Addition    & long text bla bla bla bla long text bla bla bla bla\\
    \hline
\end{tabularx}
    \end{center}


    \begin{center}
\setlist[itemize]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textendash,
                  %before=\vspace{-0.6\baselineskip},
                  %after=\vspace{-\baselineskip}
                  }

\begin{tabularx}{\linewidth}{ | l | X | }
    \hline
Description &   \begin{itemize} \vspace{-0.6\baselineskip}
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                  \begin{itemize}
                  \item short text
                  \item short text
                  \end{itemize}\vspace{-\baselineskip}
                \end{itemize}          \\
    \hline
Addition    & long text bla bla bla bla long text bla bla bla bla\\
    \hline
\end{tabularx}
    \end{center}
\end{document}

The last table can also be produced with the following MWE, which makes use of two different, new defined itemize-like environments for first-level and subsequent-level itemize environments inside table cells:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{enumitem}

\newlist{tabitemizefirst}{itemize}{1}
\newlist{tabitemizesecond}{itemize}{1}

\setlist[tabitemizefirst]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textendash,
                  before=\vspace{-0.6\baselineskip},
                  after=\vspace{-\baselineskip}
                  }

\setlist[tabitemizesecond]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textendash,
                  }

\begin{document}
\begin{tabularx}{\linewidth}{ | l | X | }
    \hline
Description &   \begin{tabitemizefirst}
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                \item   long text bla bla bla bla
                  \begin{tabitemizesecond}
                  \item short text
                  \item short text
                  \end{tabitemizesecond}
                \end{tabitemizefirst}          \\
    \hline
Addition    & long text bla bla bla bla long text bla bla bla bla\\
    \hline
\end{tabularx}
\end{document}

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.