创建简单表格(含图片)

创建简单表格(含图片)

我很纠结。我想将除表 X、三个长单词和左侧面板(Bla of... + abcde)之外的几乎所有内容集中起来。感谢您的建议。

到目前为止我想到了这个:

\begin{table}

\caption{name}

\centering 

\begin{tabular}{llllllll}

\hline

~ & \multicolumn{5}{c}{Three long words}   \\ 

Blue of bla of ble  & 1 & 2 & 3 & 4 & 5  \\ \hline

A       &  10.2  & 10.2  &  10.2  &  10.2  &  10.2    \\

B       &   111.2 & 111.2 & 111.2 & 111.2 & 111.2 \\ \hline

\end{tabular}

\end{table}

但效果不太好。我想要创建的是:

我想要创造什么

答案1

这是一个可能的解决方案。请参阅下面的输入和相应的输出。

我做了一些改进,包括使用booktabs包(用于更好看的规则)和siunitx包(用于小数对齐),如所建议的休斯

在此处输入图片描述

\documentclass{article}

\usepackage[showframe]{geometry}    % only to show the position
                                    % of the tabular on the page
\usepackage{booktabs}   % this package promotes good tabular style
\usepackage{caption}    % for customising caption style
\usepackage{siunitx}    % for decimal alignment

\begin{document}

\begin{table}
    \captionsetup%
    {%
        singlelinecheck = off,  % for correct just. of single-line captions
        justification   = raggedright,
        labelfont       = bf,
    }
    \centering%
    \bfseries
    \begin{minipage}[b]{.7\textwidth}       % A minipage is convenient here;
                                            % its width may have to be adjusted.
        \caption{name}%
        \begin{tabular}{@{}l SSSSS }        % @{} removes the extra horizontal space
            \toprule
                                & \multicolumn{5}{l}{Three long words}  \\
            \cmidrule{2-6}

            Blue of bla of ble  & 1     & 2     & 3     & 4     & 5     \\
            \midrule
            A                   & 10.2  & 10.2  &  10.2 & 10.2  &  10.2 \\
            B                   & 111.2 & 111.2 & 111.2 & 111.2 & 111.2 \\
            \bottomrule
        \end{tabular}
    \end{minipage}
\end{table}

\end{document}

答案2

似乎您期望的是这样的(标记的变化):

\documentclass{article}

\begin{document}

\begin{table}

\caption{name}

\centering 

%\begin{tabular}{llllllll}
\begin{tabular}{l*5{c}}
\hline

%~ & \multicolumn{5}{c}{Three long words}   \\ 
~ & \multicolumn{5}{l}{ Three long words}   \\ 
\cline{2-6} % PS
Blue of bla of ble  & 1 & 2 & 3 & 4 & 5  \\ \hline

A       &  10.2  & 10.2  &  10.2  &  10.2  &  10.2    \\

B       &   111.2 & 111.2 & 111.2 & 111.2 & 111.2 \\ \hline

\end{tabular}

\end{table}
\end{document}

在此处输入图片描述

相关内容