1

I have following table

\documentclass[a4paper, 11pt, parskip]{scrreprt}
\usepackage{graphicx}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{multirow}
\usepackage{makecell}%To keep spacing of text in tables
\setcellgapes{3pt}%parameter for the spacing

\newcommand{\specialcell}[2][c]{%
    \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

\begin{document}
\begin{table}[h]
    %\makegapedcells
    \centering
    \resizebox{\textwidth}{!}{%resizing the whole table
        \begin{tabular}{|c|c|c|c|c|c|c|c|c|}
            \hline 
            \multicolumn{9}{|c|}{\Huge Relaisplatine} \\ 
            \hline 
            Relay Nr. & Part & Test-Id & \specialcell[c]{Signal-Name \\for Testcases} & Conn. & Pin & \specialcell[c]{Pin-\\Func.} & R Value & \specialcell[c]{Influenced \\ Signal/Voltage } \\ 
            \hline
            \rowcolor[gray]{0.8} 
            &  &  &  &  & 1 & N.C. & Open & Open \\
            \cline{6-9}
            %\hline 
            0 & WFB & WFB\_VOLT\_SDAR & WFB\_CLOCK\_+1V8 & P2 & 3 & COM &  0 $\Omega$ & SIGN02659 \\
            \cline{6-9}  
            %\hline 
            &  &  &  &  & 5 & N.O. &  0 $\Omega$ & GND \\
            %\cline{6-9}  
            \hline 
            &  &  &  &  & 7 & N.C. &  Open & Open \\ 
            \cline{6-9} 
            1 & WFB & WFB\_CLK & WFB\_CLKDIS153\_MUXOUT  & P2 & 9 & COM &  0 $\Omega$ & P5801 \\ 
            \cline{6-9}
            &  &  &  &  & 11 & N.O. &  0 $\Omega$ & P5802 \\ 
            \hline 
            &  &  &  &  & 13 & N.C. &  Open & Open \\ 
            \cline{6-9} 
            2 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_VCORE & P2 & 15 & COM &  0 $\Omega$ & SIGN02652 \\ 
            \cline{6-9} 
            &  &  &  &  & 17 & N.O. &  0 $\Omega$ & GND \\ 
            \hline 
            &  &  &  &  &  & N.C. &  Open & Open \\ 
            \cline{6-9} 
            3 & RIO & RIO\_T2\_DATA & RIO\_T2\_DATA & P3 & PCB-Cable & COM &  0 $\Omega$ & RIO\_GPP\_I2C\_SDA \\ 
            \cline{6-9} 
            &  &  &  &  & PCB-Cable & N.O. &  0 $\Omega$ & GND \\ 
            \hline 
            &  &  &  &  &  & N.C. &  Open & Open \\ 
            \cline{6-9} 
            4 &  &  &  & P3 &  & COM &  0 $\Omega$ &  \\ 
            \cline{6-9} 
            &  &  &  &  & PCB-Cable & N.O. &  0 $\Omega$ & GND \\ 
            \hline 
            &  &  &  &  & 14 & N.C. &  Open & Open \\ 
            \cline{6-9} 
            5 & RIO & RIO\_T1\_CLK & RIO\_T1\_CLK & P2 & 16 & COM &  0 $\Omega$ & RIO\_GPP\_I2C\_SCL1 \\ 
            \cline{6-9} 
            &  &  &  &  & 18 & N.O. &  0 $\Omega$ &  \\ 
            \hline 
            &  &  &  &  & 8 & N.C. &  Open & Open \\ 
            \cline{6-9} 
            6 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_MGTVCCAUX & P2 & 10 & COM &  0 $\Omega$ & SIGN02672 \\ 
            \cline{6-9} 
            &  &  &  &  & 12 & N.O. &  0 $\Omega$ &  \\ 
            \hline 
            &  &  &  &  & 2 & N.C. &  Open & Open \\ 
            \cline{6-9} 
            7 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_AVTT & P2 & 4 & COM &  0 $\Omega$ & SIGN02661 \\ 
            \cline{6-9} 
            &  &  &  &  & 6 & N.O. &  0 $\Omega$ & Open \\ 
            \hline 
        \end{tabular}
    }
    \caption{Verkabelung der ersten Relaisplatine an X400/PortA}
\end{table}
\end{document}

enter image description here

As you can see the Title of the table, called Relaisplatine, is touching the table borders. To tackle this problem i used \makegapedcells, but if I use it, it disables the coloring of the row.

How can I make the title not touch the borderlines and have colored rows?

  • 1
    If you just want to increase the height of the title row you can write \multicolumn{9}{|c|}{\gape{\Huge Relaisplatine}}. The colored row will the stay colored. Oh, and please make your code a complete MWE. – Mike Jul 5 '17 at 22:12
  • 1
    where is defined \specialcell? – Zarko Jul 7 '17 at 9:59
  • 1
    off-topic: your table is to huge that even with use \tiny font size can be fit in the text width. Consider to rotate table for 90 degree and use normal size font. Otherwise the table content one can read only with help of magnifying glass :( – Zarko Jul 7 '17 at 10:17
  • @Mike better now? – Simon Jul 7 '17 at 11:05
  • @Zarko Thanks for telling that \specialcell was missing. I used it to get linebreaks inside a cell. I will consider rotating it, thanks for the tip. – Simon Jul 7 '17 at 11:08
3

Macro \makegapedcells from package makecell is not compatible with coloring of table. IN similar cases you can use package cellspace and extension S to column types, where you like to have added vertical spaces into cells:

\documentclass[a4paper, 11pt, parskip]{scrreprt}
\usepackage[table]{xcolor}
\usepackage{cellspace, makecell, multirow}% for tables
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

%-------------------------------------- only for show page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{table}%[ht]
    \tiny
    \setlength\tabcolsep{3pt}
    \centering
        \begin{tabular}{|c|c|c|c|c|c|Sc|c|c|}
            \hline
            \multicolumn{9}{|>{\normalsize}Sc|}{Relaisplatine} \\
            \hline
\makecell{Relay\\ Nr.} & Part & Test-Id & \makecell[c]{Signal-Name \\for Testcases} & Conn. & Pin & \makecell[c]{Pin-\\Func.} & R  & \makecell[c]{Influenced \\ Signal/Voltage } \\
            \hline
            \rowcolor[gray]{0.8}
            &  &  &  &  & 1 & N.C. & Open & Open \\
            \cline{6-9}
            %\hline
            0 & WFB & WFB\_VOLT\_SDAR & WFB\_CLOCK\_+1V8 & P2 & 3 & COM &  0 $\Omega$ & SIGN02659 \\
            \cline{6-9}
            %\hline
            &  &  &  &  & 5 & N.O. &  0 $\Omega$ & GND \\
            %\cline{6-9}
            \hline
            &  &  &  &  & 7 & N.C. &  Open & Open \\
            \cline{6-9}
            1 & WFB & WFB\_CLK & WFB\_CLKDIS153\_MUXOUT  & P2 & 9 & COM &  0 $\Omega$ & P5801 \\
            \cline{6-9}
            &  &  &  &  & 11 & N.O. &  0 $\Omega$ & P5802 \\
            \hline
            &  &  &  &  & 13 & N.C. &  Open & Open \\
            \cline{6-9}
            2 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_VCORE & P2 & 15 & COM &  0 $\Omega$ & SIGN02652 \\
            \cline{6-9}
            &  &  &  &  & 17 & N.O. &  0 $\Omega$ & GND \\
            \hline
            &  &  &  &  &  & N.C. &  Open & Open \\
            \cline{6-9}
            3 & RIO & RIO\_T2\_DATA & RIO\_T2\_DATA & P3 & PCB-Cable & COM &  0 $\Omega$ & RIO\_GPP\_I2C\_SDA \\
            \cline{6-9}
            &  &  &  &  & PCB-Cable & N.O. &  0 $\Omega$ & GND \\
            \hline
            &  &  &  &  &  & N.C. &  Open & Open \\
            \cline{6-9}
            4 &  &  &  & P3 &  & COM &  0 $\Omega$ &  \\
            \cline{6-9}
            &  &  &  &  & PCB-Cable & N.O. &  0 $\Omega$ & GND \\
            \hline
            &  &  &  &  & 14 & N.C. &  Open & Open \\
            \cline{6-9}
            5 & RIO & RIO\_T1\_CLK & RIO\_T1\_CLK & P2 & 16 & COM &  0 $\Omega$ & RIO\_GPP\_I2C\_SCL1 \\
            \cline{6-9}
            &  &  &  &  & 18 & N.O. &  0 $\Omega$ &  \\
            \hline
            &  &  &  &  & 8 & N.C. &  Open & Open \\
            \cline{6-9}
            6 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_MGTVCCAUX & P2 & 10 & COM &  0 $\Omega$ & SIGN02672 \\
            \cline{6-9}
            &  &  &  &  & 12 & N.O. &  0 $\Omega$ &  \\
            \hline
            &  &  &  &  & 2 & N.C. &  Open & Open \\
            \cline{6-9}
            7 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_AVTT & P2 & 4 & COM &  0 $\Omega$ & SIGN02661 \\
            \cline{6-9}
            &  &  &  &  & 6 & N.O. &  0 $\Omega$ & Open \\
            \hline
        \end{tabular}
    \caption{Verkabelung der ersten Relaisplatine an X400/PortA}
\end{table}
\end{document}

Instead specialcell (not defined in your MWE) I use standard \makecell{...} from package `makecell}.

enter image description here

In above MWE I remove \resizebox{\textwidth}{!}{%resizing the whole table ...}, since it gives the same effect as changing font size to \tiny. This can be serious issues for readers, since text is to small for normal reading (see my comment above).

Addendum: In case, that you will consider to rotate your table, see if the following sMWE can help you. Note, even in it and reduced font size to \small, the table width is bigger than text height:

\documentclass[a4paper, 11pt, parskip]{scrreprt}
\usepackage{rotating}
\usepackage[table]{xcolor}
\usepackage{cellspace, makecell, multirow}% for tables
\setlength\cellspacetoplimit{3pt}       % additional top vertical spaces in cells
\setlength\cellspacebottomlimit{3pt}    % additional bottom vertical spaces in cells

%-------------------------------------- only for show page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{sidewaystable}
    \centering
    \small
\begin{tabular}{|c|c|c|c|c|c|Sc|c|c|}% added S foractivate additional vertical spaces in cels
    \hline
\multicolumn{9}{|Sc|}{Relaisplatine} \\
    \hline
\makecell{Relay\\ Nr.} & Part & Test-Id & \makecell[c]{Signal-Name \\for Testcases} & Conn. & Pin & \makecell[c]{Pin-\\Func.} & R  & \makecell[c]{Influenced \\ Signal/Voltage }        \\
    \hline
\rowcolor[gray]{0.8}
&  &  &  &  & 1 & N.C. & Open & Open \\
    \cline{6-9}
0 & WFB & WFB\_VOLT\_SDAR & WFB\_CLOCK\_+1V8 & P2 & 3 & COM &  0 $\Omega$ & SIGN02659 \\
    \cline{6-9}
&  &  &  &  & 5 & N.O. &  0 $\Omega$ & GND \\
    \hline
&  &  &  &  & 7 & N.C. &  Open & Open \\
    \cline{6-9}
1 & WFB & WFB\_CLK & WFB\_CLKDIS153\_MUXOUT  & P2 & 9 & COM &  0 $\Omega$ & P5801 \\
    \cline{6-9}
&  &  &  &  & 11 & N.O. &  0 $\Omega$ & P5802 \\
    \hline
&  &  &  &  & 13 & N.C. &  Open & Open \\
    \cline{6-9}
2 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_VCORE & P2 & 15 & COM &  0 $\Omega$ & SIGN02652 \\
    \cline{6-9}
&  &  &  &  & 17 & N.O. &  0 $\Omega$ & GND \\
    \hline
&  &  &  &  &  & N.C. &  Open & Open \\
    \cline{6-9}
3 & RIO & RIO\_T2\_DATA & RIO\_T2\_DATA & P3 & PCB-Cable & COM &  0 $\Omega$ & RIO\_GPP\_I2C\_SDA \\
    \cline{6-9}
&  &  &  &  & PCB-Cable & N.O. &  0 $\Omega$ & GND \\
    \hline
&  &  &  &  &  & N.C. &  Open & Open \\
    \cline{6-9}
4 &  &  &  & P3 &  & COM &  0 $\Omega$ &  \\
    \cline{6-9}
&  &  &  &  & PCB-Cable & N.O. &  0 $\Omega$ & GND \\
    \hline
&  &  &  &  & 14 & N.C. &  Open & Open \\
    \cline{6-9}
5 & RIO & RIO\_T1\_CLK & RIO\_T1\_CLK & P2 & 16 & COM &  0 $\Omega$ & RIO\_GPP\_I2C\_SCL1 \\
    \cline{6-9}
&  &  &  &  & 18 & N.O. &  0 $\Omega$ &  \\
    \hline
&  &  &  &  & 8 & N.C. &  Open & Open \\
    \cline{6-9}
6 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_MGTVCCAUX & P2 & 10 & COM &  0 $\Omega$ & SIGN02672 \\
    \cline{6-9}
&  &  &  &  & 12 & N.O. &  0 $\Omega$ &  \\
    \hline
&  &  &  &  & 2 & N.C. &  Open & Open \\
    \cline{6-9}
7 & WFB & WFB\_VOLT\_SDAR & WFB\_WF\_FPGA\_AVTT & P2 & 4 & COM &  0 $\Omega$ & SIGN02661 \\
    \cline{6-9}
&  &  &  &  & 6 & N.O. &  0 $\Omega$ & Open \\
    \hline
\end{tabular}
\caption{Verkabelung der ersten Relaisplatine an X400/PortA}
    \end{sidewaystable}
\end{document}
  • I didn't know something as \makecellexists. I will use it. Thanks! – Simon Jul 7 '17 at 13:19

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.