3

I'd like to have a proper diagonal line in the top left cell - going from the top left corner to the right end corner. Moreover, the vertical lines in the main body of the table are not consistent, and I do not see how to fix that.

\documentclass[10pt]{article}
\textwidth= 5.00in
\textheight= 7.4in
\topmargin = 30pt
\evensidemargin=0pt
\oddsidemargin=55pt
\headsep=17pt
\parskip=.8pt
\parindent=12pt
\font\smallit=cmti10
\font\smalltt=cmtt10
\font\smallrm=cmr9

\usepackage{amssymb,amsmath} 
\usepackage{diagbox}

\makeatletter

\begin{document}

\begin{center}
\scriptsize
\begin{tabular}{||c|c|c|c|c||}
\hline
\backslashbox{1st scenario}{2nd scenario}& $(aaaaaaa,$ & $(aaaaaaa,$ & $(aaaaaaa,$ & $(aaaaaaa,$ \\ [0.5ex]
& $bbbbbbb)$ & $bbbbbbbb)$ & $bbbbbbbb)$ & $bbbbbbbb)$ \\ [0.5ex]
\hline\hline \\[0.15ex]
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\ 
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\  [1ex] 
\hline 
\end{tabular}
\end{center} 
\end{document}

enter image description here

2
  • Unrelated, you should remove the useless \makeatletter.
    – jlab
    Commented May 24 at 21:10
  • 1
    Your diagonal line is proper aligned. It seems that you may like that it should gov over two rows ... Is this a ca case what you after?
    – Zarko
    Commented May 24 at 21:14

3 Answers 3

5

With nicematrix you can use the \diagbox command in a \Block:

enter image description here

\documentclass[10pt]{article}
\textwidth= 5.00in
\textheight= 7.4in
\topmargin = 30pt
\evensidemargin=0pt
\oddsidemargin=55pt
\headsep=17pt
\parskip=.8pt
\parindent=12pt
\font\smallit=cmti10
\font\smalltt=cmtt10
\font\smallrm=cmr9

\usepackage{amssymb,amsmath} 
\usepackage{nicematrix}

\makeatletter

\begin{document}

\begin{center}
\scriptsize
\begin{NiceTabular}{||c|c|c|c|c||}
\hline
\Block{2-1}{\diagbox{1st scenario}{2nd scenario}}& $(aaaaaaa,$ & $(aaaaaaa,$ & $(aaaaaaa,$ & $(aaaaaaa,$ \\[0.5ex]
& $bbbbbbb)$ & $bbbbbbbb)$ & $bbbbbbbb)$ & $bbbbbbbb)$ \\[0.5ex]
\hline\hline \\[0.15ex]
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\ 
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\[1ex] 
\hline 
\end{NiceTabular}
\end{center} 
\end{document}
5

You probably looks for something like this:

enter image description here

what is according to my opinion not the best looking table. Anyway, above table is produced by:

\documentclass{article}
\usepackage{geometry}
\parindent=12pt

\usepackage{amssymb,amsmath} 
\usepackage{diagbox, 
            makecell} % <--- added

\begin{document}

\begin{center}
\scriptsize
\begin{tabular}{||c|c|c|c|c||}
    \hline
\backslashbox{\thead{1st scenario}}{\thead{2nd scenario}}
        & \thead{$(aaaaaaa,$\\ $bbbbbbb)$}   
            & \thead{$(aaaaaaa,$\\ $bbbbbbb)$}    
                & \thead{$(aaaaaaa,$\\ $bbbbbbb)$}  
                    & \thead{$(aaaaaaa,$\\ $bbbbbbb)$}  \\  
    \hline\hline 
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\ 
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\ 
    \hline 
\end{tabular}
\end{center} 
\end{document}

where contents of the first two rows are merged into one by use of thead instruction defined in the makecell package.

However, to my opinion the following table is more professional appealing:

enter image description here

By use of tblr from tabularray package the MWE is simpler and shorter in comparison to the first one:

\documentclass{article}
\usepackage{geometry}
\parindent=12pt

\usepackage{tabularray} 
\UseTblrLibrary{booktabs}


\begin{document}

    \begin{center}
\scriptsize
\begin{tblr}{colspec = {*{5}{c}},
             cell{1}{1} ={r=2}{},
             cell{1}{2} ={c=4}{}
             }
    \toprule
1st scenario    &   2nd scenario
                    &   &   &                               \\
    \midrule
                &   {$(aaaaaaa,$\\ $bbbbbbb)$}   
                    &   {$(aaaaaaa,$\\ $bbbbbbb)$}    
                        &   {$(aaaaaaa,$\\ $bbbbbbb)$}  
                            &   {$(aaaaaaa,$\\ $bbbbbbb)$}  \\  
    \midrule
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\ 
cccccccccccccccccccccccccccc & $ddddddd^1$ & $ddddddd^2$ & $ddddddd^3$ & $ddddddd^4$\\  [1ex] 
    \bottomrule
\end{tblr}
    \end{center}
 
\end{document}
3

You need to merge the two rows in the first cell, and/or set the \diagbox height with something like

\diagbox[height=2\baselineskip]{1st scenario}{2nd scenario}

May I suggest something with the tabularray package?

\documentclass[10pt]{article}

\usepackage{tabularray}
\UseTblrLibrary{diagbox}

\begin{document}

\begin{center}

  \begin{tblr}
    {
      colspec={||*{5}{Q[c,m]|}|},   % five columns, centered content
      hline{1}={1}{-}{},            % first hline
      hline{Z}={1}{-}{},            % last hline
      hline{2}={1}{-}{},            % double hline after the first row
      hline{2}={2}{-}{},
      cells={mode=math},            % all cells are in math mode
      column{1}={mode=text},        % except the first column
      row{1}={mode=text},           % and the first row (as multilined)
    }
    \diagbox[height=2\baselineskip]{1st scenario}{2nd scenario}
    & { ($aaaaaaa$, \\ $bbbbbbbb$) } % multilined cell
    & { ($aaaaaaa$, \\ $bbbbbbbb$) }
    & { ($aaaaaaa$, \\ $bbbbbbbb$) }
    & { ($aaaaaaa$, \\ $bbbbbbbb$) }
    \\[0.15ex]
    cccccccccccccccccccccccccccc & ddddddd^1 & ddddddd^2 & ddddddd^3 & ddddddd^4\\
    cccccccccccccccccccccccccccc & ddddddd^1 & ddddddd^2 & ddddddd^3 & ddddddd^4
\end{tblr}
\end{center}

\end{document}

tabularray example

You must log in to answer this question.

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