1

diagonal split is not proper aligned. how to align it.

\documentclass{article}
\usepackage{tabularx,booktabs}
\usepackage{diagbox}

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|p{9em}|p{9.89em}|p{16.165em}|p{12.28em}|p{8.165em}|p{9.945em}|p{6.665em}|p{8.165em}|}
    \toprule
    \textbf{\diagbox[]{Mobility Model}{Parameter}} & \textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{e} & \textbf{f} & \textbf{g} \\
   \midrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%
\end{document}
Bernard
  • 271,350
monika
  • 127
  • 10
  • (i) your table is to wide that can be fit in the text width, (ii) diagbox doesn't work with rules from booktabs you should consider to use standard \hline – Zarko Mar 10 '19 at 07:29
  • i had also use \backslashbox but that is also not working – monika Mar 10 '19 at 07:34
  • \documentclass{article} \usepackage{tabularx,booktabs}\usepackage{slashbox} \usepackage{makecell} \begin{document}

    \begin{table}[htbp] \centering \caption{Add caption} \begin{tabular}{|p{9em}|p{9.89em}|p{16.165em}|p{12.28em}|p{8.165em}|p{9.945em}|p{6.665em}|p{8.165em}|} \hline\textbf{\backslash {Mobility Model}{Parameter}} & \textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{e} & \textbf{f} & \textbf{g} \\end{tabular}% \label{tab:addlabel}% \end{table}% \end{document}

    – monika Mar 10 '19 at 07:46
  • diagonally split cell (regardless which package you use for them) doesn't work with rules from booktabs package, because they add some vertical space above and below rules. you have , as i see, three choices: (i) not use diagonally split cells (as i suggest in answer below), (ii) use ordinary \hline for horizontal lines in table and (ii) remove vertical space around rules from booktabs. – Zarko Mar 10 '19 at 07:54

1 Answers1

3

i would not use diagbox. to my opinion is more clear and answer the following design of your table:

enter image description here

which is generated by:

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
  \label{tab:addlabel}%
    \begin{tabularx}{\linewidth}{c*{7}{X}}
    \toprule
    \multirow{2.4}*{\textbf{Mobility Model}}
        &   \multicolumn{7}{c}{\textbf{Parameter}}  \\
        \cmidrule{2-8}
        & \textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{e} & \textbf{f} & \textbf{g} \\
    \midrule
    \end{tabularx}%
\end{table}%
\end{document}

i select tabularx table environment ad assume, that all columns except first have equal width. if you would provide some row of table body (that we can see size of other cells contents) than i will be able to suggest different column width.

addendum: off course, proposed solution works at any columns type. for example, if you use p{...} columns, than the table definition can be:

    \begin{tabular}{l*{7}{p{3em}}}
    \toprule
    \multirow{2.4}*{\textbf{Mobility Model}}
        &   \multicolumn{7}{c}{\textbf{Parameter}}  \\
        \cmidrule{2-8}
        & \textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{e} & \textbf{f} & \textbf{g} \\
    \midrule
    \end{tabular}

similary you can select column types as you need (as i mentioned bewof, the contents of table is not known to me, so i can't help you in the design columns types).

this also work with longtable. only you need accordingly design heads for those table

Zarko
  • 296,517
  • yes it is a good option sir,thanks , but will the same work with \longtable if it is a long table of multipage table – monika Mar 10 '19 at 07:51
  • @monika, suggested approach works at any kind of table. – Zarko Mar 10 '19 at 07:55
  • the other cells are like \begin{table}[htbp]\centering \begin{tabular}{|p{9em}|p{9.89em}|p{16.165em}|p{12.28em}|p{8.165em}|p{9.945em}|p{6.665em}|p{8.165em}|} \hline \textbf{\diaghead{\theadfont Diag ColumnmnHead II}% {Mobility\ Model}{Para-\meter}} & \textbf{Basic Description} & \textbf{Adaptability for AANETs} & \textbf{Support to higher node mobility and Frequent topology updates} & \textbf{Safety parameters} & \textbf{Mechanical and aerodynamic constraint} & \textbf{Degree of Randomness} & \textbf{Applications} \ \hlineend{tabularx}%\end{table}%\end{document} – monika Mar 10 '19 at 08:01
  • @monika, i told you that this selection of columns width cannot be fit in page size. you should reduce their widths! and please, be so kind and edit your question, add this information there and show result, which you obtain. – Zarko Mar 10 '19 at 08:06
  • \begin{document}\begin{table}[htbp]\centering\begin{tabular}{|p{3em}|p{5em}|p{4em}|p{5em}|p{5em}|p{4em}|p{4em}|p{4em}|} \hline \multirow{2}{*}{\textbf{Mobility Model}} & \multicolumn{7}{c}{\textbf{Parameter}} \ \cmidrule{2-8}& \textbf{Basic Description} & \textbf{Adaptability for AANETs} & \textbf{Support to higher node mobility and Frequent topology updates} & \textbf{Safety parameters} & \textbf{Mechanical and aerodynamic constraint} & \textbf{Degree of Randomness} & \textbf{Applications} \ \hline end{tabular}%\label{tab:addlabel}%\end{table}%\end{document} – monika Mar 10 '19 at 08:33
  • still multi row data crossing the column – monika Mar 10 '19 at 08:34
  • @monika, please, please add this information to your question that they can see other members of site too. also in comments are not readable well. so far i can only conclude, that you have many issues with your table, which aren't related to your question. you should consider to ask new question with this new problems. it seems that https://tex.stackexchange.com/questions/332902/my-table-doesnt-fit-what-are-my-options can help you. – Zarko Mar 10 '19 at 08:43