以下最小工作示例cals
在文档环境中使用了一个表格,并且运行良好:
\documentclass{article}
%document encoding
\usepackage[utf8]{inputenc}
%geometry
\RequirePackage[a4paper, layoutwidth=10.5cm, layoutheight=20cm, noheadfoot, nomarginpar, margin=0mm, showcrop]{geometry}
\RequirePackage{calc}
\geometry{layouthoffset=0.5\paperwidth-5.25cm}
\geometry{layoutvoffset=0.5\paperheight-10cm}
\setlength{\topskip}{0mm}
\setlength{\parindent}{0mm}
%table
\RequirePackage{cals}
\begin{document}
\thispagestyle{empty}
\begin{calstable}
\makeatletter
\colwidths{{3.30cm}{1.95cm}{5.25cm}}
\def\cals@cs@width{0.8pt}
\def\cals@rs@width{0.8pt}
\setlength{\cals@paddingT}{1.44ex}
\setlength{\cals@paddingL}{1em}
\brow \nullcell{tbl}\nullcell{tb}\nullcell{tbr}\spancontent{} \ht\cals@current@row=30mm \erow
\brow \alignC \nullcell{tbl}\nullcell{tbr}\spancontent{} \alignL \cell{} \ht\cals@current@row=22mm \erow
\makeatother
\end{calstable}
\end{document}
但是,当我将代码放入\newcommand
调用中时\calscommand
,出现Use of \cals doesn't match its definition \calscommand
错误:
\documentclass{article}
%document encoding
\usepackage[utf8]{inputenc}
%geometry
\RequirePackage[a4paper, layoutwidth=10.5cm, layoutheight=20cm, noheadfoot, nomarginpar, margin=0mm, showcrop]{geometry}
\RequirePackage{calc}
\geometry{layouthoffset=0.5\paperwidth-5.25cm}
\geometry{layoutvoffset=0.5\paperheight-10cm}
\setlength{\topskip}{0mm}
\setlength{\parindent}{0mm}
%table
\RequirePackage{cals}
\newcommand{\calscommand}{%
\thispagestyle{empty}
\begin{calstable}
\makeatletter
\colwidths{{3.30cm}{1.95cm}{5.25cm}}
\def\cals@cs@width{0.8pt}
\def\cals@rs@width{0.8pt}
\setlength{\cals@paddingT}{1.44ex}
\setlength{\cals@paddingL}{1em}
\brow \nullcell{tbl}\nullcell{tb}\nullcell{tbr}\spancontent{} \ht\cals@current@row=30mm \erow
\brow \alignC \nullcell{tbl}\nullcell{tbr}\spancontent{} \alignL \cell{} \ht\cals@current@row=22mm \erow
\makeatother
\end{calstable}
}
\begin{document}
\calscommand
\end{document}
我究竟做错了什么?
答案1
移动
\makeatletter
在你的定义之前
\makeatother
之后。您需要 @
将 用作命令名称中使用的字母,该字母位于您使用这些命令的定义处,而不是定义内部。