NiceTabular 中的水平规则或非水平规则

NiceTabular 中的水平规则或非水平规则

我正在用 制作一个简单的表格NiceTabular,其中一列必须占据 6 行,具体来说是第二列。问题在于规则(可能吗?),并且取决于使用命令的选项\NiceMatrixOptions{rules/color=black, hvlines}

例如,两种可能性是:

\begin{NiceTabular}{c|c|c}
        \large{\textbf{Temáticas}} & \large{Estrategias de enseñanza} & \large{Competencias promotoras}\\\toprule
        \parbox[l]{5cm}{Conocimiento y razonamiento. \textbf{blablabla}} & \Block[b]{6-1}{estrat} & otra\\\midrule
        \parbox[l]{5cm}{Surgimientos de la ciencia moderna. \textbf{blablabla}} & & \\\hline
        \parbox[l]{5cm}{Sucesión de teorías. \textbf{blablabla}} & & \\
        \parbox[l]{5cm}{Articulación entre teorías. \textbf{blablabla}} & & \\
        \parbox[l]{5cm}{Ciencias formales y ciencias fácticas. \textbf{blablabla}} & & \\
        \parbox[l]{5cm}{Ciencias sociales. \textbf{blablabla}} & & \\\bottomrule
    \end{NiceTabular}

没有选择,并且

\NiceMatrixOptions{rules/color=black, hvlines}
\begin{NiceTabular}{c|c|c}
    \large{\textbf{Temáticas}} & \large{Estrategias de enseñanza} & \large{Competencias promotoras}\\\toprule
    \parbox[l]{5cm}{Conocimiento y razonamiento. \textbf{blablabla}} & \Block[b]{6-1}{estrat} & otra\\\midrule
    \parbox[l]{5cm}{Surgimientos de la ciencia moderna. \textbf{blablabla}} & & \\\hline
    \parbox[l]{5cm}{Sucesión de teorías. \textbf{blablabla}} & & \\
    \parbox[l]{5cm}{Articulación entre teorías. \textbf{blablabla}} & & \\
    \parbox[l]{5cm}{Ciencias formales y ciencias fácticas. \textbf{blablabla}} & & \\
    \parbox[l]{5cm}{Ciencias sociales. \textbf{blablabla}} & & \\\bottomrule
\end{NiceTabular}

有选项。

区别在于:

在此处输入图片描述

请注意最后一个表格中第一列和第三列的水平线;但第一个表格中没有。但是,对于最后一个表格中的第二列,如果我使用,它就是我想要的NiceMatrixOptions。这是我的疑问。为什么?

答案1

我不太熟悉nicematrix这个包,但我确信使用它你可以编写表格而无需使用parboxes。对于第一列,你只需要规定适当的列类型(例如X),这样就可以自动将较长的文本分成几行。

使用nicematrix包来编写表格时,您应该知道,表格要经过多次编译才能得到最终形式。

使用tabularray包,表格代码很简单,而且效果更好。假设第二张图显示,生成类似结构表格的代码如下:

\documentclass{article}
\usepackage{geometry}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\begin{tblr}{hline{1,Z} = 0.8pt, hline{2} = 0.4pt, hline{3-Y} = 0.25pt,
             vlines,
             colspec = {Q[wd=42mm, cmd=\RaggedRight, m] c c},
             row{1}  = {font=\bfseries, cmd=\Centering},
             }
Temáticas   &   Estrategias de enseñanza    
                &   Competencias promotoras    \\
Conocimiento  razonamiento. \textbf{blablabla}
            &   &   otra                        \\   %
Surgimientos de la ciencia moderna. \textbf{blablabla}
            &   &                               \\
Sucesión de teorías. \textbf{blablabla}
            &   \SetCell[r=4]{f} estat
                &                               \\
Articulación entre teorías. \textbf{blablabla} 
            &   &                               \\
Ciencias formales y ciencias fácticas. \textbf{blablabla}
            &   &                               \\
Ciencias sociales. \textbf{blablabla}
            &   &                               \\
    \end{tblr}
\end{document}

在此处输入图片描述

要使用软件包重现上述结果nicematrix,您应该查阅软件包文档。我这样做了,并会使用它编写表格,如下所示:

\documentclass{article}
\usepackage{geometry}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage{ragged2e}

\begin{document}
\NiceMatrixOptions{hvlines}
\begin{NiceTabular}{>{\RaggedRight}p{42mm} c c}
Temáticas   &   Estrategias de enseñanza    
                &   Competencias promotoras    \\
Conocimiento  razonamiento. \textbf{blablabla}
            &   &   otra                        \\   %
Surgimientos de la ciencia moderna. \textbf{blablabla}
            &   &                               \\
Sucesión de teorías. \textbf{blablabla}
            &   \Block[b]{4-1}{estrat}
                &                               \\
Articulación entre teorías. \textbf{blablabla} 
            &   &                               \\
Ciencias formales y ciencias fácticas. \textbf{blablabla}
            &   &                               \\
Ciencias sociales. \textbf{blablabla}
            &   &                               \\
    \end{NiceTabular}
\end{document}

