1

I'm trying to make a table with diagonale titles. For this, I used some functions from the answer from Heiko Oberdiek in the post Special Table with Diagonal lines

I create the following functions by using the Heiko's proposition and modify it in order to have a line up and down, multiline support and the capability to increase the angle selection:

\usepackage{makecell}
\newcolumntype{M}{>{\centering\arraybackslash}m{3mm}}

\renewcommand*{\arraystretch}{1.5}%

\newcommand*{\headformat}[1]{{\small#1}}%
\newcommand*{\vcorr}{%
      \vadjust{\vspace{-\dp\csname @arstrutbox\endcsname}}%
      \global\let\vcorr\relax
    }%
    \newcommand*{\HeadAux}[5]{%
      \multicolumn{#2}{@{}#3@{}}{%
        \vcorr
        \sbox0{\headformat{\strut #1}}%
        \sbox2{\headformat{Maintenance}}%
        \sbox4{\kern\tabcolsep\redtriangle\kern\tabcolsep}%
        \sbox6{\rotatebox{#4}{\rule{0pt}{\dimexpr\ht0+\dp0\relax}}}%
        \sbox0{\raisebox{0.25\dimexpr\dp0-\ht0\relax}[0pt][0pt]{\unhcopy0}}%

        \dimen0=\dimexpr\wd2+0.5\wd4\relax
       \ifx\HeadLine Y% 
          \rlap{\rotatebox{#5}{\hbox{\vrule width\dimen0 height .4pt}}}%
        \fi
        \kern.75\wd4 %

        \rlap{%
          \raisebox{.1\wd4}{\rotatebox{#4}{\unhcopy0}}%
        }%

        \kern.25\wd4 %
        \ifx\HeadLine Y%
          \rlap{\rotatebox{#5}{\hbox{\vrule width\dimen0 height .4pt}}}%
        \fi
      }%
    }%
    \newcommand*{\head}[1]{\HeadAux{\global\let\HeadLine=Y#1} {1} {r} {45} {45}}%
    \newcommand*{\headNoLine}[1]{\HeadAux{\global\let\HeadLine=N#1} {1} {r} {45} {45}}%
    \newcommand*{\headmulti}[2]{\HeadAux{\global\let\HeadLine=N#1} {#2} {l} {0} {45}}%

And I create my table in a separate tex file thanks the following:

\documentclass[./main.tex]{subfiles}

\begin{document}

\begin{tabular}{%
       >{\bfseries}rM|M|M|M|M|M|M|M|M|M|M%
    }%
    & \head{Maintenance}
    & \head{Flight n-i}
    & \headmulti{\thead{$n^{th}$ - Flight Conditions}}{5}
    & \head{Flight n+i}
    & \head{Maintenance}
    \\
    \toprule
    \sbox0{S}%
      \rule{0pt}{\dimexpr\ht0 + 2ex\relax}%
    Repercussion Phase 
            & {\cellcolor{blue!25}}  & \cellcolor{gray!25}\greencheck
            &\greencheck &\greencheck & \greencheck 
            &\greencheck & \greencheck &  \cellcolor{gray!25}\greencheck 
            & {\cellcolor{blue!25}}\\ 
    \hline
    S1 Detection 
            & {\cellcolor{blue!25}}  & \cellcolor{gray!25}\redtriangle
            & \redtriangle & \redtriangle & \redtriangle 
            & \redtriangle & \redtriangle &  \cellcolor{gray!25}\redtriangle 
            & {\cellcolor{blue!25}}\\ 
    \hline
    Risk Time 
            & {\cellcolor{blue!25}}  & \cellcolor{gray!25}\greencheck 
            &\greencheck & \greencheck & \greencheck 
            &\greencheck&\greencheck&  \cellcolor{gray!25}\greencheck
            & {\cellcolor{blue!25}}\\
    \hline
    \multicolumn{3}{c|}{\multirow{2}{*}{Time(s)}}
            & \multicolumn{5}{c|}{$t_0$}\\
            \cline{3-9}
    \multicolumn{2}{c|}{} & \multicolumn{7}{c|}{Mainteance Time $MT_1$} \\
    \cline{3-9}
    \end{tabular}%
    \kern19.5mm 
\newline
\begin{tabular}{%
      >{\bfseries}lc|>{\quad}c
      *{4}{c|}c>{\quad}c
      *{4}{c|}c>{\quad}c
      *{2}{c|}c%
    }%
      &
      \head{Data Dimensions} &
      &
      \head{Single Input/Output} &
      \head{Statc Rates} &
      \head{Hierachical Memory} &
      \head{Complex Data Movement} &
      \headNoLine{Single Kernel Execution} &
      &
      \head{Application graph} &
      \head{Implicit memory access} &
      \head{Theoretical Framework} &
      \head{Out-of-band control} &
      \headNoLine{Real-time constraints} &
      &
      \head{Data Parallelism} &
      \head{Pipeline Parallelism} &
      \headNoLine{Task Parallelism}
      \\
      \sbox0{S}%
      \rule{0pt}{\dimexpr\ht0 + 2ex\relax}%
      StreamIt & \textcolor{tabred}{\bfseries 1} &&
      \redtriangle & \redtriangle & & & &&
      \greenbullet & \greenbullet & \orangecirc & \greenbullet & &&
      \greenbullet & \greenbullet & \greenbullet
      \\\hline
      StreamC/KernelC & \textcolor{tabred}{\bfseries 1} &&
      & & & & \redtriangle &&
      \greenbullet & \greenbullet & & \greenbullet & &&
      \greenbullet & &
      \\\hline
      SDF & \textcolor{tabred}{\bfseries 1} &&
      & \redtriangle & & & &&
      \greenbullet & \greenbullet & \greenbullet & & &&
      & \greenbullet & \greenbullet
      \\\hline
      MDSDF & \textcolor{tabgreen}{\bfseries\itshape n} &&
      & \redtriangle & & \redtriangle & &&
      \greenbullet & \greenbullet & \greenbullet & & &&
      \greenbullet & \greenbullet & \greenbullet
      \\\hline
      ArrayOL & \textcolor{tabgreen}{\bfseries\itshape n} &&
      & \redtriangle & & \redtriangle & &&
      \greenbullet & \greenbullet & \orangecirc & & &&
      \greenbullet & \greenbullet & \greenbullet
      \\\hline
      Brook & \textcolor{tabgreen}{\bfseries\itshape n} &&
      & & & & \redtriangle &&
      & \greenbullet & & & &&
      \greenbullet & &
      \\\hline
      Sequoia & \textcolor{tabgreen}{\bfseries\itshape n} &&
      & & \redtriangle & \redtriangle & \redtriangle &&
      & & & & &&
      \greenbullet & &
      \\\hline
      \rowcolor{tabyellow}%
      Block-parallel & \textcolor{tabbrown}{\bfseries 2} &&
      & \redtriangle & & & &&
      \greenbullet & \greenbullet & \orangecirc & \greenbullet &
        \greenbullet &&
      \greenbullet & \greenbullet & \greenbullet
      \\[.5ex]
      \multicolumn{3}{c}{} &
      \multicolumn{5}{c}{\bfseries Limitations} &&
      \multicolumn{5}{c}{\bfseries Features} &&
      \multicolumn{3}{c}{\bfseries Parallelism}
      \\
    \end{tabular}%
    \kern19.5mm % manually with the help of the next \vrule
    % \vrule height 50mm
\end{document}

Except for the gap between the title row and the first data raw, it is working great (not so bad for a beginner...).

Diagonale Titles with Gap

Do you know I can reduce / delete this Gap between the first rows??.

I try to modify several parameters, but unefortunately, it does nothing. I think the problem is in vcorr,

\newcommand*{\vcorr}{%
      \vadjust{\vspace{-\dp\csname @arstrutbox\endcsname}}%
      \global\let\vcorr\relax
    }

I don't understand the behavior, nor the goal of @arstrutbox. In fact, I found very few information about it...

Furthermore if someone can explain me how I could push my horizontal text in multiline...? Think, I will have to use some cosinus and sinus function to do a perfect behavior...

Many thanks for your support

Bernard
  • 271,350
Dede Vince
  • 21
  • 2
  • 1
    Welcome to TeX.SX! booktabs rules (\toprule and the like) don't go along with vertical rules. – egreg Feb 04 '18 at 22:53

2 Answers2

1

You have to use the \specialrule command, with a padding above and below equal to 0pt to remove the gape. I took the liberty to replace the \head commands with a simpler (in my opinion) \myrothead command, which makes the column heads have zero width, and a \rotatebox{45}{{\phantom{longest head}} to compensate for the vertical spacing.

Note the second table is too large to fit on the page, so perhaps you should consider swapping rows and columns:

\documentclass{article}
\usepackage[utf8]{inputenc} 

\usepackage[T1]{fontenc} 
\usepackage{booktabs, multirow} 
\usepackage[table]{xcolor} 
\usepackage{rotating, graphicx}
\usepackage{amsmath, amssymb} 
\usepackage{bbding} 
\newcommand*{\redtriangle}{\ensuremath{\color{red}{\triangle}}}
\newcommand*{\greencheck}{\ensuremath{\color{green}{\XSolidBrush}}}
\newcommand*{\greenbullet}{\color{green}{\textbullet}}
\newcommand*{\orangecirc}{\ensuremath{\color{orange}{\circ}}}
\colorlet{tabred}{red}
\colorlet{tabgreen}{green}
\colorlet{tabyellow}{yellow}
\colorlet{tabbrown}{brown}

    \usepackage{makecell}
    \newcolumntype{M}{>{\centering\arraybackslash}m{3mm}}

    \renewcommand*{\arraystretch}{1.5}%

    \newcommand\myrothead[1]{ \multicolumn{1}{c}{\rothead {\rlap{#1}}}}
    \usepackage{lipsum}
    \begin{document}
    \lipsum[2]
    \renewcommand{\theadfont}{\small}
    \renewcommand{\cellrotangle}{45}
    \begin{tabular}{%
           >{\bfseries}rM|M|M|M|M|M|M|M|M|M|M%
        }%
    \rotatebox{45}{\phantom{\theadfont Maintenance}} & \myrothead{Maintenance}
        & \myrothead{Flight n-i} 
        & \multicolumn{5}{c}{\thead[b]{$n^\text{th}$ - Flight Conditions}}{5}
        &\myrothead {Flight n+i}
        & \myrothead{Maintenance}
        \\
 \specialrule{\heavyrulewidth}{0pt}{0pt}%\toprule%\addlinespace[-\belowrulesep]
 \sbox0{S}%
 \rule{0pt}{\dimexpr\ht0 + 2ex\relax}%
        Repercussion Phase
                & {\cellcolor{blue!25}} & \cellcolor{gray!25}\greencheck
                &\greencheck &\greencheck & \greencheck
                &\greencheck & \greencheck & \cellcolor{gray!25}\greencheck
                & {\cellcolor{blue!25}}\\
        \hline
        S1 Detection
                & {\cellcolor{blue!25}} & \cellcolor{gray!25}\redtriangle
                & \redtriangle & \redtriangle & \redtriangle
                & \redtriangle & \redtriangle & \cellcolor{gray!25}\redtriangle
                & {\cellcolor{blue!25}}\\
        \hline
        Risk Time
                & {\cellcolor{blue!25}} & \cellcolor{gray!25}\greencheck
                &\greencheck & \greencheck & \greencheck
                &\greencheck&\greencheck& \cellcolor{gray!25}\greencheck
                & {\cellcolor{blue!25}}\\
        \hline
        \multicolumn{3}{c|}{\multirow{2}{*}{Time(s)}}
                & \multicolumn{5}{c|}{$t_0$}\\
                \cline{3-9}
        \multicolumn{2}{c|}{} & \multicolumn{7}{c|}{Maintenance Time $MT_1$} \\
        \cline{3-9}
        \end{tabular}%
        \kern19.5mm
    \newline
    \begin{tabular}{%
          >{\bfseries}lc|>{\quad}c
          *{4}{c|}c>{\quad}c
          *{4}{c|}c>{\quad}c
          *{2}{c|}c%
        }%
    \rotatebox{45}{\phantom{\theadfont Complex Data Movement}}
          &
          \myrothead{Data Dimensions} &
          &
          \myrothead{Single Input/Output} &
          \myrothead{Statc Rates} &
          \myrothead{Hierachical Memory} &
          \myrothead{Complex Data Movement} &
          \myrothead{Single Kernel Execution} &
          &
          \myrothead{Application graph} &
          \myrothead{Implicit memory access} &
          \myrothead{Theoretical Framework} &
          \myrothead{Out-of-band control} &
          \myrothead{Real-time constraints} &
          &
          \myrothead{Data Parallelism} &
          \myrothead{Pipeline Parallelism} &
          \myrothead{Task Parallelism}
          \\
          \sbox0{S}%
          \rule{0pt}{\dimexpr\ht0 + 2ex\relax}%
          StreamIt & \textcolor{tabred}{\bfseries 1} &&
          \redtriangle & \redtriangle & & & &&
          \greenbullet & \greenbullet & \orangecirc & \greenbullet & &&
          \greenbullet & \greenbullet & \greenbullet
          \\\hline
          StreamC/KernelC & \textcolor{tabred}{\bfseries 1} &&
          & & & & \redtriangle &&
          \greenbullet & \greenbullet & & \greenbullet & &&
          \greenbullet & &
          \\\hline
          SDF & \textcolor{tabred}{\bfseries 1} &&
          & \redtriangle & & & &&
          \greenbullet & \greenbullet & \greenbullet & & &&
          & \greenbullet & \greenbullet
          \\\hline
          MDSDF & \textcolor{tabgreen}{\bfseries\itshape n} &&
          & \redtriangle & & \redtriangle & &&
          \greenbullet & \greenbullet & \greenbullet & & &&
          \greenbullet & \greenbullet & \greenbullet
          \\\hline
          ArrayOL & \textcolor{tabgreen}{\bfseries\itshape n} &&
          & \redtriangle & & \redtriangle & &&
          \greenbullet & \greenbullet & \orangecirc & & &&
          \greenbullet & \greenbullet & \greenbullet
          \\\hline
          Brook & \textcolor{tabgreen}{\bfseries\itshape n} &&
          & & & & \redtriangle &&
          & \greenbullet & & & &&
          \greenbullet & &
          \\\hline
          Sequoia & \textcolor{tabgreen}{\bfseries\itshape n} &&
          & & \redtriangle & \redtriangle & \redtriangle &&
          & & & & &&
          \greenbullet & &
          \\\hline
          \rowcolor{tabyellow}%
          Block-parallel & \textcolor{tabbrown}{\bfseries 2} &&
          & \redtriangle & & & &&
          \greenbullet & \greenbullet & \orangecirc & \greenbullet &
            \greenbullet &&
          \greenbullet & \greenbullet & \greenbullet
          \\[.5ex]
          \multicolumn{3}{c}{} &
          \multicolumn{5}{c}{\bfseries Limitations} &&
          \multicolumn{5}{c}{\bfseries Features} &&
          \multicolumn{3}{c}{\bfseries Parallelism}
          \\
        \end{tabular}%
        \kern19.5mm % manually with the help of the next \vrule
        % \vrule height 50mm

    \end{document} 

enter image description here

Bernard
  • 271,350
  • Thakns Bernard for the proposition. I would like to keep the borders around the text set in the first row. I try to add the | , but it generates vertical lines and not 45deg lines... :( I add the \specialrule... but it changes nothing. – Dede Vince Feb 05 '18 at 22:33
  • @DedeVince: I'm afarid I don't see what you mean: the table I Ihave here is the same as the table produced by the code you posted, after I've completed it to make it compilable. Could you explain more what you want exactly? Or maybe post an image of the result you obtain? – Bernard Feb 05 '18 at 22:55
  • On my initial view , the column titles are set with 45° lines separator. Unfortunately, I can't create such 45deg lines with your proposition. When I used the traditional | to create the vertical separator, I have a vertical line, crossing the text of the first line... I try to use the specialrule, but the gap remains. – Dede Vince Feb 07 '18 at 22:36
  • Did you try with the \specialrule command, (I suppressed all no vertical padding around the rule)? – Bernard Feb 07 '18 at 22:58
  • Yes.... :) Did it, I don't know why ny first tries with specialrule where not concluant, but now it is. I will provide my code latter, now I need to go work :( Thanks @Bernard – Dede Vince Feb 08 '18 at 22:59
0

Thanks @Bernard, I modify the code. Here, the code used for the head description

\usepackage{pifont}
\usepackage{makecell}
\newcolumntype{M}{>{\centering\arraybackslash}m{3mm}}
\renewcommand*{\arraystretch}{1.5}
\newcommand*{\headformat}[1]{{\small#1}}
    \newcommand*{\HeadAux}[5]{%
      \multicolumn{#2}{@{}#3@{}}{%
        \sbox0{\headformat{\strut #1}}%
        \sbox2{\headformat{Maintenance}}%
        \sbox4{\kern\tabcolsep\redtriangle\kern\tabcolsep}%
        \sbox0{\raisebox{0.25\dimexpr\dp0-\ht0\relax}[0pt][0pt]{\unhcopy0}}%
        \dimen0=\dimexpr\wd2+0.5\wd4\relax
       \ifx\HeadLine Y% 
          \rlap{\rotatebox{#5}{\hbox{\vrule width\dimen0 height .4pt}}}%
        \fi
        \kern.75\wd4 %
        \rlap{%
          \raisebox{0.1\wd4}{\rotatebox{#4}{\unhcopy0}}%
        }%
        \kern.25\wd4 %
        \ifx\HeadLine Y%
          \rlap{\rotatebox{#5}{\hbox{\vrule width\dimen0 height .4pt}}}%
        \fi
      }%
    }%
    \newcommand*{\head}[1]{\HeadAux{\global\let\HeadLine=Y#1} {1} {r} {45} {45}}%
    \newcommand*{\headNoLine}[1]{\HeadAux{\global\let\HeadLine=N#1} {1} {r} {45} {45}}%
    \newcommand*{\headmulti}[2]{\HeadAux{\global\let\HeadLine=N#1} {#2} {l} {0} {45}}%

And I create the table thanks the following lines:

\begin{tabular}{%
       >{\bfseries}rM|M|M|M|M|M|M|M|M|M|M%
    }%

    & \head{Maintenance}
    & \head{Flight n-i}
    & \headmulti{\thead{$n^{th}$ - Flight Conditions}}{5}
    & \head{Flight n+i}
    & \head{Maintenance}\\
    \specialrule{\heavyrulewidth}{-5.5pt}{0pt}%\toprule%\addlinespace[-\belowrulesep]
    Repercussion Phase 
            & {\cellcolor{blue!25}}  & \cellcolor{gray!25}\greencheck
            &\greencheck &\greencheck & \greencheck 
            &\greencheck & \greencheck &  \cellcolor{gray!25}\greencheck 
            & {\cellcolor{blue!25}}\\ 
    \hline
    S1 Detection 
            & {\cellcolor{blue!25}}  & \cellcolor{gray!25}\redtriangle
            & \redtriangle & \redtriangle & \redtriangle 
            & \redtriangle & \redtriangle &  \cellcolor{gray!25}\redtriangle 
            & {\cellcolor{blue!25}}\\ 
    \hline
    Risk Time 
            & {\cellcolor{blue!25}}  & \cellcolor{gray!25}\greencheck 
            &\greencheck & \greencheck & \greencheck 
            &\greencheck&\greencheck&  \cellcolor{gray!25}\greencheck
            & {\cellcolor{blue!25}}\\
    \hline
    \multicolumn{3}{c|}{\multirow{2}{*}{Time(s)}}
            & \multicolumn{5}{c|}{$t_0$}\\
            \cline{3-9}
    \multicolumn{2}{c|}{} & \multicolumn{7}{c|}{Mainteance Time $MT_1$} \\
    \cline{3-9}
    \end{tabular}%

The {\heavyrulewidth}{-5.5pt}{0pt}... should be tune manually to avoid the gap between the head and the subpart of the table.

Dede Vince
  • 21
  • 2