2

I want to specify the width of my column, each column with a different width. However, if I do specify like {\tabularx = X{1cm}||Y|Y|Y| etc. } the columns are combining in the same cell.
Most ideally I want the column width as wide as the word in the top row. For the first column this is the word Composition (Sheet resistance may be split into two lines).

Another problem I am facing has to do with the \checkmark symbol. It is not shown properly, but as a unfilled square (indicating that the code \checkmark is not recognized). I know that with greek letters, the problem is simply solved by putting the symbol into a math environment ($\rho$). However, this is not working for the \checkmark symbol. If somebody knows how to fix this, I would be very thankful.

Below I attached the code and the used packages.

    \documentclass{report}

    \usepackage{changes}
    \usepackage{amssymb}
    \usepackage{mathtools}
    \usepackage{amsmath}
    \usepackage[version=4]{mhchem}  %allows chemical formulae
    \usepackage{siunitx} %allow SI units
    \usepackage{cleveref} %smart referencing, automatic sorting etc.
    \usepackage{nomencl}
    \usepackage{pdfpages}
    \makenomenclature 

    \usepackage[usenames,dvipsnames]{xcolor}
    \usepackage{tcolorbox}
    \usepackage{tabularx}
    \usepackage{array}
    \usepackage{colortbl}
    \tcbuselibrary{skins}

    \newcolumntype{Y}{>{\raggedleft\arraybackslash}X}

    \tcbset{tab2/.style={enhanced,fonttitle=\bfseries,fontupper=\normalsize\sffamily,
    colback=yellow!10!white,colframe=tudelft-sky-blue,colbacktitle=Salmon!40!white,
    coltitle=black,center title}}

\begin{document}     

        \begin{tcolorbox}[tab2,tabularx={X||Y|Y|Y|Y|Y|Y|Y|Y}]
            \textbf{Property}   & \textbf{ECV}                  & \textbf{QSSPC}                & \textbf{Sherescan}            & \textbf{PL}                       & \textbf{Ellipsometry}         & \textbf{SEM}                  & \textbf{FTIR}                 & \textbf{XRD}      \\\hline\hline
            Passivation         & \checkmark    &            &            &            &            &            &           &           \\
            Doping profile      &               & \checkmark &            &            &            &            &           &           \\
            Sheet resistance    &               & \checkmark & \checkmark &            &            &            &           &           \\
            Thickness           & \checkmark    &            &            &            & \checkmark &\checkmark  &           &           \\
            Crystallinity       &               &            &            &            &            &\checkmark  &           &\checkmark \\
            Composition         &               &            &            & \checkmark &            &\checkmark  &\checkmark &           \\
            Absorption          &               &            &            &            & \checkmark &            &           &           \\
            \end{tcolorbox}

    \end{document}

2 Answers 2

2

With the default margins of your MWE there is simply not enough room to make each column as wide as the header. If your document provides enough room for your table, then you don't need to specify the widths manually, but just let latex do it's job.

(I had to move the xcolor package, otherwise your document did not compile because of an option clash)

\documentclass{report}

\usepackage{geometry}

\usepackage[dvipsnames]{xcolor}
\usepackage{changes}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage[version=4]{mhchem}  %allows chemical formulae
\usepackage{siunitx} %allow SI units
\usepackage{cleveref} %smart referencing, automatic sorting etc.
\usepackage{nomencl}
\usepackage{pdfpages}
\makenomenclature 


\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{array}
\usepackage{colortbl}
\tcbuselibrary{skins}

\newcolumntype{Y}{>{\raggedleft\arraybackslash}c}

\tcbset{tab2/.style={enhanced,fonttitle=\bfseries,fontupper=\normalsize\sffamily,
colback=yellow!10!white,colframe=blue,colbacktitle=Salmon!40!white,
coltitle=black,center title}}

