1

In the following, there is an issue in the colouring of the first line. It should be a one simple grey block but there is some overlaying white rectangle.

Why and how to fix it?

\documentclass{article}

\usepackage{amsfonts}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{wasysym}

\begin{document}

\begin{tabular}{@{} m{2cm} <{\hspace*{1mm}} | m{1.9cm} <{\hspace*{1mm}}}
\multicolumn{2}{c}{\cellcolor{black!20!white}{}}\\[-3mm]
\multicolumn{2}{c}{\cellcolor{black!20!white}{\footnotesize $\ \mathbf{15}$ \hspace{0pt plus 1filll} Test}}\\[1.5mm]
\scriptsize \hfill $\times \hspace{-1pt}\approx\hspace{-1pt}\checked$
& \scriptsize \hfill $\times \hspace{-1pt}\approx\hspace{-1pt}\checked$  \\                                                          
\dotfill\scriptsize $\square$\,$\square$\,$\square$ & \dotfill\scriptsize $\square$\,$\square$\,$\square$\\
\dotfill\scriptsize $\square$\,$\square$\,$\square$ & \dotfill\scriptsize $\square$\,$\square$\,$\square$\\
\dotfill\scriptsize $\square$\,$\square$\,$\square$ & \dotfill\scriptsize $\square$\,$\square$\,$\square$\\[3mm]
\end{tabular}

\end{document}

enter image description here

Log

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex) \write18 enabled. entering extended mode (./bac_a_sable.tex LaTeX2e <2017-04-15> Babel <3.10> and hyphenation patterns for 84 language(s) loaded. (/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls Document Class: article 2014/09/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amsfonts.sty) (/usr/local/texlive/2017/texmf-dist/tex/latex/tools/tabularx.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/tools/array.sty)) (/usr/local/texlive/2017/texmf-dist/tex/latex/xcolor/xcolor.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-cfg/color.cfg) (/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-def/pdftex.def (/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/infwarerr.sty) (/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)) (/usr/local/texlive/2017/texmf-dist/tex/latex/colortbl/colortbl.sty)) (/usr/local/texlive/2017/texmf-dist/tex/latex/wasysym/wasysym.sty) (./bac_a_sable.aux) (/usr/local/texlive/2017/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] ) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/umsb.fd) (/usr/local/texlive/2017/texmf-dist/tex/latex/wasysym/uwasy.fd) [1{/usr/local/t exlive/2017/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./bac_a_sable.aux) )< /usr/local/texlive/2017/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb> Output written on bac_a_sable.pdf (1 page, 42174 bytes). SyncTeX written on bac_a_sable.synctex.gz. Transcript written on bac_a_sable.log.

3

If I understand well what you try to achieve, it's much simpler to use a single row for the table head, using two \multicolumns with different alignments, and the cellspace package to increase the row height:

\documentclass{article}

\usepackage{amsfonts}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{8pt}
\setlength{\cellspacebottomlimit}{8pt}
\usepackage{wasysym}

\begin{document}

\begin{tabular}{@{} m{2cm} <{\hspace*{1mm}} | m{1.9cm} <{\hspace*{1mm}}}
\rowcolor{black!20!white}\multicolumn{1}{@{}Sl}{\footnotesize $\ \mathbf{15} $} & \multicolumn{1}{r}{\footnotesize Test}\\
\scriptsize \hfill $\times \hspace{-1pt}\approx\hspace{-1pt}\checked$
& \scriptsize \hfill $\times \hspace{-1pt}\approx\hspace{-1pt}\checked$ \\
\dotfill\scriptsize $\square$\,$\square$\,$\square$ & \dotfill\scriptsize $\square$\,$\square$\,$\square$\\
\dotfill\scriptsize $\square$\,$\square$\,$\square$ & \dotfill\scriptsize $\square$\,$\square$\,$\square$\\
\dotfill\scriptsize $\square$\,$\square$\,$\square$ & \dotfill\scriptsize $\square$\,$\square$\,$\square$\\[3mm]
\end{tabular}

\end{document}

enter image description here

  • Thanks Bernard. Where Can I find more info on \multicolumn{1}{@{}Sl} (esp. the Sl)? – Colas Jul 7 '18 at 18:03
  • The prefix S defines a minimal vertical spacing at the top and bottom of cells in columns with specifier prefiexed with this letter. If you load siunitx, which defines an S column type, you have to use the letter C. You'll find some other details in the package documentation. On the other hand, \multicolumn here is also used to remove the vertical rule in the table header. – Bernard Jul 7 '18 at 18:27
2

enter image description here

\documentclass{article}
\usepackage{amssymb}
\usepackage{wasysym}
\usepackage[table]{xcolor}

\begin{document}

{\renewcommand\arraystretch{1.5}
 \newcommand\mcbf[2]{\multicolumn{1}{#1}{\normalsize\textbf{#2}}}
    \begin{tabular}{@{} >{\raggedleft\arraybackslash\scriptsize}p{2cm} <{\hspace*{1mm}} | 
                        >{\raggedleft\arraybackslash\scriptsize}p{2cm} <{\hspace*{1mm}}}
\rowcolor{black!20!white}
\mcbf{l}{15}  &   \mcbf{r}{Test}              \\
$\times \hspace{-1pt}\approx\hspace{-1pt}\checked$
                    &   $\times \hspace{-1pt}\approx\hspace{-1pt}\checked$  \\
\dotfill $\square$\,$\square$\,$\square$ & \dotfill $\square$\,$\square$\,$\square$\\
\dotfill $\square$\,$\square$\,$\square$ & \dotfill $\square$\,$\square$\,$\square$\\
\dotfill $\square$\,$\square$\,$\square$ & \dotfill $\square$\,$\square$\,$\square$
\end{tabular}
}
\end{document}
  • Let me check your code. I need the lines to be compact... – Colas Jul 7 '18 at 17:18
  • There should be no separator in the first line (the grey one). – Colas Jul 7 '18 at 17:19
  • 1
    @Colas, now i remove vertical line in gray row. – Zarko Jul 7 '18 at 17:48

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.