1

I have the following document which is a table (tabularray) which I want to full with empty dotted lines. I have defined the command \fillwithdottedlines as you can see in MWE. Although the command works perfectly outside tblr environment it does not work inside. Why this happens and how I can fix it? Please uncomment the line with this command inside the table to see the error.

\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} 
2
  • 1
    Why not just using \dotfill (or \makebox[2cm]{\dotfill} for a shorter line)? Commented Mar 3, 2023 at 9:32
  • You have right! Just wanted to know what the problem is. I also need many lines to be filled, 12 or more in each table. Commented Mar 3, 2023 at 10:19

1 Answer 1

1

I am not completely sure what is really going wrong here (and therefore this is only a partial answer), but at least one of the problems stems from the definition of \fillwithdottedlines which requires that a space follows the argument (because the space delimits the argument). You can check this by writing into one of the cells in the left column \fillwithdottedlines{5cm} {}, which at least results in no errors but still in a suboptimal output regarding vertical alignment. For some reasons I cannot explain, but probably due to the way the tblr is constructed, this trick does not work for cells in the right column.

A solution, however, would be to wrap the \fillwithdottedlines macro in a \parbox, for example using \parbox{\linewidth}{\fillwithdottedlines{2cm} }. Take care of the required space before the last closing curly brace!

\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} 

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.