如何自动避免tabularray中第一列的白色间隙?

如何自动避免tabularray中第一列的白色间隙?

我看到了这个问题,答案是这里。我尝试使用\\\nopagebreak,但无法获得良好的长表。我的代码

\documentclass[12pt]{article}
\usepackage{tabularray}
\UseTblrLibrary{diagbox}
\UseTblrLibrary{varwidth}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{counter}
\usepackage{enumitem}
\usepackage{ninecolors}
\UseTblrLibrary{amsmath}
%\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\UseTblrLibrary{siunitx} 
\usepackage{tikz}

\usepackage[paperwidth=19cm, paperheight=26.5cm, left=1.7cm,right=1.7cm,top=1.8cm,bottom=1.7cm]{geometry}
\DefTblrTemplate{contfoot-text}{normal}{Continued on next page}
\SetTblrTemplate{contfoot-text}{normal}
\DefTblrTemplate{conthead-text}{normal}{(Continued)}
\SetTblrTemplate{conthead-text}{normal}
\SetTblrTemplate{conthead-text}{normal}
\newcounter{mycnta}
\newcommand{\mycnta}{\stepcounter{mycnta}\arabic{mycnta}}


\newcommand{\startproblem}[1]{
    \SetCell[r=#1]{m}\SetRow{bg=teal9}\SetCell{bg=gray9}\mycnta
}

\begin{document}
    
    
    \begin{longtblr}[
        expand=\startproblem,
        caption={Some text}]{
            colspec = {Q[c,gray9]X[l,valign=m]Q[c]},
            rowhead = 1,
            vlines,
            hlines,
            row{1}={yellow9,font=\bfseries},
            cell{1}{2-3}={halign=c},
            column{1}={font=\bfseries},
        }
        Problem & Content & Point \\
        \startproblem{5}    & Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
        & $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
        & $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
        & $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
        & The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
        \startproblem{4}    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ $ y = \dfrac{2x+1}{x-2} $ $ y = \dfrac{2x+1}{x-2} $ $ y = \dfrac{2x+1}{x-2} $ $ y = \dfrac{2x+1}{x-2} $ $ y = \dfrac{2x+1}{x-2} $&  \num{0.75}  \\
        & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
        & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
        & $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
        \startproblem{3}    & Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\
        &  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
        & $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
        \\
        \startproblem{5}    & Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
        & $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
        & $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
        & $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
        & The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
        \startproblem{4}    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
        & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
        & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
        & $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
        \startproblem{3}    & Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\\nopagebreak
        &  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
        & $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
        \\
        \startproblem{5}    & Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
        & $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
        & $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
        & $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
        & The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
        \startproblem{20}   & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\\nopagebreak
        & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
        & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
        & $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
        & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
        & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
        & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
        & $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
        & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
        & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
        & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
        & $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
        & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
        & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
        & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
        & $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
        & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
        & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
        & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
        & $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
        
    \end{longtblr} 
    
\end{document}

在此处输入图片描述

答案1

  • 问题出\startproblem在表格中的最后一条命令:它跨越的行数太多,所以它突出在页面下方。
  • 解决方案是手动将其分为两部分,8-a例如8-b
  • 我擅自将代码稍微缩短了一些……

梅威瑟:

\documentclass[12pt]{article}
\usepackage[paperwidth=19cm, paperheight=26.5cm,
            hmargin=1.7cm,
            vmargin={1.8cm,1.7cm}]{geometry}
\usepackage{ninecolors}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,
                booktabs,
                counter,
                diagbox,
                siunitx,
                varwidth}
\sisetup{output-decimal-marker={,}}
\usepackage{amssymb}
\usepackage{enumitem}

