0

It's related to my previous question. I need to break a large row of the table containing many sentences and lists. I'm very excited when i found this : Credit link. Now, my problem is i can't add lines on the top row (1 line on the top and 2 lines on the bottom) and 1 line on the last row. i have a bad idea to do the first problem to make a blank row under the top row, but the vertical length size is too wide and even if it's working, as i said i need a repeated top row on every pages and this bad idea will not working when there's a break row.

To clarify my point about the lines on the top and the bottom. enter image description here This is an example of what i want the table to look like.

I really need your help. Thanks in advance!

Here is my MWE:

\documentclass{article}
\usepackage{lipsum,enumitem}
\usepackage{cals}
\usepackage[latin]{babel}
\showboxbreadth=100
\showboxdepth=100
\usepackage[none]{hyphenat}
\sloppy

\makeatletter
\let\oldDispatch=\cals@row@dispatch
\newbox\rowBefore
\newbox\rowAfter
\newbox\decorationCopy
\newdimen\splitHeight

\def\cals@row@dispatch{%
  \cals@ifbreak\iftrue % detect that a break is required
  \splitHeight=\pagegoal \advance\splitHeight -\pagetotal
  \ifdim \splitHeight>50pt % break inrow only if at least 100pt left
  \advance\splitHeight -5pt % avoid pagebreak due to overflows
  %
  % Split the current row on two: before and after the break
  %
  \setbox\rowBefore=\hbox{}
  \setbox\rowAfter=\hbox{}
  \def\next{%
    \setbox0=\lastbox
    \ifvoid0
    \def\next{\global\setbox\rowBefore=\box\rowBefore
      \global\setbox\rowAfter=\box\rowAfter }%
    \else
    \setbox2=\vsplit0 to\splitHeight
    \ifvoid0
      \setbox0=\vbox{\hbox to \wd2{}}%
    \fi
    \setbox\rowBefore=\hbox{\box2 \unhbox\rowBefore
      \hbox to 0pt{\hss\vbox{\hrule width\wd\cals@current@cs}}}%
    \setbox\rowAfter=\hbox{\box0 \unhbox\rowAfter}%
    \fi
    \next}
  \setbox0=\hbox{\unhbox\cals@current@row \next}
  %
  % Decoration backup, typeset the first row,
  % restore context, typeset the second at the end of macro
  %
  \setbox\decorationCopy=\copy\cals@current@cs
  \setbox\cals@current@row=\box\rowBefore
  \ht\cals@current@cs=\ht\cals@current@row
  \oldDispatch
  \cals@issue@break
  \cals@thead@tokens
  \setbox\cals@current@row=\box\rowAfter
  \cals@reheight@cells\cals@current@row
  \setbox\cals@current@cs=\box\decorationCopy
  \ht\cals@current@cs=\ht\cals@current@row
  \let\cals@current@context=b
  \fi
  \fi
  \oldDispatch}

\begin{document}
\begin{calstable}
\colwidths{{150pt}{150pt}}
\thead{\brow \bfseries \cell{\parbox{150pt}{\centering \textbf{Header 1}}}\cell{\parbox{150pt}{\centering \textbf{Header 2}}}
  \mdseries \erow}
\brow \cell{\lipsum[ 1]}\cell{\lipsum[ 2]} \erow
\brow \cell{\lipsum[ 4]}\cell{
\begin{itemize}[left= 5pt, noitemsep, topsep= 0pt, nosep]
    \item \lipsum[1][1-2]
    \item \lipsum[2][1-2]
    \item \lipsum[3][1-2]
    \item \lipsum[4][1-2]
\end{itemize}} \erow
\brow \cell{\lipsum[ 7]}\cell{\lipsum[ 8]} \erow
\brow \cell{\lipsum[10]}\cell{\lipsum[11]} \erow
\brow \cell{\lipsum[13]}\cell{\lipsum[14]} \erow
\end{calstable}
\end{document}
6
  • please upload the images to this site, not rely on external links Dec 25, 2020 at 22:54
  • @DavidCarlisle done :)
    – user516076
    Dec 25, 2020 at 23:11
  • Not sure I understand the question, do you jsut want \def\cals@rs@width{1pt}\def\cals@cs@width{0pt} inside your \makeatletter block? Dec 25, 2020 at 23:19
  • @DavidCarlisle oh yes. I want that also i just forgot to mention it to my question but still thanks. Actually my main question is "how to add horizontal line on the top row and on the bottom row". About the top row,which is where I want the horizontal line on the row containing header 1 and header 2 that has 1 horizontal line on top. And the two horizontal lines below, that's the first. the second one, I want there to be a horizontal line to close the very last line. It actually looks like in the picture. Please try my MWE and compare it with the pictures I gave, I'm sure you'll understand.
    – user516076
    Dec 25, 2020 at 23:30
  • 1
    the cals package has its own rule mechanisms I don't know the package at all, just going by mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/cals/… Dec 25, 2020 at 23:57

