1

I try to write tabulars using the cals-package, but have run into a problem. I try to remove the side bearings (what you achieve by >@{} using array). As far as I understand, I have to remove left padding of leftmost column by issuing a \setlength{\cals@paddingL}{0pt} at all leftmost cells in the first column, and restore it by \cals@setpadding{Ag}\ immediately after the cell. The same goes for the right side.

This approach works in the body of the table as you will see from the enclosed picture. However, if I use the code in the heading (\thead{<code>}), the code does not compile. For the MWE enclosed, you get the error message indicating a command is not defined.

enter image description here

Here is the MWE (MnWE):

\documentclass{article}
\usepackage{cals}
\begin{document}

\begin{calstable}
\colwidths{{50pt}{100pt}}
%
\thead{\bfseries\selectfont
\brow
    \makeatletter\setlength{\cals@paddingL}{0pt}\makeatother % If you comment out line 16 and 18 the MWE compiles
    \cell{col1}
    \makeatletter\cals@setpadding{Ag}\makeatother % Comment out to compile
    \cell{col2}
\erow
\mdseries\selectfont}
\tfoot{\lastrule\nointerlineskip
\textit{\strut Some table caption
(not implemented: PartKofN)}\par}
%
\brow
    \makeatletter\setlength{\cals@paddingL}{0pt}\makeatother
    \cell{r1,col1}
    \makeatletter\cals@setpadding{Ag}\makeatother
    \makeatletter\setlength{\cals@paddingR}{0pt}\makeatother
    \alignR\cell{r1,col2}
    \makeatletter\cals@setpadding{Ag}\makeatother
 \erow
%
\brow
    \alignL\cell{r2,col1}
    \alignR\cell{r2,col2}
\erow
%
\brow
    \alignL\cell{r3,col1}
    \cell{r3,col2}
\erow
%\tbreak{Manual table break!\strut\par}
\brow
    \cell{r4,col1}
    \cell{r4,col2}
\erow
%
\brow
    \cell{r5,col1}
    \cell{r5,col2}
\erow
\end{calstable}
\end{document}

Here is the log-file:

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7050)
entering extended mode
(C:/temp/test-cals-ex2.tex
LaTeX2e <2018-12-01>
(C:\miktex\texmfs\install\tex/latex/base\article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(C:\miktex\texmfs\install\tex/latex/base\size10.clo))
(C:\miktex\texmfs\install\tex/latex/cals\cals.sty)
No file test-cals-ex2.aux.
! Undefined control sequence.
<argument> \cals 
                 @paddingL
l.15 }

? 

A bug or a user error?

2
  • You are missing a \ in makeatletter: \brow makeatletter\setlength{\cals@paddingL May 24, 2019 at 13:57
  • @PhelypeOleinik That is just a typo in the question, the source code is correct. I have also corrected two other typos.
    – Sveinung
    May 24, 2019 at 13:59

1 Answer 1

2

Catcode changes (\makeatletter, \makeatother, and the like) will not work as macro arguments. You are doing \thead{... \makeatletter\setlength{\cals@paddingL}{0pt}}. This is tokenized as \makeatletter\setlength{\cals @paddingL}{0pt} (notice the space after \cals). You need to move \makeatletter and \makeatother outside \thead.

You can also reduce a bunch of the \makeatletter<code with @>\makeatother and use one \makeatletter when the all the code with @ starts and a \makeatother when it all ends.

Also, \bfseries already does \selectfont, so the latter is redundant here:

\documentclass{article}
\usepackage{cals}
\begin{document}

\begin{calstable}
\colwidths{{50pt}{100pt}}
%
\makeatletter
\thead{\bfseries
\brow
    \setlength{\cals@paddingL}{0pt}% If you comment out line 16 and 18 the MWE compiles
    \cell{col1}
    \cals@setpadding{Ag}% Comment out to compile
    \cell{col2}
\erow
\mdseries}
\makeatother
\tfoot{\lastrule\nointerlineskip
\textit{\strut Some table caption
(not implemented: PartKofN)}\par}
%
\makeatletter% @=11
\brow
    \setlength{\cals@paddingL}{0pt}%
    \cell{r1,col1}
    \cals@setpadding{Ag}
    \setlength{\cals@paddingR}{0pt}
    \alignR\cell{r1,col2}
    \cals@setpadding{Ag}
\erow
\makeatother% @=12
%
\brow
    \alignL\cell{r2,col1}
    \alignR\cell{r2,col2}
\erow
%
\brow
    \alignL\cell{r3,col1}
    \cell{r3,col2}
\erow
%\tbreak{Manual table break!\strut\par}
\brow
    \cell{r4,col1}
    \cell{r4,col2}
\erow
%
\brow
    \cell{r5,col1}
    \cell{r5,col2}
\erow
\end{calstable}
\end{document}
6
  • Thank you, this worked. The example was taken from the documentation (to be sure that I did not introduced some stupid mistakes, which I unintentionally did :)).
    – Sveinung
    May 24, 2019 at 14:13
  • @Sveinung A wise man once said: never read the documentation :-) May 24, 2019 at 14:18
  • I always read the documentation three times before I start. :(. Follow up: If I start the calstable with a \makeatletter and end it with a \makeatother, will I run the risk that I suddenly run into trouble because of the content of a cell?
    – Sveinung
    May 24, 2019 at 14:31
  • @Sveinung (About the documentation, it was a joke; it's good to read it once in a while :) I find it rather unlikely that you'll get in trouble for using \makeatletter there. Unless you have some input file which contains something like \some@macro and you need it to be \some<space>@macro. Otherwise you should be fine. May 24, 2019 at 14:46
  • I understood the joke. Another wise man said that you learn as long as you live. So the conclusion (after have read your answer) is that I am still alive. Have a nice week-end!
    – Sveinung
    May 24, 2019 at 15:23

You must log in to answer this question.

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