3

I'm already 3 days trying to create simple table as I have in Word. I want to create some template for me. I tried many converters to LaTeX, but it doesn't answer on all my requirements. That what I get m but have to fix several things. I almost sure I don't need multicolumn in the code. Just to set alignment for some row.

Table

  1. I draw the lines (\hhline) with cell color where I did \multirow, but still there is some line there, depending on zoom. Also in PDF Foxit reader. I tried to use \hline and \cline but they don't work properly with colored cells. Is there option to change the line width?

  2. I use \multirow and the text inside the cell is not in the middle if I use \multicolumn also. If I remove \multicolumn it comes to the middle. BUT I defined it in the top by >{\raggedright}p{0.2\textwidth}|. So I want to place it or in the top inside the cell OR option to drop it a little down from the top line, a little bit more control on the placing inside the cells. Also I wanted to do alignment left-top, or left-middle, but without to set width of the cell, is it posible?

3-4. If I have one long sentence, I expect it should be moved to another line automatically according to the size of the column. But if I need to join cells by \multirow it doesn't work if the sentence inside the \multirow and I must to use tabular. If I don't need to join cells, I can take out a sentence from \multirow and it will brake the sentence to several lines as expected. In the code line 43 outside \multirow, goes to a next line automatically. In the line 46 inside \multirow because I need to use \multirow to join several cells, and I must to use tabular. It doesn't goes to other line automatically.

  1. Some cells I want to do alignment center-middle, but without set column width. How I do that?
% Automatically added code
\documentclass{article}
\usepackage{xcolor}

\begin{document}
% End of automatically added code


\begin{table}[H]
\resizebox{\columnwidth}{!}{%

\begin{tabular}{|>{\raggedright}p{0.2\textwidth}|>{\raggedright}p{0.2\textwidth}|c|c|c|c|>{\raggedright}p{0.3\textwidth}|}
%{|l|l|c|c|c|c|l|}%>{\raggedright}p{0.12\textwidth}

\hhline{-------}
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{79, 129, 189}Parameter}} &
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{79, 129, 189} Details}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{79, 129, 189} Min}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{79, 129, 189} Typ}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{79, 129, 189} Max}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{79, 129, 189} Unit}} &
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{79, 129, 189} Notes}}\tabularnewline
\hhline{|-|-|-|-|-|-|-|}


\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{ 79, 129, 189}VDD}} &
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{184, 204, 228}VDD2\_b\_a}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{184, 204, 228} 1.71}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{184, 204, 228} 2}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{184, 204, 228} 2.2}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{184, 204, 228} {[}V{]}}} &
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{184, 204, 228}2V ±5\%}} \tabularnewline
\hhline{|-|-|-|-|-|-|-|}

\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{ 79, 129, 189}}}  &
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241}VDD1V8\_c\_d}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 0.9}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 1.}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 1.2}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} {[}V{]}}} &
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241}}}  \tabularnewline
\hhline{|>{\arrayrulecolor[RGB]{79, 129, 189}}-|>{\arrayrulecolor{black}}->{\arrayrulecolor{black}}|-|-|-|-|-|}

\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{ 79, 129, 189}}} & 
\multicolumn{1}{|l|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} }} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 1.0}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 1.2}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 1.29}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} {[}V{]}}} &
\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241}}1.20V ±10\%, on save mode also work 5{[}V{]} input  \tabularnewline
\hhline{|>{\arrayrulecolor[RGB]{79, 129, 189}}-|>{\arrayrulecolor[RGB]{219, 229, 241}}->{\arrayrulecolor{black}}|-|-|-|-|-|}

\multirow{-3}{*}{\cellcolor[RGB]{ 79, 129, 189}\begin{tabular}[l]{@{}l@{}}Open Source \\SDevice\end{tabular}}  &
\multicolumn{1}{|l|}{\multirow{-2}{*}{\cellcolor[RGB]{219, 229, 241}VDD5V2\_sssss\_ttttt}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 0.95}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 1.0}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} 1.05}} &
\multicolumn{1}{|c|}{\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241} {[}V{]}}} &
\multirow{1}{*}{\cellcolor[RGB]{219, 229, 241}}1.00V ±20\%, on save also work 3{[}V{]}   \tabularnewline
\hhline{|-|-|-|-|-|-|-|}


\end{tabular}
}
\end{table}

% Automatically added code
\end{document}
% End of automatically added code 

Thank you in advance.

1
  • 2
    Welcome to TeX.SX! You should complete your code example so that it can be compiled as is; it seems to be missing some packages.
    – Vincent
    Mar 28 at 13:42

3 Answers 3

3

Here is a way to do that tabular with {NiceTabular} of nicematrix. You won't see thin whites lines, whatever PDF viewer you use.

However, you need several compilations.

\documentclass[x11names,svgnames,11pt]{article}
\usepackage{geometry}
\usepackage{nicematrix}
\usepackage{xcolor}

\begin{document}

\begin{NiceTabular}{p{25mm}lccccX[l,m]}[hvlines]
\CodeBefore
  \rowcolor[RGB]{79,129,189}{1}
  \columncolor[RGB]{79,129,189}{1}
  \rectanglecolor[RGB]{184,204,228}{2-2}{2-*}
  \rectanglecolor[RGB]{219,229,241}{3-2}{5-*}
