# Mimic Microsoft Word Tables

I need to fill out some Word form. As the form is very long I was allowed to transform it into a LaTeX format. One item that is difficult for me to mimic are the tables. They look like this:

Note that word is using a specific spacing as well as a different background color it would be great to mimic both a closely as possible.

I am aware of the table generator for LaTeX. https://www.tablesgenerator.com/ But that does not help me with either the spacing nor the background color.

Follow-Up Question: In the two very nice answers it is also possible to edit the colors. I know the RGB values of the specific colors that I want to use. How can I set the colors using RGB values? the predefined colors are not exactly matching my needs.

• Welcome to TeX.SE! Can you show us the TeX code you tried so far? Oct 3 '21 at 20:46
• as far as I have seen by examples posted previously on thi ssite the tablesgenerator website makes massively over complicated markup and would be best avoided. for your table you can copy the examples in the colortbl manual (texdoc colortbl although that uses more cheerful colours than just grey:-) Oct 3 '21 at 20:52

## 2 Answers

With the help of the tabularray package, you can quite easily get a similar output:

\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}

\noindent
\begin{tblr}{
width=\linewidth,
colspec={X[2]X[3]},
hlines ={gray7},
vlines ={gray7},
row{1} = {bg=gray9, fg=azure4, font=\sffamily},
column{1} = {gray9, fg=azure4, font=\sffamily},
}
first column header   & second column header  \\
row 1 & contents   \\
row 2 & more text here    \\
row 3 & other longer text in this cell other longer text in this cell other longer text in this cell \\
row 4 & text   \\
row 5 & example text \\
\end{tblr}

\end{document}

• Finally, changing the font to Calibri will make the camouflage perfect =) Oct 4 '21 at 0:01
• Nice, but my overleaf compiler says it cannot find tabularray. I use Xelatex, as I need to important the Calibri font and that does not work with pdflatex.
– Till
Oct 4 '21 at 9:55
• @Till tabulararray package is not yet added in Overleaf. Try adding it manually. You can find it here. Also, you might need to add the ninecolors package. Oct 4 '21 at 10:20

With the nicematrix package.

MWE:

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
\begin{table}[htbp]
\sffamily
%\caption{Caption}
\label{tab:my_label}
\centering
\begin{NiceTabular}{|>{\color{blue}}m{4.5cm}|m{6.5 cm}|}[hvlines, rules/color=gray!70, cell-space-limits=3pt]
\CodeBefore
\columncolor{gray!20}{1}
\Body
\RowStyle{\color{blue}}Experience & Number of months\\
Research activities & Some text\\
Education & Some text\\
Leave & Some text\\
Management tasks & Some text\\
Others (please specify): & Some text\\
\end{NiceTabular}

\end{table}

\end{document}


Edit: I wasn't notified about your edit in the question and probably the answerers aren't notified about any edit in the question as @leandriis hasn't also noticed yet.

You can easily set colors using RGB values. For absolute RGB values, you can use the syntax [RGB]{num, num, num} and for relative RGB values (i.e. R/255, G/255, B/255), you can use the syntax [rgb]{frac, frac, frac}.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{xcolor}

\begin{document}
\begin{table}[htbp]
\sffamily
%\caption{Caption}
\label{tab:my_label}
\centering
\begin{NiceTabular}{|>{\color[RGB]{20, 40, 200}}m{4.5cm}|m{6.5 cm}|}[hvlines, rules/color=gray!70, cell-space-limits=3pt]
\CodeBefore
\columncolor[RGB]{224, 224, 224}{1}
\Body
\RowStyle{\color[rgb]{0.08, 0.08, 0.86}}Experience & Number of months\\
Research activities & Some text\\
Education & Some text\\
Leave & Some text\\
Management tasks & Some text\\
Others (please specify): & Some text\\
\end{NiceTabular}

\end{table}

\end{document}


• @Till extended the answer to add color using RGB values. Nov 10 '21 at 11:34