经过多次编译,基于`nicematrix 的表格如下:

在此处输入图片描述

这就是你要找的吗?

附录: 如果我考虑您答案中显示的图像,那么使用包tblr的可能解决方案tabularray可能是:

\documentclass{article}
\usepackage{geometry}

\usepackage{enumitem}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,
                varwidth}   % that lists work

\begin{document}
\begin{tblr}{hline{1,Z} = 0.8pt, hline{2} = 0.4pt, hline{3-Y} = 0.25pt,
             vlines,
             colspec = {Q[wd=42mm, cmd=\RaggedRight] X[c] Q[c, wd=0.25\linewidth]},
             row{1}  = {font=\bfseries, cmd=\Centering, m},
             stretch=-1,%<--- remove extra space above and below lists
                        % with nosep option; doc p.51 tabularray
             measure=vbox,  % for listrs
             }
Temáticas   &   Estrategias de enseñanza
                &   Competencias promotoras    \\
Conocimiento  razonamiento. \textbf{blablabla}
            &   \SetCell[r=6]{l, h}
                \begin{itemize}[nosep, leftmargin=*]
            \item   bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla
            \item   bla, bla
            \item   bla, bla
            \item   bla, bla
            \item   bla, bla
                \end{itemize}
                &   other                       \\   %
Surgimientos de la ciencia moderna. \textbf{blablabla}
            &   &                               \\
Sucesión de teorías. \textbf{blablabla}
            &   &                               \\
Articulación entre teorías. \textbf{blablabla}
            &   &                               \\
Ciencias formales y ciencias fácticas. \textbf{blablabla}
            &   &                               \\
Ciencias sociales. \textbf{blablabla}
            &   &                               \\
    \end{tblr}
\end{document}

在此处输入图片描述

如果您坚持使用nicematrix包来编写表格,则 MWE 是:

\documentclass{article}
\usepackage{geometry}
\usepackage{nicematrix}
\usepackage{booktabs, 
            varwidth}   % needed for lists in table
\usepackage{ragged2e}
\usepackage{enumitem}

\begin{document}
\NiceMatrixOptions{hvlines}
\begin{NiceTabular}{>{\RaggedRight}p{42mm} >{\Centering}X c}
Temáticas   &   Estrategias de enseñanza
                &   Competencias promotoras    \\
Conocimiento  razonamiento. \textbf{blablabla}
            &   \Block[t]{6-1}{
                \begin{itemize}[nosep, leftmargin=*]    % you may liked to omit "nosep" option
            \item   bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla
            \item   bla, bla
            \item   bla, bla
            \item   bla, bla
            \item   bla, bla
                \end{itemize}   
                                }
                &   other                      \\   %
Surgimientos de la ciencia moderna. \textbf{blablabla}
            &   &                               \\
Sucesión de teorías. \textbf{blablabla}
            &   &                               \\
Articulación entre teorías. \textbf{blablabla}
            &   &                               \\
Ciencias formales y ciencias fácticas. \textbf{blablabla}
            &   &                               \\
Ciencias sociales. \textbf{blablabla}
            &   &                               \\
    \end{NiceTabular}
\end{document}

三次编译的结果和之前几乎一样:

在此处输入图片描述

答案2

经过一段时间的思考,我想起了\cline我在中使用的命令tabular。我在行末添加了 \cline{1}\cline{3} 并解决了我的问题。

问候,达里奥

编辑 这是对我有用的MWE:

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper,left=1cm, right=1cm, top=2cm, bottom=2cm]{geometry}
\usepackage{nicematrix,booktabs}
    
\begin{document}
\begin{table}
    \centering
    \begin{NiceTabular}{|c|c|c|}
        \toprule
        \large{\textbf{Contenidos}} & \textbf{\large{Estrategias de enseñanza}} & \parbox{.25\textwidth}{\textbf{\large{Competencias esperadas}}} \\\toprule
        \parbox[l]{7cm}{Conocimiento y razonamiento.} & \Block[T,l]{6-1}{\parbox[l]{.25\textwidth}{\begin{itemize}
            \item bla
            \item ble
            \item bli
            \item blo
        \end{itemize}}} & other\\\cline{1}\cline{3}
        \parbox[l]{7cm}{Surgimientos de la ciencia moderna.} & & \\\cline{1}\cline{3}
        \parbox[l]{7cm}{Sucesión de teorías.} & & \\\cline{1}\cline{3}
        \parbox[l]{7cm}{Articulación entre teorías.} & & \\\cline{1}\cline{3}
        \parbox[l]{7cm}{Ciencias formales y ciencias fácticas.} & & \\\cline{1}\cline{3}
        \parbox[l]{7cm}{Ciencias sociales.} & & \\\bottomrule
    \end{NiceTabular}
\end{table}
\end{document}

在此处输入图片描述

我使用它是\parbox因为它允许我插入类似 的环境itemize。这是一个与我的疑问相关的简单示例,经过美学更新后,但对我有用。

感谢您的回复,我不知道该如何操作ragged2e,但一切正常。有一点需要注意,\RaggedRight第二个 R 字母大写,因为它给了我一个错误。

问候,达里奥

相关内容