3
\documentclass{article}


\usepackage{cals}

\makeatletter
\renewcommand\cals@cs@width{0pt}
\renewcommand\cals@framecs@width{0pt}
\renewcommand\cals@rs@width{0pt}
\renewcommand\cals@framers@width{.5pt}
\renewcommand\cals@bodyrs@width{.5pt}
\makeatother

\begin{document}


{\fontsize{9}{11}\selectfont\begin{calstable}[c]
\colwidths{{38pt}{42pt}{39pt}{23pt}}
\thead{\bfseries\brow \cell{col1} \cell{col2} \cell{col3} \cell{col4}\erow\mdseries}
\brow\cell{col1}\cell{r1,col2} \cell{r1,col3} \cell{col4}\erow
\brow\cell{col1} \cell{r2,col2} \cell{r2,col3} \cell{col4}\erow
\brow\cell{\strut col1$_f^1$} \cell{\strut r3,col2$^1_5$} \cell{\strut r3,col3}\cell{\strut col4} \erow
\brow\cell{col1} \cell{r4,col2} \cell{r4,col3} \cell{col4}\erow
\brow\cell{\strut col1$5^+_5$} \cell{\strut r5,col2} \cell{\strut r5,col3} \cell{\strut col4}\erow
 \end{calstable}}


\end{document}
2
  • 1
    This is the first time i am hearing of cals.
    – Johannes_B
    Commented Jun 30, 2018 at 5:52
  • Maybe a \par in \end{calstable}\par} would solve the leading problem? Commented Jun 30, 2018 at 5:55

1 Answer 1

1

A little bit late, but never too late:

Leading

I am uncertain what OP means by ‘setting the leading to 11 pt’, but I interpret it as he is referring to the the line height and depth, which he has fixed to 11 pt by the command

\fontsize{9}{11}\selectfont

To ensure that all rows has equal height and depth, you may use a zero with column where you put a zero width rule of preferred height, i.e. 11pt. I define a shortcut \rl (rule)

\newcommand{\rl}{\rule{0pt}{11pt}}

I then add a fifth column 0pt wide.

To avoid Overfull hbox for this last column, you have to remove both left and right padding (side bearing). To achieve this, I use the shortcuts \lp and \rp, which I comments below. Now, all rows are 11 pt plus top and bottom padding (each approximatly 3.96pt). To ensure correct line up of all the cell, it is necessary to use \vfil inside the cell. The cell content is the vertically centred. It is easy to do this for all cells by using a special hook: \cals@AtBeginCell

\def\cals@AtBeginCell{\vfil}

Side bearing

You remove the side bearing in the first column by resetting the left padding to zero just before the cell starts, and reset it to the predefined value just after. Unfortunately, you have to do this for all cells in the first column, because as far as I know, cals has no commands that work on the entire column (nothing similar array's @{}). Therefore, I have defined a shortcut macro that operates as a switch. If the padding is zero, it resets padding to the previous value. If padding is not zero, the command sets the padding to zero.

\def\rp{\ifdim\cals@paddingL=0.0pt\relax    % Left padding switch (off-on)
        \cals@setpadding{Ag}                % Reset padding to standard value
\else \setlength{\cals@paddingL}{0pt}\fi}

You can define similar macros for right, top and bottom padding, and set each individually. I have included one for the right padding. Also, remember to reset to correct value. If you use the default leading, the macro is as above, if you have set your own value, you have to reset to that value:

\def\rp{\ifdim\cals@paddingR=0.0pt\relax    % Right padding switch (off-on)
        \setlength{\cals@paddingR}{5.5pt}   % Reset padding to custom value
\else \setlength{\cals@paddingR}{0pt}\fi}

The padding removal is a little bit more complex in this case, because we first have to remove the right padding from column 4, and in addition both left and right padding from the zero width column 5.

Here is an MWE and a picture of the output. I have right aligned last column just to demonstrate how the cell content is pushed to the right edge:

\documentclass{article}
\usepackage{cals}

\makeatletter
\renewcommand\cals@cs@width{0pt}
\renewcommand\cals@framecs@width{0pt}
\renewcommand\cals@rs@width{0pt}
\renewcommand\cals@framers@width{.5pt}
\renewcommand\cals@bodyrs@width{.5pt}

\def\lp{\ifdim\cals@paddingL=0.0pt\relax    % Left padding switch (off-on)
    \cals@setpadding{Ag} 
\else \setlength{\cals@paddingL}{0pt}\fi}

\def\rp{\ifdim\cals@paddingR=0.0pt\relax    % Right padding switch (off-on)
    \cals@setpadding{Ag}
\else \setlength{\cals@paddingR}{0pt}\fi}
\makeatother

\newcommand{\rl}{\rule{0pt}{11pt}}

\begin{document}

{\fontsize{9}{11}\selectfont
\begin{calstable}[c]
\colwidths{{38pt}{42pt}{39pt}{23pt}{0pt}}
\makeatletter
\def\cals@AtBeginCell{\vfil}  % All cells vertical adjusted
%\setlength{\cals@paddingT}{5.5pt}  % In case you need own value
%\setlength{\cals@paddingB}{5.5pt}  % In case you need own value

\thead{\bfseries%
\brow
    \lp\cell{col1}\lp          % Remove left padding
    \cell{col2}
    \cell{col3}
    \rp\alignR\cell{col4}\rp   % Remove right padding
    \lp\rp\cell{\rl}\lp\rp     % Remove left *and* right padding
\erow\mdseries
}
\brow
    \lp\alignL\cell{col1}\lp
    \cell{r3,col2$^1_5$}
    \cell{r1,col3}
    \rp\alignR\cell{col4}\rp
    \lp\rp\cell{\rl}\lp\rp
\erow
\brow
    \lp\alignL\cell{col1}\lp
    \cell{r2,col2}
    \cell{r2,col3}
    \rp\alignR\cell{col4}\rp
    \lp\rp\cell{\rl}\lp\rp
\erow
\brow
    \lp\alignL\cell{\strut col1$_f^1$}\lp
    \cell{\strut r3,col2$^1_5$}
    \cell{\strut r3,col3}
    \rp\alignR\cell{\strut col4}\rp
    \lp\rp\cell{\rl}\lp\rp
\erow
\brow
    \lp\alignL\cell{col1}\lp
    \cell{r4,col2}
    \cell{r4,col3}
    \rp\alignR\cell{col4}\rp
    \lp\rp\cell{\rl}\lp\rp
\erow
\brow
    \lp\alignL\cell{\strut col1$5^+_5$}\lp
    \cell{\strut r5,col2}
    \cell{\strut r5,col3}
    \rp\alignR\cell{\strut col4}\rp
    \lp\rp\cell{\rl}\lp\rp
\erow
\makeatother
\end{calstable}}
\end{document}

enter image description here

You must log in to answer this question.

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