0

How can I make the table row and column widths adjustable?

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
 \usepackage{booktabs}
 \usepackage{multirow}
 \usepackage{longtable}
 \usepackage{mathtools}
\begin{document}

\begin{table}[]
\resizebox{\textwidth}{!}{%
\begin{tabular}{@{}cccllll@{}}
\toprule
No                 & TYPE & \multicolumn{2}{c}{X}                 & \multicolumn{1}{c}{Y} & \multicolumn{1}{c}{Z} & \multicolumn{1}{c}{T} \\ \midrule
\multirow{2}{*}{1} & A    & \multicolumn{2}{c}{\multirow{2}{*}{$\begin{aligned}
    M &= -\frac{1}{D} \\
    d &= e+f
  \end{aligned}$}} &   4th column                   & 5th column                      &  6th column                     \\ \cmidrule(lr){2-2} \cmidrule(l){5-7} 
                   & B    & \multicolumn{2}{c}{}                  &                       &                       &                       \\ \midrule
\multirow{2}{*}{2} & C    & \multicolumn{2}{c}{\multirow{2}{*}{}} &                       &                       &                       \\ \cmidrule(lr){2-2} \cmidrule(l){5-7} 
                   & D    & \multicolumn{2}{c}{}                  &                       &                       &                       \\ \bottomrule
\end{tabular}%
}
\end{table}




\end{document}

2 Answers 2

1

Dont't scale table. Keep the font size in line with the requirements of the journal.

\documentclass{IEEEtran}
\usepackage{tabularray}
\usepackage{lipsum}
\begin{document}
\begin{table*}
\caption{title}
\begin{tblr}
{
colspec      = {Q[c,m]Q[c,m]Q[c,m]X[c,m]X[c,m]X[c,m]},
hline{1,Z}   = {wd=.08em},
hline{2,4}   = {wd=.05em},
hline{3,5}   = {2}{wd=.05em},
hline{3,5}   = {4-Z}{wd=.05em},
cell{2,4}{1} = {r=2}{},
}
No & TYPE & X                & Y          & Z          & T          \\
1  & A    & $M=-\frac{1}{D}$ & 4th column & 5th column & 6th column \\
   & B    & $d=e+f$          &            &            &            \\
2  & C    &                  &            &            &            \\
   & D    &                  &            &            &            \\
\end{tblr}
\end{table*}
\lipsum
\begin{table}
\caption{title}
\begin{tblr}
{
colspec      = {Q[c,m]Q[c,m]Q[c,m]X[c,m]X[c,m]X[c,m]},
hline{1,Z}   = {wd=.08em},
hline{2,4}   = {wd=.05em},
hline{3,5}   = {2}{wd=.05em},
hline{3,5}   = {4-Z}{wd=.05em},
cell{2,4}{1} = {r=2}{},
}
No & TYPE & X                & Y          & Z          & T          \\
1  & A    & $M=-\frac{1}{D}$ & 4th column & 5th column & 6th column \\
   & B    & $d=e+f$          &            &            &            \\
2  & C    &                  &            &            &            \\
   & D    &                  &            &            &            \\
\end{tblr}
\end{table}
\begin{table}
\caption{title}
\begin{tblr}
{
colspec      = {Q[c,m]Q[c,m]Q[c,m]X[c,m]X[c,m]X[c,m]},
hline{1,Z}   = {wd=.08em},
hline{2,4}   = {wd=.05em},
hline{3,5}   = {2}{wd=.05em},
hline{3,5}   = {4-Z}{wd=.05em},
cell{2,4}{1} = {r=2}{},
columns      = {colsep=3pt},
}
No & TYPE & X                & Y          & Z          & T          \\
1  & A    & $M=-\frac{1}{D}$ & 4th column & 5th column & 6th column \\
   & B    & $d=e+f$          &            &            &            \\
2  & C    &                  &            &            &            \\
   & D    &                  &            &            &            \\
\end{tblr}
\end{table}
\lipsum
\end{document}

enter image description here

2
  • Nice but how can I combine the rows in the third column?
    – emnha
    Mar 10, 2023 at 1:11
  • Just add cell{2,4}{3} = {r=2}{},. You can read the doc of tabularray. tabularray is very good to typeset table.
    – Clara
    Mar 10, 2023 at 1:14
1

Like this?

enter image description here

  • It is not clear why you use \multicolumn cells.
  • As I understood, in the first and third columns you have multi row cells
  • With tabularray is simple:
\documentclass[journal]{IEEEtran}
\usepackage{lipsum}

\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs}
\usepackage{mathtools}

\begin{document}
\lipsum[11]
    \begin{table}[ht]
\begin{tblr}{colspec = {@{} Q[c, m] c Q[c,mode=math] *{3}{X[l]} @{}},
             cell{even[2]}{1-3} = {r=2}{},   % multi row cell{<rows>}{<columns>}
             rowsep=3pt,
             vspan = even
             }
    \toprule
No  & TYPE  &   X   &   Y   &   Z   &   T   \\ 
    \midrule
1   & A & \begin{aligned}
            M & = -\frac{1}{D} \\
            d & = e + f
          \end{aligned} 
            &   4th column
                &   5th column
                &   6th column  \\
    \midrule
    & B &   &   &               \\
    \midrule
2   & C &   &   &               \\ 
    \midrule
    & D &   &   &               \\ 
    \bottomrule
\end{tblr}
    \end{table}
\end{document}
1
  • You're right. Somehow I got error misplace noalign.
    – emnha
    Mar 10, 2023 at 1:12

You must log in to answer this question.

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