\newcounter{mycnta}
\newcommand{\mycnta}{\stepcounter{mycnta}\arabic{mycnta}}
\newcommand{\startproblem}[1]%
{
    \SetCell[r=#1]{m,bg=gray9, font=\bfseries}\mycnta
}

\begin{document}
    \begin{longtblr}[
expand=\startproblem,
caption={Some text} ]{vlines,hlines,
                     colspec = {Q[c,gray9]
                                X[l,valign=m]
                                Q[c, si={table-format=1.2}]},
                     rowhead = 1,
                     row{1}={yellow9,font=\bfseries},
                     cell{1}{2-3}={halign=c},
                    }
Problem & Content & Point \\
\startproblem{5}    
    & Solve the equation $ x^2 - 5x + 6 = 0 $   & 1.00 \\*
    & $\Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & 0.25 \\*
    & $ x = \dfrac{-(-5) -1}{2} = 2$.           & 0.25 \\*
    & $ x = \dfrac{-(-5)  + 1}{2} = 3$          & 0.25 \\*
    & The given equation has two solutions $x=2$ and $x = 3$.   
                                                & 0.25 \\
\startproblem{4}    
    & Find the derivate of the functions    
        $y = \dfrac{2x+1}{x-2},\ y = \dfrac{2x+1}{x-2},$
        $y = \dfrac{2x+1}{x-2},\ y = \dfrac{2x+1}{x-2},\ 
         y = \dfrac{2x+1}{x-2},\ y = \dfrac{2x+1}{x-2}$ 
                                                & 0.75 \\*
    & $y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$.        
                                                & 0.25 \\*
    & $y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$.     & 0.25 \\*
    & $y'=-\dfrac{5}{(x-2)^2}$.                 & 0,25 \\
\startproblem{3}    
    & Is this $ x^2 + 3x +4 >0$ true or fail? Why?  
                                                & 0.75 \\*
    &  $ x^2 + 3x +4 >0$ true.                  & 0.25 \\*
    & $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. 
                                                & 0.50 \\
\startproblem{5}    
    & Solve the equation $ x^2 - 5x + 6 = 0 $   & 1.00 \\*
    & $\Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & 0.25 \\*
    & $ x = \dfrac{-(-5) -1}{2} = 2$.           & 0.25 \\*
    & $ x = \dfrac{-(-5)  + 1}{2} = 3$          & 0.25 \\*
    & The given equation has two solutions $x=2$ and $x = 3$. 
                                                & 0.25 \\
\startproblem{4}    
    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ 
                                                & 0.75 \\*
    & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. 
                                                & 0.25 \\*
    & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$.    & 0.25 \\*
    & $y'=-\dfrac{5}{(x-2)^2}$.                 & 0,25 \\
\startproblem{3}    & Is this $ x^2 + 3x +4 >0$ true or fail? why?  
                                                & 0.75 \\*
    &  $ x^2 + 3x +4 >0$ true.                  & 0.25 \\*
    & $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. 
                                                & 0.50 \\
\startproblem{5}    
    & Solve the equation $ x^2 - 5x + 6 = 0 $   & 1.00 \\*
    & $\Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & 0.25 \\*
    & $ x = \dfrac{-(-5) -1}{2} = 2$.           & 0.25 \\*
    & $ x = \dfrac{-(-5)  + 1}{2} = 3$          & 0.25 \\*
    & The given equation has two solutions $x=2$ and $x = 3$. 
                                                & 0.25 \\
\startproblem{13}-a  % <--------------- changed
%\SetCell[r=13]{m,bg=gray9, font=\bfseries}\mycnta-a
    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ 
                                                & 0.75 \\*
    & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. 
                                                & 0.25 \\*
    & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$.    & 0.25 \\*
    & $y'=-\dfrac{5}{(x-2)^2}$.                 & 0,25 \\*
    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ 
                                                & 0.75 \\*
    & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. 
                                                & 0.25 \\*
    & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$.    & 0.25 \\*
    & $y'=-\dfrac{5}{(x-2)^2}$.                 & 0,25 \\*
    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ 
                                                & 0.75 \\*
    & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. 
                                                & 0.25 \\*
    & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$.    & 0.25 \\*
    & $y'=-\dfrac{5}{(x-2)^2}$.                 & 0,25 \\*
    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ 
                                                & 0.75 \\
\SetCell[r=7]{m,bg=gray9, font=\bfseries}\themycnta-b % <--- inserted, changed
    & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. 
                                                & 0.25 \\*
    & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$.    & 0.25 \\*
    & $y'=-\dfrac{5}{(x-2)^2}$.                 & 0,25 \\
    & Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ 
                                                &  \num{0.75}  \\
    & $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & 0.25 \\*
    & $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$.    & 0.25 \\*
    & $y'=-\dfrac{5}{(x-2)^2}$.                 & 0,25 \\
    \end{longtblr}
\end{document}

在此处输入图片描述

相关内容