\Body
  Parameter & Details & Min & Typ & Max & Unit & Notes \\ 
  VDD & VDD2\_b\_a & 1.71 & 2 & 2.2 & [V] & 2V ±5\% \\
  \Block{3-1}{Open Source Device  }
  & VDD1V8\_c\_d & 0.9 & 1. & 1.2 & [V] & \\
  & \Block{2-1}{VDD5V2\_sssss\_ttttt}  & 1.0 & 1.2 & 1.29 & [V] & 1.20V ±10\%, on save mode also work 5[V] input \\
  &  & 0.95 & 1.0 & 1.05  & [V] & 1.00V ±20\%, on save also work 3[V] \\
\end{NiceTabular}

\end{document}

Output of the above code

8
  • Why it doesn't work ? ! Fatal Package nicematrix Error: Bad column type.(nicematrix) The column type '\CodeBefore ' in your(nicematrix) environment {NiceTabularX} is unknown.(nicematrix) This error is fatal.Type <return> to continue.... \rowcolor
    – ikif
    Mar 28 at 19:56
  • Strange... Is your TeX installation up to date? Mar 28 at 20:03
  • My Texmaker ver 5.1.3 MikTeX console 4.9 instaletion file 22.10x64
    – ikif
    Mar 28 at 20:14
  • You should try to update with the button Updates in MikTeX console. Mar 28 at 20:18
  • I updated everything. I think I found , it conflicts with \usepackage{colortbl} \usepackage{tabularx}
    – ikif
    Mar 28 at 20:36
3

For such a table, I would suggest that you use the tabularray package. It gives all possible controls. The documentation is fantastic and huge.

I have recast your table for tabularray and changed the separator horizontal rules to white. Most of the members on this forum would strongly suggest you to avoid vertical lines in a table. The only problem I faced is I could not get rid of the thin vertical white space between the columns.

%
\documentclass[x11names,svgnames,11pt]{article}
%
\usepackage[body={15cm,23cm},centering]{geometry}

\usepackage{siunitx}
\usepackage{xcolor}

\usepackage{tabularray}
  \UseTblrLibrary{booktabs, siunitx} 

\begin{document}

\setlength{\belowrulesep}{0pt}
\setlength{\aboverulesep}{0pt}
\begin{tblr}{
  width=1\textwidth, stretch=1.5,
  cell{1}{1-7} = {bg=azure3, fg=white},
  cell{1-5}{1} = {bg=azure3, fg=white},
  cell{2}{2-7} = {bg=azure7},
  cell{3}{2-7} = {bg=azure8},
  cell{4-5}{2-7} = {bg=azure9},
  colspec  = {llSSSlX[l, 3cm]}
  }
\toprule
  Parameter & Details & Min & Typ & Max & Unit & Notes \\ 
\hline[white]
  VDD & VDD2\_b\_a & 1.71 & 2 & 2.2 & [V] & 2V ±5\% \\
\hline[white]
\SetCell[r=3]{m, 2cm} Open Source Device  
  & VDD1V8\_c\_d & 0.9 & 1. & 1.2 & [V] & \\
\cline[white]{3-7}
  & \SetCell[r=2]{m, 3.5cm} VDD5V2\_sssss\_ttttt  & 1.0 & 1.2 & 1.29 & [V] & 1.20V ±10\%, on save mode also work 5[V] input \\
  \cline[white]{3-7}
  &  & 0.95 & 1.0 & 1.05  & [V] & 1.00V ±20\%, on save also work 3[V] \\
\bottomrule
\end{tblr}

\end{document}

enter image description here

1
  • THank you. What is a problem with vertical lines ?
    – ikif
    Mar 28 at 19:25
1

Another possible solution using of tabularray package:

\documentclass{article}
\usepackage[body={15cm,23cm}]{geometry}

\usepackage{siunitx}
\usepackage{xcolor}
\definecolor{darkB}{RGB}{ 79, 129, 189}     % dark blue
\definecolor{mediumB}{RGB}{184, 204, 228}   % dark blue
\definecolor{lightB}{RGB}{219, 229, 241}    % dark blue

\usepackage{tabularray}         % version 2023A
\UseTblrLibrary{booktabs, siunitx}
\newlength\colwidth

\begin{document}
\begingroup
\settowidth\colwidth{Parameter}
\noindent
\begin{tblr}{row{1} = {guard, bg=darkB,fg=white},
             row{2} = {bg=mediumB},
             row{3} = {bg=lightB},
            colspec = {Q[l, wd=4.4em, bg=darkB,fg=white] l
                       SSS
                       c X[l, m]},
            hlines, vlines, 
              }
Parameter   & Details & Min & Typ & Max & Unit & Notes \\
VDD         & VDD2\_b\_a & 1.71 & 2 & 2.2 & [V] & 2V ±5\% \\
\SetCell[r=3]{l}    Open Source Device
    & VDD1V8\_c\_d  & 0.9 & 1.      & 1.2 & [V] & \\
    & \SetCell[r=2]{l} VDD5V2\_sssss\_ttttt  
        & 1.0       & 1.2 & 1.29    & [V] & 1.20V ±\qty{10}{\%}, 
                                      on save mode also work \qty{5}{\volt} input \\
    &    & 0.95     & 1.0 & 1.05    & [V] & 1.00V ±\qty{20}{\%},   
                                      on save also work \qty{3}{\volt} \\
\end{tblr}
\endgroup
\end{document}

enter image description here

You must log in to answer this question.

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