%20%E3%81%AF%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%20(Tabularray)%20%E3%81%A7%E3%81%AF%E6%A9%9F%E8%83%BD%E3%81%97%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%E3%81%AA%E3%81%9C%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%3F%20%E4%BF%AE%E6%AD%A3%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%99%E3%81%8B%3F.png)
次のようなドキュメントがあります。これは空の点線で埋めたいテーブル (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}