让长描述表看起来更好

让长描述表看起来更好

有什么建议可以让这张长桌看起来更好看

我的代码和输出:

  \documentclass[preprint,12pt,authoryear]{elsarticle}

    %-----------------------------------------------------------------------------------------
 \usepackage[margin=2cm]{geometry}
 \usepackage[figurename=Fig.]{caption}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{varioref}
\usepackage{multirow}
\usepackage{commath}
\usepackage{array,multirow}
\usepackage{threeparttable}  
 \usepackage{longtable}
 \usepackage{tabulary}
 \usepackage{booktabs}
 \usepackage{float}
  \usepackage{caption}
  \usepackage{subcaption}
  \usepackage{rotating}
  \usepackage{graphicx}
  \usepackage{setspace}
  \usepackage{varioref}  
  \usepackage[colorlinks,allcolors=blue]{hyperref}
  \usepackage[nameinlink,noabbrev]{cleveref} 
  \crefname{equation}{eq.}{eq.}
  \usepackage{amssymb}
 \usepackage{amsthm}
 \usepackage[utf8]{inputenc}
 \usepackage{ragged2e}
 \usepackage{booktabs, makecell, multirow, xltabular}
 \renewcommand\theadfont{\bfseries}
 \renewcommand\theadgape{}
 \newcolumntype{R}{>{\RaggedRight}X}
