tabularx \ linewidth调整不起作用

时间:2019-05-19 07:59:49

标签: latex tabular

我告诉tabularx将表格重新调整为\textwidth,但它不起作用(\linewidth也不起作用)。如果减小字体大小以达到期望的结果就可以了!

有趣的是,第一个\hline和最后一个\textwidth的大小已调整为\begin{table}[h!] \centering \caption{asdf} \begin{tabularx}{\linewidth}{ccllllllll} \hline & & \multicolumn{4}{c}{X = Gini} & \multicolumn{4}{c}{X = Selfishness} \\ \cline{3-10} Treatment & Round & \multicolumn{2}{c}{WMW} & \multicolumn{2}{c}{Schlag} & \multicolumn{2}{c}{WMW} & \multicolumn{2}{c}{Schlag} \\ & & \multicolumn{1}{c}{reduced} & \multicolumn{1}{c}{full} & \multicolumn{1}{c}{reduced} & \multicolumn{1}{c}{full} & \multicolumn{1}{c}{reduced} & \multicolumn{1}{c}{full} & \multicolumn{1}{c}{reduced} & \multicolumn{1}{c}{full} \\ \cline{3-10} \multirow{3}{*}{1} & 1 & .123*** & .123*** & .123*** & .123*** & .123*** & .123*** & .123*** & .123*** \\ & 2 & .123** & .123** & .123** & .123** & .123** & .123** & .123** & .123** \\ & 3 & .123* & .123* & .123* & .123* & .123* & .123* & .123* & .123* \\ \multirow{3}{*}{2} & 1 & .123 & .123 & .123 & .123 & .123 & .123 & .123 & .123 \\ & 2 & .123 & .123 & .123 & .123 & .123 & .123 & .123 & .123 \\ & 3 & .123 & .123 & .123 & .123 & .123 & .123 & .123 & .123 \\ \hline \end{tabularx} \end{table} ,但表的其余部分却没有(参见图片)。

任何帮助,我们将不胜感激。下面找到我示例的代码:

private void jButton1_LogInActionPerformed(java.awt.event.ActionEvent evt) {
    Connection con = MyConnection.getConnection();
   PreparedStatement ps;

    try {


        ps=con.prepareStatement("Select * from agent WHERE User_Name = ? AND Password = ?");
        ps.setString(1, jTextField1_UserName.getText());
        ps.setString(2, String.valueOf(jPasswordField1.getPassword()));


        ResultSet rs = ps.executeQuery();


        String Name = jTextField1_UserName.getText();
        if(rs.next())
        {
        String First_Name = rs.getString("First_Name");
        if(Name.equals(First_Name))
        {
            Agent_Info ag_info = new Agent_Info();
            ag_info.setVisible(true);

            ag_info.pack();
            ag_info.setLocationRelativeTo(null);
            this.dispose();
            //System.out.println("Yes");
        }
        }
        } catch (SQLException ex) {
            Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
        }

enter image description here

1 个答案:

答案 0 :(得分:0)

  • 调整列大小仅适用于类型X的列,不适用于lc
  • \multicolumn{1}{c}{...}没有用
  • 即使具有调整大小的列,该表对于正常页面而言也太宽。使用较小的字体大小,缩写一些标题或创建横向页面

\documentclass{article}

\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

\begin{table}[htbp]
\centering
\scriptsize
\caption{asdf}
\begin{tabularx}{\linewidth}{XXXXXXXXXX}
\hline
&  & \multicolumn{4}{c}{X = Gini} & \multicolumn{4}{c}{X = Selfishness} \\ \cline{3-10}
Treat. & Round & \multicolumn{2}{c}{WMW} & \multicolumn{2}{c}{Schlag} & \multicolumn{2}{c}{WMW} & \multicolumn{2}{c}{Schlag} \\
&  & reduced & full & reduced & full & reduced & full & reduced & full \\ \cline{3-10}
\multirow{3}{*}{1} & 1 & .123*** & .123*** & .123*** & .123*** & .123*** & .123*** & .123*** & .123*** \\
& 2 & .123** & .123** & .123** & .123** & .123** & .123** & .123** & .123** \\
 & 3 & .123* & .123* & .123* & .123* & .123* & .123* & .123* & .123* \\
\multirow{3}{*}{2} & 1 & .123 & .123 & .123 & .123 & .123 & .123 & .123 & .123 \\
 & 2 & .123 & .123 & .123 & .123 & .123 & .123 & .123 & .123 \\
 & 3 & .123 & .123 & .123 & .123 & .123 & .123 & .123 & .123 \\
\hline
\end{tabularx}
\end{table}

\end{document}