代码之家  ›  专栏  ›  技术社区  ›  Rafid

乳胶:多排问题

  •  3
  • Rafid  · 技术社区  · 15 年前


    我正在用mulitrow创建一个表,但是我遇到了一个问题。据我所知,这是多行的形式:

    \multirow{count}{alignment}{content}
    

    其中count是要合并的行数,alignment是l、c、r或*,content是行的内容。我尝试了以下方法:

    \multirow{3}{*}{Framing}
    

    但我有麻烦了。与其在单元格中看到“Framing”一词,不如看到“3*Framing”,这表示\multirow元素不起作用。知道吗?

    另外,如何垂直对齐单元格中的文本?

    更新: 我以为\usepack{multirow}可以解决这个问题,但我仍然看到了一些问题: 首先,我不能做垂直对齐。 第二,我对“框架”单元有点奇怪。与其让“框架”与左边对齐,我得到一个包含字母“l”的虚拟行,然后在两个虚拟行之后,我得到单词“框架”!!是这样的:

    ______________
    |     l       |
    |             |
    |     Framing |
    |             |
    |             |
    |             |
    |             |
    ______________
    

    这是我的桌子,给那些问我这个问题的人:

    \begin{table*}\tiny
        \centering
        \begin{tabular}{|c|c|c|c|c|p{2in}|}
            \hline
    
            Rule & Factor & Best Value & \Delta_t & \Delta_{do} & Comments \\
    
            \hline
    
            % Diagonal Dominance Rule
            \multirow{3}{*}{Diagonal Dominance} & Line Angle & 45 & 15 & 30 & The angle between the prominent line of the object and
                                                                              the diagonal lines \\                                     % TODO: What object? Make sure it is clear.
                                                & Line Distance & 0 & 0.25 & 1 & The distance, in screen coordinates, from the
                                                                                 prominent line of the object to the diagonal lines. \\ % TODO: Need to define screen coordinates
                                                & Corner Distances & 0 & 0.1 & 0.7 & The distance, in screen coordinates, from the
                                                                                     end of the prominent line of the object to the corners of the screen. \\
    
            \hline
    
            % Framing Rule
            \multirow{4}{l}{Framing} & Left Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance between the
            left side of the frame covering the object and the left or the right side of the intended frame, whichever closer. \\
                                    & Right Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance between the
            right side of the frame covering the object and the left or the right side of the intended frame, whichever closer. \\
                                    & Top Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance between the
            top side of the frame covering the object and the upper or the lower side of the intended frame, whichever closer. \\
                                    & Bottom Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance between the
            bottom side of the frame covering the object and the upper or the lower side of the intended frame, whichever closer. \\
    
            \hline
        \end{tabular}
        \caption{The factors of each rule and their parameters.}
        \label{table:factors}
    \end{table*}
    

    当做,
    拉菲德

    3 回复  |  直到 15 年前
        1
  •  5
  •   Hendy    15 年前

    1) 你把 \usepackage{multirow} 在你文件的开头?

    2) 可能有好的例子可以效仿。我从来没用过这个包裹,但在很短的时间内(几秒钟)就找到了这个 PAGE 通过谷歌。下面的例子对你有帮助吗?


    更新: 在看到您的实际表后,我不想这么说,但我认为您的间距问题是由于“comments”列溢出成多行造成的。我截短了你的评论,得到了这个(第1列现在按需要垂直居中):

    \begin{table*}\tiny
      \centering
      \begin{tabular}{|c|c|c|c|c|p{3cm}|}
        \hline
        Rule & Factor & Best Value & \Delta_t & \Delta_{do} & Comments \\
        \hline
    
        % Diagonal Dominance Rule
        \multirow{3}{*}{Diagonal Dominance} & Line Angle & 45 & 15 & 30 & The angle between... \\
                                            & Line Distance & 0 & 0.25 & 1 & The distance, in... \\
                                            & Corner Distances & 0 & 0.1 & 0.7 & The distance, in... \\
        \hline
    
        % Framing Rule
        \multirow{4}{*}{Framing} & Left Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance... \\
                                 & Right Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance... \\
                                 & Top Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance... \\
                                 & Bottom Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance... \\
        \hline
      \end{tabular}
    
      \caption{The factors of each rule and their parameters.}
      \label{table:factors}
    
    \end{table*}
    

    关于{l}参数,我认为我最初发布的链接可能是错误的。当我试着用l代替 \multirow 争论。我把这个放在测试台上:

    ! Missing number, treated as zero.
    <to be read again> 
                       l
    l.12 \multirow{4}{l}{Batch}
                                & MM & Min-Min \\
    ! Illegal unit of measure (pt inserted).
    <to be read again> 
                       l
    l.12 \multirow{4}{l}{Batch}
                                & MM & Min-Min \\
    

    发现后 THIS ,我想第二个论点 \多行 不是为了对齐而是为了宽度。链接到LyX wiki的网站说,格式如下:

    \multirow{number of rows}{cell width}{cell entry}
    

    我们一直假设{cell width}是实际的{alignment},我认为前面的链接会让人感到困惑。请参见LyX wiki上关于间距的注释;您可以在需要时使用以下内容来完成您的竞价:

    \renewcommand{\multirowsetup}{\centering}
    

    并替换 \centering 具有 \raggedleft \raggedright 在需要的地方。我仍然认为你会在多条线路上遇到麻烦。我至少已经证明了抛弃它们能使间距按预期工作。。。恐怕我无法强迫他们以你的默认例子为中心。但也许现在你知道问题出在哪里了?

    我想如果你真的,真的,真的想,你可以把你的句子分成几行,然后调整 \多行 相应地增加行数。尽管您可能还需要一个嵌套的多行结构:

    |                   | item 1, 2 rows | comment 1 line 1              |
    |  multirow, 4 rows |                | comment 1 line 2 (spill over) |
    |                   | item 2, 2 rows | comment 2 line 1              |
    |                   |                | comment 2 line 2 (spill over) |
    

    这有道理吗?列1将跨越其节的所有行,后续行将跨越拆分注释所需的行数,并且注释所需的每一行(有些行占3或4)将位于各自的单独行上,并且看起来是连续的。不过,不确定句子间距是否会看起来奇怪。

    胡言乱语。这是你思考的食物。


    最后一次更新: 最后一个解决这个问题的方法可能是使用TikZ表。基本上,你的节点就像“细胞”,然后把它们放在一起,让它看起来像一张桌子。也许是一个可怕的建议,但我向你保证,你将拥有所有的灵活性,你需要与细胞间距等。一些想法:

        2
  •  2
  •   Steve Tjoa    15 年前

    是的,你需要 multirow 包裹。

    \usepackage{multirow}
    \begin{document}
    \begin{table}
    \centering
    \begin{tabular}{l||c|r}
    Header 1 & Header 2 & Header 3 \\
    \multirow{2}{*}{Hello} & stuff & stuff \\
    & Body 2 & Body 3
    \end{tabular}
    \end{table}
    \end{document}
    

    编辑后再编辑问题:我有两个错误:

    1. \multirow{4}{l}{Framing} . 我改成了 \multirow{4}{*}{Framing}

    2. Delta_t 更改为 $Delta_t$ .

    否则,一切看起来都很好。你可能想问 tex.stackexchange.com 也是。

        3
  •  2
  •   Samuel Bolduc    7 年前

    疯狂猜测:你得到了 undefined control sequence: multirow 因为你缺少 \usepackage{multirow} 在序言里?

    推荐文章