我尝试使用卡路里-package,但遇到了问题。我尝试移除侧轴承(通过>@{}
使用大批)。据我所知,我必须通过\setlength{\cals@paddingL}{0pt}
在第一列的所有最左侧单元格处发出一个来删除最左列的左填充,然后通过\cals@setpadding{Ag}\
在该单元格后立即恢复它。右侧也是如此。
这种方法在表格主体中有效,如附图所示。但是,如果我使用标题 ( \thead{<code>}
) 中的代码,则代码无法编译。对于随附的 MWE,您会收到错误消息,指示未定义命令。
这是 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}
这是日志文件:
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 }
?
是错误还是用户错误?
答案1
Catcode 更改(\makeatletter
、\makeatother
等)将无法用作宏参数。您正在执行\thead{... \makeatletter\setlength{\cals@paddingL}{0pt}}
。这被标记为\makeatletter\setlength{\cals @paddingL}{0pt}
(注意 后面的空格\cals
)。您需要将\makeatletter
和移到\makeatother
之外\thead
。
您还可以减少一堆\makeatletter<code with @>\makeatother
并\makeatletter
在所有代码@
开始时使用一个,并\makeatother
在所有结束时使用一个。
此外,\bfseries
已经这样做了\selectfont
,因此后者在这里是多余的:
\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}