1

Hopefully this is the last of my table questions.

I have never done a table like this before and I'm not sure how to set it up with multirow/column (i'm assuming there is no easier way).

Here is the code I have so far (I did not put the actual numbers in yet). I've been trying to use booktabs.

\documentclass[12pt, onecolumn]{article}
\usepackage{multicol, multirow, array}
\usepackage{calc}
\usepackage{colortbl}
\usepackage{geometry}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{arydshln}
\usepackage{booktabs}
\usepackage{bigstrut}

\begin{document}

    \begin{center}
    \begin{tabular}{|c|c|c|c|c|c|c|}
    \toprule
    \multicolumn{3}{|c|}{\multirow{3}[2]{*}{1}} & \multicolumn{3}{c|}{\multirow{4}[4]{*}{2}} & \multirow{3}[2]{*}{3} \\
    \multicolumn{3}{|c|}{} & \multicolumn{3}{c|}{} &  \\
    \multicolumn{3}{|c|}{} & \multicolumn{3}{c|}{} &  \\
\cmidrule{1-3}\cmidrule{7-7}    \multicolumn{3}{|c|}{4} & \multicolumn{3}{c|}{} & 5 \\
    \midrule
    \multicolumn{3}{|c|}{6} & \multicolumn{3}{c|}{7} & 8 \\
    \bottomrule
    \end{tabular}
 \end{center}

\end{document}

This is what the table looks like now:

enter image description here

and this is what it eventually needs to look like:

enter image description here

I've been using arrays instead of tabular for other tables but this one seems a bit too complicated to go that route.

Please help as I need to write several tables like this but with different orders (ie: the last row of the table will eventually need to be at the top). Thank you!

3

If you want this type of table, you do not need some of the styles you are loading.

\documentclass[12pt, onecolumn]{article}
\usepackage{multirow, array,arydshln}
\usepackage{geometry}
\begin{document}
\begin{center}
 \begin{tabular}{|c|c|c|}
    \hline
     & &  \\
    1 & & 3 \\
     & &  \\
    \cdashline{1-1} \cdashline{3-3} 
    4 &\multirow{-4}{*}{2} & 5\\ 
    \hline
    6 & 7 & 8\\ 
    \hline
 \end{tabular}
\end{center}
\end{document}

enter image description here

\documentclass[12pt, onecolumn]{article}
\usepackage{array}
\usepackage{arydshln}
\usepackage{bigstrut}
\usepackage{multirow}
\usepackage{geometry}
\begin{document}
\[
 \begin{array}{|>{\centering\bigstrut$}p{3cm}<{$}|>{\centering$}p{3cm}<{$}|c|}
    \hline
     & &  \\
    A & & b \\
     & &  \\
    \cdashline{1-1} \cdashline{3-3} 
    \bar c &\multirow{-4}{*}{$I_{(m+1)}$} & d\\ 
    \hline
    \bar 0_n & \bar 0_{(m+1)} & 0\\ 
    \hline
 \end{array}
\]
\end{document}

enter image description here

In order to get the 0s in the first row, you only need to move the row up in the TeX code.

\documentclass[12pt, onecolumn]{article}
\usepackage{array}
\usepackage{arydshln}
\usepackage{bigstrut}
\usepackage{multirow}
\usepackage{geometry}
\begin{document}
\[
 \begin{array}{|>{\centering\bigstrut$}p{3cm}<{$}|>{\centering$}p{3cm}<{$}|c|}
    \hline
    \bar 0_n & \bar 0_{(m+1)} & 0\\ 
    \hline
     & &  \\
    A & & b \\
     & &  \\
    \cdashline{1-1} \cdashline{3-3} 
    \bar c &\multirow{-4}{*}{$I_{(m+1)}$} & d\\ 
    \hline
 \end{array}
\]
\end{document}

enter image description here

5
  • Fantastic! When moving rows (say the last row of 0's needs to appear at the top) does {|>{\centering\bigstrut$}p{3cm}<{$}|>{\centering$}p{3cm}<{$}|c|} need to change? – Erika Olsen Dec 11 '19 at 16:31
  • 1
    @ErikaOlsen No. You can move the row up. \centering means that the cell content is centered, the argument of p is the width, and the \bigstrut gives the cells a bit padding. – user194703 Dec 11 '19 at 16:40
  • Thanks!! You're awesome! – Erika Olsen Dec 11 '19 at 16:42
  • 1
    @ErikaOlsen I cannot tell you what you are doing wrong because I do not know what you are doing but I just added a version with the 0s in the first line. (Will now be offline for a bit.) – user194703 Dec 11 '19 at 18:28
  • What do the & & do? haha sorry about my last comment – Erika Olsen Dec 11 '19 at 18:32

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.