I just started learning latex and needed a kind of table like what the uploaded picture shows. The code was generated by Excel2LaTex. I have tried some ways but cannot make it.
Several cells in the lower left corner of the table are merged. The command \tabular
cannot make the table adaptively adjust the width to the whole row. If I use \resizebox
, the height of the table will increase together, which will be very unsightly. So I used \tabularx
but it always went wrong…Although I knew that \tabular
cannot be simply replaced by \tabularx
, I had no idea dealing with it…
So I come here for help. By the way, if it is really difficult, the big fork in the big cell can not be used. After all, this is drawn by Excel and it is very simple there.
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
order & number & weight & order & number & weight \\
\hline
1 & 1 & 1 & 1 & 1 & 1 \\
\hline
2 & 2 & 2 & 2 & 2 & 2 \\
\hline
3 & 3 & 3 & 3 & 3 & 3 \\
\hline
... & ... & ... & ... & ... & ... \\
\hline
118 & 118 & 118 & 118 & 118 & 118 \\
\hline
119 & 119 & 119 & 119 & 119 & 119 \\
\hline
120 & 120 & 120 & 120 & 120 & 120 \\
\hline
\multicolumn{3}{|c|}{\multirow{4}[8]{*}{}} & ... & ... & ... \\
\cline{4-6} \multicolumn{3}{|c|}{} & 138 & 138 & 138 \\
\cline{4-6} \multicolumn{3}{|c|}{} & 139 & 139 & 139 \\
\cline{4-6} \multicolumn{3}{|c|}{} & 140 & 140 & 140 \\
\hline
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
I also tried tablesgenerator website. It gave me the following code:
% Please add the following required packages to your document preamble:
% \usepackage{multirow}
\begin{table}[]
\caption{}
\label{tab:my-table}
\begin{tabular}{|ccc|c|c|c|}
\hline
\multicolumn{1}{|c|}{order} & \multicolumn{1}{c|}{number} & weight & order & number & weight \\ \hline
\multicolumn{1}{|c|}{1} & \multicolumn{1}{c|}{1} & 1 & 1 & 1 & 1 \\ \hline
\multicolumn{1}{|c|}{2} & \multicolumn{1}{c|}{2} & 2 & 2 & 2 & 2 \\ \hline
\multicolumn{1}{|c|}{3} & \multicolumn{1}{c|}{3} & 3 & 3 & 3 & 3 \\ \hline
\multicolumn{1}{|c|}{...} & \multicolumn{1}{c|}{...} & ... & ... & ... & ... \\ \hline
\multicolumn{1}{|c|}{118} & \multicolumn{1}{c|}{118} & 118 & 118 & 118 & 118 \\ \hline
\multicolumn{1}{|c|}{119} & \multicolumn{1}{c|}{119} & 119 & 119 & 119 & 119 \\ \hline
\multicolumn{1}{|c|}{120} & \multicolumn{1}{c|}{120} & 120 & 120 & 120 & 120 \\ \hline
\multicolumn{3}{|c|}{\multirow{4}{*}{}} & ... & ... & ... \\ \cline{4-6}
\multicolumn{3}{|c|}{} & 138 & 138 & 138 \\ \cline{4-6}
\multicolumn{3}{|c|}{} & 139 & 139 & 139 \\ \cline{4-6}
\multicolumn{3}{|c|}{} & 140 & 140 & 140 \\ \hline
\end{tabular}
\end{table}
@Mico: I didn't know how to insert a lot of code into the comments, so I answered my own question here. It's just an information table and I want it to look better. The following code has integrated Mico's code.
\documentclass{article}
\usepackage[english]{babel}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\usepackage{gensymb}
\usepackage{multirow,tabularx,ragged2e,booktabs,longtable}
\newcolumntype{C}{>{\Centering}X} % centered version of X col. type
\usepackage[skip=0.333\baselineskip]{caption}
\begin{document}
\begin{table}[htbp]
\caption{Fast Hankel Transform} \label{FHT}
\begin{tabularx}{\linewidth}{|*{6}{C|}}
\hline
Order & Abscissa of $J_0$ & Weight of $J_0$ & Order & Abscissa of $J_1$ & Weight of $J_1$ \\\hline
1 & $-19.32$ & $9.63\times10^{-7}$ & 1 & $-18.21$ & $-6.77\times10^{-14}$ \\\hline
2 & $-19.11$ & $-5.02\times10^{-6}$ & 2 & $-18.01$ & $3.40\times10^{-13}$ \\\hline
3 & $-18.90$ & $1.25\times10^{-5}$ & 3 & $-17.81$ & $-7.43\times10^{-13}$ \\\hline
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\\hline
118 & $5.04$ & $6.23\times10^{-6}$ & 118 & $5.49$ & $7.33\times10^{-6}$ \\\hline
119 & $5.25$ & $-1.12\times10^{-6}$ & 119 & $5.69$ & $-3.76\times10^{-6}$ \\\hline
120 & $5.46$ & $1.04\times10^{-7}$ & 120 & $5.89$ & $1.86\times10^{-6}$ \\\hline
\multicolumn{3}{|c|} {\multirow{4}{*}{}} & $\vdots$ & $\vdots$ & $\vdots$ \\
\cline{4-6} \multicolumn{3}{|c|}{} & 138 & $9.54$ & $-1.36\times10^{-9}$ \\
\cline{4-6} \multicolumn{3}{|c|}{} & 139 & $9.74$ & $3.53\times10^{-10}$ \\
\cline{4-6} \multicolumn{3}{|c|}{} & 140 & $9.94$ & $-4.54\times10^{-11}$ \\ \hline
\end{tabularx}
\end{table}
\end{document}
Best Answer
Here are two possible solutions. Both take up the full width of the textblock. The first uses a
tabularx
environments (with centered versions of theX
column type), and the second uses atabular*
-inspiredlongtable
environment.The two major differences between the tables is that second (a) gets rid of all vertical lines and most horizontal lines in order to give the table a more open and inviting "look" and (b) allows page breaks, as needed, which may be useful since the real table may have as many as 140 rows.
Addendum to incorporate additional information provided by the OP: Here's a variant of the
tabularx
-based solution which (a) allows columns 1 and 4 to be narrower than columns 2, 3, 5, and 6 and (b) allows the numbers in the latter four columns to be aligned on their decimal markers, with the help of theS
column type provided by thesiunitx
package.