\begin{document}     

    \begin{tcolorbox}[tab2,tabularx={X||Y|Y|Y|Y|Y|Y|Y|Y}]
        \textbf{Property}   & \textbf{ECV}                  & \textbf{QSSPC}                & \textbf{Sherescan}            & \textbf{PL}                       & \textbf{Ellipsometry}         & \textbf{SEM}                  & \textbf{FTIR}                 & \textbf{XRD}      \\\hline\hline
        Passivation         & \checkmark    &            &            &            &            &            &           &           \\
        Doping profile      &               & \checkmark &            &            &            &            &           &           \\
        Sheet resistance    &               & \checkmark & \checkmark &            &            &            &           &           \\
        Thickness           & \checkmark    &            &            &            & \checkmark &\checkmark  &           &           \\
        Crystallinity       &               &            &            &            &            &\checkmark  &           &\checkmark \\
        Composition         &               &            &            & \checkmark &            &\checkmark  &\checkmark &           \\
        Absorption          &               &            &            &            & \checkmark &            &           &           \\
        \end{tcolorbox}

\end{document}

enter image description here

3
  • @mhchem Thanks for your edit! Can you also comment or edit on the original question to make the OP aware of this problem? Commented Mar 30, 2018 at 18:51
  • Umm, the instruction \newcolumntype{Y}{>{\raggedleft\arraybackslash}c} does nothing at all, i.e., the resulting column type is still just c. Why not use c directly as the column type for the 8 data columns?
    – Mico
    Commented Jun 7 at 12:46
  • 1
    @Mico It would have required editing what was already there :) Commented Jun 7 at 12:50
0

Most ideally I want the column width as wide as the word in the top row

There's little that can be said to be "ideal" about a table that whose cells are either blank or contain a single symbol (here: \checkmark) yet whose columns differ wildly in width. Put differently: Do set the same width for all 8 data columns.

I'd continue to use a tabularx approach, and I'd let the width of the first column exceed that of the final 8 columns. In the example below, the usable width of the first column is ca 1.55 times larger than the width of the 8 data columns.

Oh, and I can't see a good argument for bold-facing the contents of the header row.

enter image description here

\documentclass{report}

\usepackage{changes}
\usepackage{amssymb}
\usepackage{mathtools}
%\usepackage{amsmath} % loaded automatically by 'mathtools'
\usepackage[version=4]{mhchem}  %allows chemical formulae
\usepackage{siunitx} %allow SI units
\usepackage{pdfpages}

\usepackage{nomencl}
\makenomenclature

\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{tabularx,ragged2e}
%\usepackage{array} % loaded automatically by 'tabularx'
%\usepackage{colortbl}

\usepackage[english]{babel}
\hyphenation{shere-scan ellips-om-etry}

\usepackage{cleveref} % load this package last

\newcolumntype{C}[1]{%
  >{\Centering\hspace{0pt}\hsize=#1\hsize}X}
\newcolumntype{L}[1]{%
  >{\RaggedRight\hspace{0pt}\hsize=#1\hsize\hangafter=1\hangindent=1ex}X}
\renewcommand\tabularxcolumn[1]{m{#1}}

\tcbset{tab2/.style={enhanced,
    fonttitle=\bfseries,
    fontupper=\normalsize\sffamily,
    colback=yellow!10!white,
    colframe=blue,
    colbacktitle=Salmon!40!white,
    coltitle=black,
    center title}}

\begin{document}
\setlength\tabcolsep{2pt} % default: 6pt
\noindent
% 1.48+8*0.94 = 9.0 = # of X-type columns
\begin{tcolorbox}[tab2,tabularx={ L{1.48} | *{8}{|C{0.94}} }]
   Property & ECV & QSSPC & Sherescan & PL & Ellipsometry & SEM & FTIR & XRD \\
   \hline\hline
   Passivation      & \checkmark & & & & & & & \\
   Doping profile   & & \checkmark & & & & & & \\
   Sheet resistance & & \checkmark & \checkmark & & & & & \\
   Thickness        & \checkmark & & & & \checkmark &\checkmark & & \\
   Crystallinity    & & & & & &\checkmark & &\checkmark \\
   Composition      & & & & \checkmark & &\checkmark  &\checkmark & \\
   Absorption       & & & & & \checkmark & & & \\
\end{tcolorbox}

\end{document} 

You must log in to answer this question.

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