コマンド \fillwithdottedlines (試験のドキュメントクラスから取得) はテーブル (Tabularray) では機能しません。なぜでしょうか? 修正できますか?

コマンド \fillwithdottedlines (試験のドキュメントクラスから取得) はテーブル (Tabularray) では機能しません。なぜでしょうか? 修正できますか?

次のようなドキュメントがあります。これは空の点線で埋めたいテーブル (tabularray) です。MWE\fillwithdottedlinesでわかるようにコマンドを定義しました。コマンドはtblr環境外では完全に機能しますが、環境内では機能しません。なぜこのようなことが起こるのでしょうか。また、どうすれば修正できるのでしょうか。エラーを確認するには、テーブル内のこのコマンドの行のコメントを解除してください。

\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage{tabularray}
\makeatletter
\newlength\dottedlinefillheight
\setlength\dottedlinefillheight{9mm}

\def\fillwithdottedlines#1 {%
    \begingroup
    \ifhmode
    \par
    \fi
    \hrule height \z@
    \nobreak
    \setbox0=\hbox to \hsize{\hskip \@totalleftmargin
        \vrule height \dottedlinefillheight depth \z@ width \z@
        \dotfill}%
    \cleaders \copy0 \vskip #1 \hbox{}%
    \endgroup
}
\makeatother

\begin{document}
    \begin{tblr}{colspec={Q[0.5\linewidth-5pt,c]X[c]},row{1,2}={1cm,m},row{3}={15cm,m},vlines,hlines}
        \SetCell[c=2]{c} \large \textbf{TITLE}                                      \\ 
        \textbf{Subtitle 1}             & \textbf{Subtitle 2}                       \\
                                        &                                           \\
        %\fillwithdottedlines{10cm}     &  \fillwithdottedlines{10cm}               \\
    \end{tblr}

\fillwithdottedlines{5cm}
    
\end{document}

答え1

ここで実際に何が間違っているのか完全にはわかりません (したがって、これは部分的な回答にすぎません) が、問題の少なくとも 1 つは の定義に起因しています。 の定義では、\fillwithdottedlines引数の後にスペースが必要です (スペースが引数を区切るため)。 左の列のセルの 1 つに と書き込むことでこれを確認できます。\fillwithdottedlines{5cm} {}これにより、少なくともエラーは発生しませんが、垂直方向の配置に関しては最適ではない出力になります。 の作成方法が原因で、説明できないいくつかの理由でtblr、このトリックは右の列のセルには機能しません。

ただし、解決策としては、たとえば を使用して、\fillwithdottedlinesマクロを で囲むことが考えられます。最後の閉じ中括弧の前に必要なスペースがあることに注意してください。\parbox\parbox{\linewidth}{\fillwithdottedlines{2cm} }

\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm}, left=15mm, top=20mm]{geometry}
\usepackage{tabularray}

\makeatletter
\newlength\dottedlinefillheight
\setlength\dottedlinefillheight{9mm}

\def\fillwithdottedlines#1 {%
    \begingroup
    \ifhmode
    \par
    \fi
    \hrule height \z@
    \nobreak
    \setbox0=\hbox to \hsize{\hskip \@totalleftmargin
        \vrule height \dottedlinefillheight depth \z@ width \z@
        \dotfill}%
    \cleaders \copy0 \vskip #1 \hbox{}%
    \endgroup
}
\makeatother

\begin{document}
    \begin{tblr}{
        colspec = { Q[0.5\linewidth-5pt, c] X[c] },
        row{1,2} = {1cm, m},
        row{3} = {15cm, m},
        vlines,
        hlines,
    }
        \SetCell[c=2]{c} \large \textbf{TITLE}                                      \\ 
        \textbf{Subtitle 1}             & \textbf{Subtitle 2}                       \\
                                        &                                           \\
        \parbox{\linewidth}{\fillwithdottedlines{2cm} } &  
        \parbox{\linewidth}{\fillwithdottedlines{2cm} }                             \\
    \end{tblr}
    
%\fillwithdottedlines{5cm}

\end{document}

ここに画像の説明を入力してください

関連情報