1 Answer 1

1

You can override the rules on individual rows by defining and undefining (for example_) \cals@borderT for the rule above (Top) the row. used here to put a thick rule above the heading) Also set \def\cals@rs@width{1pt} to give a default rule between rows.

enter image description here

\documentclass{article}
\usepackage{lipsum,enumitem}
\usepackage{cals}
\usepackage[latin]{babel}
\showboxbreadth=100
\showboxdepth=100
\usepackage[none]{hyphenat}
\sloppy

\makeatletter
\def\cals@rs@width{1pt}\def\cals@cs@width{0pt}
\let\oldDispatch=\cals@row@dispatch
\newbox\rowBefore
\newbox\rowAfter
\newbox\decorationCopy
\newdimen\splitHeight

\def\cals@row@dispatch{%
  \cals@ifbreak\iftrue % detect that a break is required
  \splitHeight=\pagegoal \advance\splitHeight -\pagetotal
  \ifdim \splitHeight>50pt % break inrow only if at least 100pt left
  \advance\splitHeight -5pt % avoid pagebreak due to overflows
  %
  % Split the current row on two: before and after the break
  %
  \setbox\rowBefore=\hbox{}
  \setbox\rowAfter=\hbox{}
  \def\next{%
    \setbox0=\lastbox
    \ifvoid0
    \def\next{\global\setbox\rowBefore=\box\rowBefore
      \global\setbox\rowAfter=\box\rowAfter }%
    \else
    \setbox2=\vsplit0 to\splitHeight
    \ifvoid0
      \setbox0=\vbox{\hbox to \wd2{}}%
    \fi
    \setbox\rowBefore=\hbox{\box2 \unhbox\rowBefore
      \hbox to 0pt{\hss\vbox{\hrule width\wd\cals@current@cs}}}%
    \setbox\rowAfter=\hbox{\box0 \unhbox\rowAfter}%
    \fi
    \next}
  \setbox0=\hbox{\unhbox\cals@current@row \next}
  %
  % Decoration backup, typeset the first row,
  % restore context, typeset the second at the end of macro
  %
  \setbox\decorationCopy=\copy\cals@current@cs
  \setbox\cals@current@row=\box\rowBefore
  \ht\cals@current@cs=\ht\cals@current@row
  \oldDispatch
  \cals@issue@break
  \cals@thead@tokens
  \setbox\cals@current@row=\box\rowAfter
  \cals@reheight@cells\cals@current@row
  \setbox\cals@current@cs=\box\decorationCopy
  \ht\cals@current@cs=\ht\cals@current@row
  \let\cals@current@context=b
  \fi
  \fi
  \oldDispatch}

\begin{document}
\begin{calstable}
\colwidths{{150pt}{150pt}}
\thead{\brow 
\def\cals@borderT{2pt}
\bfseries \cell{\parbox{150pt}{\centering \textbf{Header 1}}}\cell{\parbox{150pt}{\centering \textbf{Header 2}}}
  \mdseries \erow
\let\cals@borderT\relax}
\brow \cell{\lipsum[ 1]}\cell{\lipsum[ 2]} \erow
\brow \cell{\lipsum[ 4]}\cell{
\begin{itemize}[left= 5pt, noitemsep, topsep= 0pt, nosep]
    \item \lipsum[1][1-2]
    \item \lipsum[2][1-2]
    \item \lipsum[3][1-2]
    \item \lipsum[4][1-2]
\end{itemize}} \erow
\brow \cell{\lipsum[ 7]}\cell{\lipsum[ 8]} \erow
\brow \cell{\lipsum[10]}\cell{\lipsum[11]} \erow
\brow \cell{\lipsum[13]}\cell{\lipsum[14]} \erow
\end{calstable}
\end{document}

1
  • Ok, i accept this answer. Thank you so much Mr. David.
    – user516076
    Dec 26, 2020 at 0:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .