如何在表格中获得一条长水平线

如何在表格中获得一条长水平线

我有一张 14 列的表格,我用它绘制了它tabu,现在水平线很快就停止了。

\documentclass[a4paper,french,12pt,oneside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[a4paper]{geometry}
\usepackage[french]{babel} %langue francaise
\usepackage{multirow,array}
%\usepackage{longtable}%pour la liste des symbole en format tableau
\usepackage{tabu}
\usepackage{siunitx}
    \usepackage{setspace}
    \usepackage{float}
    \begin{document}
       \begin{table}[H]
    \footnotesize\setlength{\tabcolsep}{2.5pt}
    \begin{tabu}{l*{14}{c}}
    \toprule
    Supports& \multicolumn{14}{c}{Espèces chimiques (\si{\percent})}\\
    \midrule
    &\ch{MgO}&\ch{Al2O3}&\ch{SiO2}&\ch{P2O5}&\ch{SO3}&\ch{Cl}&\ch{K2O}&\ch{CaO}&\ch{TiO2}&\ch{Fe2O3}&\ch{ZnO}&\ch{MnO}&\ch{Ba}\\
    C.A.S&5,7&3,5&17,9&5,6&5,61&19,0&19,4&15,4&0,5&4,7&0,9&0,04&0,0\\
    C.A.C&3,6&4,8&11,2&2,8&1,2&2,2&22,2&23,1&1,27&0,8&0,9&0,8&0,1\\
    \bottomrule
    \addlinespace
    \multicolumn{15}{l}{C.A.S: Charbon Actif Synthétique}\\
    \multicolumn{15}{l}{C.A.C: Charbon Actif Commercial}
    \end{tabu}
    \end{table}
    ~\\
    \end{document}

在此处输入图片描述

答案1

尝试一下\cline{1-14}。它有效。

\documentclass[a4paper,french,12pt,oneside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[a4paper]{geometry}
\usepackage[french]{babel} %langue francaise
\usepackage{multirow,array}
%\usepackage{longtable}%pour la liste des symbole en format tableau
\usepackage{tabu}
\usepackage{siunitx}
    \usepackage{setspace}
    \usepackage{float}
\newcommand{\ch}{}
    \begin{document}
       \begin{table}[H]
    \footnotesize\setlength{\tabcolsep}{2.5pt}
    \begin{tabu}{l*{14}{c}}
    \cline{1-14}
    Supports& \multicolumn{13}{c}{Espèces chimiques (\si{\percent})}\\
    \cline{1-14}
    &\ch{MgO}&\ch{Al2O3}&\ch{SiO2}&\ch{P2O5}&\ch{SO3}&\ch{Cl}&\ch{K2O}&\ch{CaO}&\ch{TiO2}&\ch{Fe2O3}&\ch{ZnO}&\ch{MnO}&\ch{Ba}\\
    C.A.S&5,7&3,5&17,9&5,6&5,61&19,0&19,4&15,4&0,5&4,7&0,9&0,04&0,0\\
    C.A.C&3,6&4,8&11,2&2,8&1,2&2,2&22,2&23,1&1,27&0,8&0,9&0,8&0,1\\
    \cline{1-14}
    \addlinespace
    \multicolumn{15}{l}{C.A.S: Charbon Actif Synthétique}\\
    \multicolumn{15}{l}{C.A.C: Charbon Actif Commercial}
    \end{tabu}
    \end{table}
    ~\\
    \end{document}

在此处输入图片描述

答案2

如果你做了一个最小例子。

\documentclass{article}


\usepackage{array}

\usepackage{booktabs}

\begin{document}


\noindent X\dotfill X

\begin{tabular}{*{5}{c}}
\toprule
xxxx&yyyy&zzzzz\\
1&2&3\\
\bottomrule
\multicolumn{5}{l}{C.A.C}
\end{tabular}

\bigskip

\begin{tabular}{*{3}{c}}
\toprule
xxxx&yyyy&zzzzz\\
1&2&3\\
\bottomrule
\multicolumn{3}{l}{C.A.C}
\end{tabular}


\end{document}

如这里所示,booktabs如果您指定了太多列,则会产生这种效果。您有 14 列,而不是 15 列。如果您测试示例\ch是否在发布的问题中定义,也会有所帮助。

更正后的表格如下

在此处输入图片描述

\documentclass[a4paper,french,12pt,oneside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[a4paper]{geometry}
\usepackage[french]{babel} %langue francaise
\usepackage{multirow,array}
%\usepackage{longtable}%pour la liste des symbole en format tableau
\usepackage{tabu}
\usepackage{siunitx}
\def\ch{}
    \usepackage{setspace}
    \usepackage{float}
    \begin{document}
       \begin{table}[H]
    \footnotesize\setlength{\tabcolsep}{2.5pt}
    \begin{tabu}{l*{13}{c}}
    \toprule
    Supports& \multicolumn{13}{c}{Espèces chimiques (\si{\percent})}\\
    \midrule
    &\ch{MgO}&\ch{Al2O3}&\ch{SiO2}&\ch{P2O5}&\ch{SO3}&\ch{Cl}&\ch{K2O}&\ch{CaO}&\ch{TiO2}&\ch{Fe2O3}&\ch{ZnO}&\ch{MnO}&\ch{Ba}\\
    C.A.S&5,7&3,5&17,9&5,6&5,61&19,0&19,4&15,4&0,5&4,7&0,9&0,04&0,0\\
    C.A.C&3,6&4,8&11,2&2,8&1,2&2,2&22,2&23,1&1,27&0,8&0,9&0,8&0,1\\
    \bottomrule
    \addlinespace
    \multicolumn{14}{l}{C.A.S: Charbon Actif Synthétique}\\
    \multicolumn{14}{l}{C.A.C: Charbon Actif Commercial}
    \end{tabu}
    \end{table}
%NO!!    ~\\
    \end{document}

答案3

这可以单独完成tabular,我认为在这里使用没有什么好处tabu

hamzaTabularLine

\documentclass[french]{memoir}
\usepackage{babel}
\usepackage{chemmacros}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{table}
    \footnotesize\setlength{\tabcolsep}{2.5pt}
    \begin{tabular}{l*{14}{c}}
        \toprule
        Supports& \multicolumn{13}{c}{Espèces chimiques (\si{\percent})}\\
        \midrule
        &\ch{MgO}&\ch{Al2O3}&\ch{SiO2}&\ch{P2O5}&\ch{SO3}&\ch{Cl}&\ch{K2O}&\ch{CaO}&\ch{TiO2}&\ch{Fe2O3}&\ch{ZnO}&\ch{MnO}&\ch{Ba}\\
        C.A.S&5,7&3,5&17,9&5,6&5,61&19,0&19,4&15,4&0,5&4,7&0,9&0,04&0,0\\
        C.A.C&3,6&4,8&11,2&2,8&1,2&2,2&22,2&23,1&1,27&0,8&0,9&0,8&0,1\\
        \bottomrule
    \end{tabular}\smallbreak
        {C.A.S: Charbon Actif Synthétique}\par
        {C.A.C: Charbon Actif Commercial}
\end{table}
\end{document}

即使列数不正确,您也可以使用p-column 来巧妙地使用正确(估计)的宽度。

但我甚至会改变整个桌子。

hamzaTabularLine旧

\documentclass{memoir}
\usepackage{siunitx}
\usepackage{chemmacros}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{table}
    \footnotesize\setlength{\tabcolsep}{2.5pt}
    \begin{tabular}{l*{14}{c}}
        \toprule
        Supports& \multicolumn{14}{>{\centering}p{.86\linewidth}}{Espèces chimiques (\si{\percent})}\\
        \midrule
        &\ch{MgO}&\ch{Al2O3}&\ch{SiO2}&\ch{P2O5}&\ch{SO3}&\ch{Cl}&\ch{K2O}&\ch{CaO}&\ch{TiO2}&\ch{Fe2O3}&\ch{ZnO}&\ch{MnO}&\ch{Ba}\\
        C.A.S&5,7&3,5&17,9&5,6&5,61&19,0&19,4&15,4&0,5&4,7&0,9&0,04&0,0\\
        C.A.C&3,6&4,8&11,2&2,8&1,2&2,2&22,2&23,1&1,27&0,8&0,9&0,8&0,1\\
        \bottomrule
    \end{tabular}\smallbreak
        {C.A.S: Charbon Actif Synthétique}\par
        {C.A.C: Charbon Actif Commercial}
\end{table}

\begin{tabular}{cSS}
    \toprule
    {Espèces chimiques (\si{\percent})} & {CAS} & {CAC} \\
    \midrule
    \ch{MgO} & 5.7 & 3.6 \\
    \ch{Al2O3} & 3.5 & 4.8 \\
    \ch{TiO2} & 0.5 & 1.27 \\
    \bottomrule
\end{tabular}



%~\\ % BAD
\end{document}

相关内容