\newcommand\mcc[1]{\multicolumn{3}{c}{\emph{#1}}}
 %--------------------------------------------------------------------------------------------


   \usepackage{enumitem}


     \begin{document}

     \begingroup
     \setlist[itemize]{nosep, wide,
                 before=\vspace{-\baselineskip},
                after=\vspace{-\baselineskip}
                 }
    \begin{xltabular}{\linewidth}{@{} >{\small\bfseries%
                                  \raggedright\arraybackslash%
                                   \hsize=0.5\hsize}X
                                 >{\hsize=0.5\hsize}R
                                 >{\hsize=0.5\hsize}R
                               @{}}
    % table preamble
    \caption{Add caption}
    \label{tab:addlabel}                        \\
    \toprule
    \thead{Student}
      &   \thead{Description of\\ Key Variables}
        &   \thead{Survey Q}    \\
     \midrule
    \endfirsthead
    %\caption[]{Add caption (cont.)}                       \\
      \toprule

       \bottomrule
      \endlastfoot
     % table body
    \mcc{Mental}                       \\
     \cmidrule{1-3}
   WHO
     & Continuous 0 to 3. Average across the following statements. Over the last two weeks: 
   (1) I have felt cheerful and in good spirits; (2) I have felt calm and
  relaxed; (3) I have felt active and vigorous; (4) I woke up feeling fresh and rested and (5) 
      My 
     daily life has been filled with things that interest me. 

            &   \multirow{2}{=}
         {
          \begin{itemize}
           \item   Response options: (0) not at all, (1) some or little of the time, (2) occasionally or a moderate amount of time and (3) most of the time      
     \end{itemize}   
        }       \\
    \addlinespace[2pt]          
      Hopkins
           &   Continuous 0 to 3. Average across 23 statements. Over the last two weeks have 
        you 
         experienced: (1)
         feeling suddenly scared for no reason, (2) feeling fearful, (3) faintness, dizziness or weakness, (4) nervousness or shakiness inside, (5) heart pounding or racing, (6) trembling, (7) feeling tense or keyed up,
          (8) headache, (9) a spell of terror or panic, (10) feeling restless or can't sit still, (11) feeling low in energy or slowed down, (12) blaming yourself for things, (13) crying easily, (14) loss of sexual interest or pleasure, (15) poor appetite, (16) difficulty falling or staying asleep, (17) feeling hopeless about the future, (18) feeling lonely, (19) feeling of being trapped or caught, (20) worrying too much about things, (21) feeling no
         interest in things, (22) feeling everything is an effort, (23) feeling of worthlessness.
&   \multirow{2}{=}
    {
 \begin{itemize}
            \item  Response options are:(0) not at all, (1) some or little of the time, (2) occasionally or a moderate amount of time (3) most of the time.    
  \end{itemize}   
    }       \\
\addlinespace[2pt] 
\midrule
\mcc{Social cohesion}                    \\
\cmidrule{1-3}
        Problems
&   Continuous 0 to 2. Have you had any problems with the other households in this dwelling? 
    \vspace{2\baselineskip}
    &   \multirow{2}{=}{%
        \begin{itemize}
    \item   Response options: (0) no problems, (1) some problems, (2) many problems

        \end{itemize}   }       \\
\addlinespace[6pt]
\end{xltabular} 
\endgroup
    \end{document}

在此处输入图片描述 在此处输入图片描述

答案1

  • 我想知道
    • 为什么你要规定第一列的宽度。它和下一列之间有太多(令人不安的)空间。
    • multirow如果没有一个细胞需要它,为什么要使用它?
  • 您的表格,如目前所讨论的,可以放在一个包装中(重新设计列之后)。
  • 解决方案xltabular可以是:
\documentclass[preprint,12pt,authoryear]{elsarticle}
\usepackage[margin=2cm]{geometry}

\usepackage{microtype}  % new
\usepackage[figurename=Fig.]{caption}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, xltabular}
    \renewcommand\theadfont{\bfseries}
    \renewcommand\theadgape{}
\newcommand\mcc[1]{\multicolumn{3}{c}{\emph{#1}}}

\usepackage{enumitem}

\begin{document}
     \begingroup
\setlist[itemize]{nosep, wide,
             before=\vspace{-\baselineskip},
            after=\vspace{-\baselineskip}
             }
\begin{xltabular}{\linewidth}{@{} >{\bfseries}l XX @{}}
    % table preamble
\caption{Add caption}
\label{tab:addlabel}                                    \\
    \toprule
\thead{Student}
    &   \thead{Description of\\ Key Variables}
        &   \thead{Survey Q}                            \\
    \midrule
\endfirsthead
\caption[]{Add caption (cont.)}                         \\
    \toprule
\thead{Student}
    &   \thead{Description of\\ Key Variables}
        &   \thead{Survey Q}                            \\
\endhead
    \midrule
    \multicolumn{3}{r}{\footnotesize\textit{Continued on next page}}
\endfoot
    \bottomrule
      \endlastfoot
% table body
    \mcc{Mental}                                        \\
    \midrule    
    WHO
    & Continuous 0 to 3. Average across the following statements. Over the last two weeks:
   (1) I have felt cheerful and in good spirits; 
   (2) I have felt calm and
  relaxed; 
    (3) I have felt active and vigorous; 
    (4) I woke up feeling fresh and rested and 
    (5) My daily life has been filled with things that interest me.
        &   \begin{itemize}
        \item   Response options: (0) not at all, (1) some or little of the time, (2) occasionally or a moderate amount of time and (3) most of the time
            \end{itemize}                               \\
    \addlinespace
Hopkins
     &   Continuous 0 to 3. Average across 23 statements. Over the last two weeks have
        you experienced: 
        (1) feeling suddenly scared for no reason, 
        (2) feeling fearful, 
        (3) faintness, dizziness or weakness, 
        (4) nervousness or shakiness inside, 
        (5) heart pounding or racing, 
        (6) trembling, 
        (7) feeling tense or keyed up,
        (8) headache, 
        (9) a spell of terror or panic, 
        (10) feeling restless or can't sit still, 
        (11) feeling low in energy or slowed down, 
        (12) blaming yourself for things, 
        (13) crying easily, 
        (14) loss of sexual interest or pleasure, 
        (15) poor appetite, 
        (16) difficulty falling or staying asleep, 
        (17) feeling hopeless about the future, 
        (18) feeling lonely, 
        (19) feeling of being trapped or caught, 
        (20) worrying too much about things, 
        (21) feeling no interest in things, 
        (22) feeling everything is an effort, 
        (23) feeling of worthlessness.
        &   \begin{itemize}
        \item  Response options are:(0) not at all, (1) some or little of the time, (2) occasionally or a moderate amount of time (3) most of the time.
            \end{itemize}                                   \\
    \midrule
    \mcc{Social cohesion}                                   \\
    \midrule
Problems
    &   Continuous 0 to 2. Have you had any problems with the other households in this dwelling?
        &   \begin{itemize}
        \item   Response options: 
            (0) no problems, 
            (1) some problems, 
            (2) many problems
            \end{itemize}                                   \\
    \addlinespace[6pt]
\end{xltabular}
    \endgroup
\end{document}

在此处输入图片描述

** 附录:** 使用\tabularray包的解决方案:

\documentclass[preprint,12pt,authoryear]{elsarticle}
\usepackage[margin=2cm]{geometry}

\usepackage{microtype}  % new
\usepackage[figurename=Fig.]{caption}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth}

\usepackage{enumitem}

\begin{document}
     \begin{table}[ht]
\setlist[itemize]{nosep, 
                  wide,
                  after=\end{minipage},                  % <---
                  before=\begin{minipage}[t]{\linewidth} % <---
                 }
\caption{Add caption}
\label{tab:addlabel}                                    
\begin{tblr}{colspec={@{} Q[l, font=\bfseries] 
                          X[2,j]
                          X[j]
                     @{}},
             row{1} = {font=\bfseries, c, m},
             measure = vbox
             }
    % table preamble
    \toprule
Student 
    &   {Description of\\ Key Variables}
        &   Survey Q                        \\
% table body
    \midrule
\SetCell[c=3]{c, font=\itshape}     Mental 
    &   &                                   \\
    \midrule    
WHO
    & Continuous 0 to 3. Average across the following statements. Over the last two weeks:
    (1) I have felt cheerful and in good spirits; 
    (2) I have felt calm and relaxed; 
    (3) I have felt active and vigorous; 
    (4) I woke up feeling fresh and rested and 
    (5) My daily life has been filled with things that interest me.
        &   \begin{itemize}
        \item   Response options: (0) not at all, (1) some or little of the time, (2) occasionally or a moderate amount of time and (3) most of the time
            \end{itemize}                   \\
Hopkins
     &   Continuous 0 to 3. Average across 23 statements. Over the last two weeks have
        you experienced: 
        (1) feeling suddenly scared for no reason, 
        (2) feeling fearful, 
        (3) faintness, dizziness or weakness, 
        (4) nervousness or shakiness inside, 
        (5) heart pounding or racing, 
        (6) trembling, 
        (7) feeling tense or keyed up,
        (8) headache, 
        (9) a spell of terror or panic, 
        (10) feeling restless or can't sit still, 
        (11) feeling low in energy or slowed down, 
        (12) blaming yourself for things, 
        (13) crying easily, 
        (14) loss of sexual interest or pleasure, 
        (15) poor appetite, 
        (16) difficulty falling or staying asleep, 
        (17) feeling hopeless about the future, 
        (18) feeling lonely, 
        (19) feeling of being trapped or caught, 
        (20) worrying too much about things, 
        (21) feeling no interest in things, 
        (22) feeling everything is an effort, 
        (23) feeling of worthlessness.
        &   \begin{itemize}
        \item  Response options are:(0) not at all, (1) some or little of the time, (2) occasionally or a moderate amount of time (3) most of the time.
            \end{itemize}                   \\
    \midrule
\SetCell[c=3]{c, font=\itshape}     Social cohesion 
    &   &                                   \\
    \midrule
Problems
    &   Continuous 0 to 2. Have you had any problems with the other households in this dwelling?
        &   \begin{itemize}
        \item   Response options: 
            (0) no problems, 
            (1) some problems, 
            (2) many problems
            \end{itemize}                   \\
    \bottomrule
\end{tblr}
    \end{table}
\end{document}

在此处输入图片描述

答案2

  • 使用不同宽度的 -type 列时X,需要注意的主要一点是宽度总和必须等于-type 列\hsize的数量。您的表格有 3 个-type 列,但长度加起来为 1.5,而不是 3。此外,似乎没有理由不使用第一列的列类型。因此,第一个主要建议是仅使用两个(或)列,并将它们的相对宽度分别设置为 1.333 和 0.667。XX\hsizelXR

  • 接下来,第三列中代码混乱程度异常高。当然,请去掉包装\multirow器。而且,由于每个分项列表只有一个语句,我认为您也\item可以去掉包装器。itemize

  • 最后,我不会使用任何大胆的在标题行和标题列中。这根本就没有必要——而且可能会不必要地造成干扰,因为粗体显示可能会显得(在印刷上)粗俗。

在此处输入图片描述

\documentclass[preprint,12pt,authoryear]{elsarticle} 
%---------------------------------------------------------------------
\usepackage[margin=2cm]{geometry}
\usepackage[figurename=Fig.]{caption}
\usepackage{tabulary}
\usepackage{tabularx}
%%%\usepackage{tabulary}
\usepackage{varioref}
\usepackage{multirow}
\usepackage{commath}
\usepackage{array,multirow}
\usepackage{threeparttable}  
 \usepackage{longtable}
 %%%\usepackage{tabulary}
 %%%\usepackage{booktabs}
 \usepackage{float}
  \usepackage{caption}
  \usepackage{subcaption}
  \usepackage{rotating}
  \usepackage{graphicx}
  \usepackage{setspace}
  %%%\usepackage{varioref}  
  \usepackage[colorlinks,allcolors=blue]{hyperref}
  \usepackage[nameinlink,noabbrev]{cleveref} 
  \crefname{equation}{eq.}{eq.}
  \usepackage{amssymb}
 \usepackage{amsthm}
 \usepackage[utf8]{inputenc}
 \usepackage{ragged2e}
 \usepackage{booktabs, makecell, multirow, xltabular}
 \renewcommand\theadfont{\bfseries}
 \renewcommand\theadgape{}
 \newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcommand\mcc[1]{\multicolumn{3}{c}{\emph{#1}}}
   
%--------------------------------------------------------------------

\usepackage{enumitem}

\begin{document}

\begingroup
\setlist[itemize]{nosep, wide=0pt,
                 before={\begin{minipage}[t]{\hsize}\raggedright},
                 after={\end{minipage}}
                 }

\begin{xltabular}{\linewidth}{@{} 
        l
        >{\hsize=1.333\hsize}R  % 1.333+0.667=2
        >{\hsize=0.667\hsize}R
        @{}}

% table preamble
    \caption{Add caption}
    \label{tab:addlabel} \\
    \toprule
    Student
    & Description of Key Variables
    & Survey Q   \\
    \midrule
    \endfirsthead
    %\caption[]{Add caption (cont.)}  \\
      
    \bottomrule
    \endlastfoot

% table body
\mcc{Mental} \\
\cmidrule{1-3}
WHO
& Continuous 0 to 3. Average across the following statements. Over the last two weeks: (1) I have felt cheerful and in good spirits; (2) I have felt calm and relaxed; (3) I have felt active and vigorous; (4) I woke up feeling fresh and rested and (5) My daily life has been filled with things that interest me. 
& Response options: (0)~not at all, (1) some or little of the time, (2)~occasionally or a moderate amount of time and (3) most of the time. \\
\addlinespace          
Hopkins
& Continuous 0 to 3. Average across 23 statements. Over~the last two weeks have you experienced: (1)~feeling suddenly scared for no reason, (2) feeling fearful, (3)~faintness, dizziness or weakness, (4)~nervousness or shakiness inside, (5) heart pounding or racing, (6)~trembling, (7) feeling tense or keyed up, (8)~headache, (9) a spell of terror or panic, (10)~feeling restless or can't sit still, (11) feeling low in energy or slowed down, (12) blaming yourself for things, (13)~crying easily, (14) loss of sexual interest or pleasure, (15) poor appetite, (16) difficulty falling or staying asleep, (17) feeling hopeless about the future, (18)~feeling lonely, (19) feeling of being trapped or caught, (20) worrying too much about things, (21)~feeling no interest in things, (22) feeling everything is an effort, (23) feeling of worthlessness.
& Response options: (0)~not at all, (1)~some or little of the time, (2)~occasionally or a moderate amount of time (3)~most of the time.  \\
\addlinespace
\midrule
\mcc{Social cohesion} \\
\cmidrule{1-3}
Problems
& Continuous 0 to 2. Have you had any problems with the other households in this dwelling? 
& Response options: (0)~no problems, (1)~some problems, (2)~many problems \\
\end{xltabular} 
\endgroup
\end{document}

答案3

如果您仅在这里更改代码:

\begin{xltabular}{\linewidth}{@{} >{\small\bfseries%
            \raggedright\arraybackslash%
            \hsize=0.15\hsize}X
        >{\hsize=0.8\hsize}R
        >{\hsize=0.4\hsize}R
        @{}}
    % table preamble

你会得到这样的结果:

在此处输入图片描述

(因为您不需要更大的第三列)。

相关内容