在tblr里面执行逻辑操作的时候遇到了问题
计数器MWE:
\documentclass[zihao=-4,a4paper,punct=kaiming,oneside]{ctexart}
\usepackage{tabularray}
\UseTblrLibrary{counter}
% % 逻辑页计数器
\newcounter{lfrmc}
\setcounter{lfrmc}{0}
\NewExpandableDocumentCommand{\spl}{}
{%
\thelfrmc%
\addtocounter{lfrmc}{1}
}
\NewExpandableDocumentCommand{\lfrmh}{}
{%
empty&ok&\spl\\
}
\begin{document}
\begin{longtblr}[expand=\expanded]{
colspec={|X|X|X|}
}
\expanded{\lfrmh}
\expanded{\lfrmh}
\expanded{\lfrmh}
a&b&c\\\hline
\end{longtblr}
最右边一列希望是:0、1、2……递增
\end{document}
MWE
\documentclass[zihao=-4,a4paper,punct=kaiming,oneside]{ctexart}
% \input{pkg.tex}
\usepackage{xeCJK}
\usepackage{xeCJKfntef}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{varwidth}
\UseTblrLibrary{counter}
% \input{tuning.tex}
\ExplSyntaxOn
\tl_new:N \g_ttle_tl
\NewDocumentCommand{\ttle}{o m}
{
\tl_set:Nx \g_ttle_tl {#2}
}
\NewDocumentCommand{\sttle}{}
{
\tl_use:N \g_ttle_tl
}
\ExplSyntaxOff
% \input{tblr.tex}
% % 逻辑页计数器
\newcounter{lfrmc}
\setcounter{lfrmc}{0}
\NewExpandableDocumentCommand{\spl}{}
{%
\thelfrmc%
\addtocounter{lfrmc}{1}
}
\NewExpandableDocumentCommand{\lfrmh}{}
{%
empty&{\sttle\\nothing~here!}&\spl\\
}
\begin{document}
\begin{longtblr}[expand=\expanded]{
colspec={|X|X|X|}
}
\ttle[1]{tblr标题}%
\expanded{\lfrmh}
\expanded{\lfrmh}
1&2&3\\\hline
\end{longtblr}
\ttle[0]{第一个标题}
\sttle
\ttle[1]{第两个标题}
\sttle
\end{document}
上面是mwe,完整的源代码如下:
% main.tex
\documentclass[zihao=-4,a4paper,punct=kaiming,oneside]{ctexart}
\input{pkg.tex}
\input{tuning.tex}
\input{tblr.tex}
\NewExpandableDocumentCommand\yes{O{Yes}m}{\SetCell{bg=green9}#1}
\NewExpandableDocumentCommand\no{O{No}m}{\SetCell{bg=red9}#1}
\begin{document}
\begin{longtblr}[expand=\expanded]{measure=vbox,
colspec={|[\hv]Q[c,t,2.5\qcwd] |Q[l,t,26.6\tcwd] |X[c,t]|[\hv]},
column{1} = {font=\zihao{4}\heiti\color{red}},
column{2} = {font=\zihao{3}\sffamily},
column{3} = {font=\zihao{4}\ttfamily},
row{even} = {bg=white},
row{odd } = {bg=black!10},
}
\hdline\SetCell[c=3]{l,m}{\zihao{3}重置计时器}&2&3\\\ftline
&\SetCell{l,m}{info\\ttle}&
\SetCell{c,m}{\zihao{3}\bfseries lf}
\\\hvline
{自动}&{一二三四五六七八九十,一二三四五六七八九十一二三四五六七八九十}&pf\\\hline
{手动}&{甲乙丙丁}&pf\\\hline
{自动}&{甲乙丙丁}&pf\\\hline
{自动}&{甲乙丙丁}&pf\\\ftline%
\section{节1}%
\ttle[1]{题目2}%
\expanded{\lfrmh}
\expanded{\lfrmh}
&\expanded{\yes[from~doc]{fromdoc}}\\
\hdline\SetCell[c=3]{l,m}{\zihao{3}演讲结束}&2&3\\\ftline
\end{longtblr}
\ttle[0]{第一个标题}
\sttle
\sinfo
\section{123}
\ttle[1]{第两个标题}
\sttle
\sinfo
\ttle{第三个标题}
\sttle
\sinfo
\par
分割线
\spar
\senum
\end{document}
% pkg.tex
\usepackage{xeCJK}
\usepackage{xeCJKfntef}
% 设置英文字体
% \setsansfont{Inter-SemiBold.ttf}
% 设置中文字体
% \setCJKsansfont{FZLTZHK.TTF}
\usepackage[bodytextleadingratio=1.66666]{zhlineskip}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{varwidth}
\UseTblrLibrary{counter}
\usepackage{tikz}
\DefTblrTemplate{contfoot-text}{default}{下一页……}
\DefTblrTemplate{caption}{default}{}
% \DefTblrTemplate{conthead}{default}{}
\DefTblrTemplate{capcont}{default}{}
\usepackage{geometry}
\geometry{a4paper,
% showframe,
margin={0.5in,0.5in},
headheight= 1\baselineskip,
headsep = .1\baselineskip,
footskip = 1\baselineskip
}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[L]{\zihao{5}\zhtoday}
\fancyhead[R]{\zihao{5}\zhcurrtime}
\fancyhead[C]{\zihao{5}稿件}
\fancyfoot[C]{\zihao{5}\thepage}
\renewcommand{\headrulewidth}{0pt}
% \renewcommand{\footrulewidth}{0.5pt}
% tuning.tex
% 2024年8月26日-16点28分
\ExplSyntaxOn
\NewDocumentCommand{\startmarker}{}{}
% 暂存章节命令
\cs_set_eq:NN \tempsect \section
\cs_set_eq:NN \tempsubs \subsection
\cs_set_eq:NN \tempssub \subsubsection
% \cs_set_eq:NN \tempttle \title
\NewDocumentCommand{\recoversect}{}
{
\cs_set_eq:NN \section \tempsect
\cs_set_eq:NN \subsection \tempsubs
\cs_set_eq:NN \subsubsection \tempssub
% \cs_set_eq:NN \title \tempttle
}
% 章节名称寄存器
\tl_new:N \g_sect_tl
\tl_new:N \g_subs_tl
\tl_new:N \g_ssub_tl
% 章节信息
\tl_new:N \g_info_tl
% 标题信息
\tl_new:N \g_ttle_tl
% 章节标题信息
\tl_new:N \g_mixd_tl
% 深度计数器,0:/, 1:sect,...
\int_new:N \g_dpth_int
\int_gset:Nn \g_dpth_int {0}
% 序列相关
% 声明一个全局序列,存储“路径:标题”
\seq_new:N \g_mixd_seq
\seq_gclear:N \g_mixd_seq
\cs_new:Npn \concat_mixd:
{
\tl_set:Nx \g_mixd_tl { \tl_use:N \g_info_tl \tl_use:N \g_ttle_tl }
% \par\noindent 调试:g_info_tl:【\g_info_tl】g_ttle_tl:【\g_ttle_tl】g_mixd_tl:【\g_mixd_tl】\par
}
\cs_new:Npn \addseq_mixd:
{
\seq_put_right:Nx \g_mixd_seq { \tl_use:N \g_mixd_tl }
% \par\noindent 调试:g_mixd_seq: 【\seq_use:Nn \g_mixd_seq {,}】\par
}
\cs_new:Npn \cminfo:
{
\concat_mixd:
% \par\noindent 调试:cminfo\par
\addseq_mixd:
}
% %%%%%%%%%%%%
\RenewDocumentCommand{\section}{m}
{
\tl_set:Nn \g_sect_tl {#1}
}
\RenewDocumentCommand{\subsection}{m}
{
\tl_set:Nn \g_subs_tl {#1}
}
\RenewDocumentCommand{\subsubsection}{m}
{
\tl_set:Nn \g_ssub_tl {#1}
}
\NewDocumentCommand{\ttle}{o m}% 1,2
{
\tl_set:Nx \g_ttle_tl {#2}
\IfNoValueTF{#1}
{ % NoValue
\int_case:nnF {\g_dpth_int}
{
{0}{\tl_set:Nx \g_info_tl
{ \S{} }
\cminfo:
}
{1}{\tl_set:Nx \g_info_tl
{ \startmarker \tl_use:N \g_sect_tl / }
\cminfo:
}
{2}{\tl_set:Nx \g_info_tl
{ \startmarker \tl_use:N \g_sect_tl / \tl_use:N \g_subs_tl / }
\cminfo:
}
{3}{\tl_set:Nx \g_info_tl
{ \startmarker \tl_use:N \g_sect_tl / \tl_use:N \g_subs_tl / \tl_use:N \g_ssub_tl / }
\cminfo:
}
}
\cminfo:
}
{ % HasValue
\int_set:Nn \g_dpth_int {#1}
\int_case:nnF {#1}
{
{0}{\tl_set:Nx \g_info_tl
{ \startmarker }
\cminfo:
}
{1}{\tl_set:Nx \g_info_tl
{ \startmarker \tl_use:N \g_sect_tl / }
\cminfo:
}
{2}{\tl_set:Nx \g_info_tl
{ \startmarker \tl_use:N \g_sect_tl / \tl_use:N \g_subs_tl / }
\cminfo:
}
{3}{\tl_set:Nx \g_info_tl
{ \startmarker \tl_use:N \g_sect_tl / \tl_use:N \g_subs_tl / \tl_use:N \g_ssub_tl / }
\cminfo:
}
}
{【错误:ttle参数错误】}
}
}
%%%%
\NewDocumentCommand{\sttle}{}
{
\tl_use:N \g_ttle_tl
% \tl_show:N \g_ttle_tl \tl_show:N \g_info_tl
}
\NewDocumentCommand{\sinfo}{}
{
\tl_use:N \g_info_tl
}
\NewDocumentCommand{\spar}{}
{
\seq_map_inline:Nn \g_mixd_seq
{
##1 \par % 输出令牌列表并换段
}
}
\NewDocumentCommand{\senum}{}
{
\begin{enumerate}
\seq_map_inline:Nn \g_mixd_seq
{
\item ##1
}
\end{enumerate}
}
%%%%
\ExplSyntaxOff
% tblr.tex
\newlength{\tcwd}
\setlength{\tcwd}{16bp}
\newlength{\qcwd}
\setlength{\qcwd}{14bp}
\newlength{\hv}
\setlength{\hv}{2\heavyrulewidth}
% % 逻辑页计数器
\newcounter{lfrmc}
\setcounter{lfrmc}{0}
% % 幻灯页计数器
\newcounter{pfrmc}
\setcounter{pfrmc}{0}
\NewExpandableDocumentCommand{\spl}{}
{%
\thelfrmc%
\addtocounter{lfrmc}{1}
}
\NewExpandableDocumentCommand{\spp}{}
{%
\thepfrmc%
\addtocounter{pfrmc}{1}
}
\NewTableCommand\hvline{\SetHline[1]{1-3}{black,5\cmidrulewidth}}
\NewTableCommand\hdline{\SetHline[1]{1-3}{black,2\heavyrulewidth}}
\NewTableCommand\ftline{\SetHline[1]{1-3}{black,2\heavyrulewidth}%
\SetHline[2]{1-3}{white,4\heavyrulewidth}%
\SetHline[3]{1-3}{black,2\heavyrulewidth}%
}
\NewExpandableDocumentCommand{\lfrmh}{}
{%
null&{\sttle\\\sinfo}&\spl\\
}
% {
% &\SetCell{l,m}{
% \expanded{\sinfo}%
% \\%
% \expanded{\sttle}%
% }&\SetCell{c,m}%
% {\zihao{3}\bfseries \thelfrmc}%
% \addtocounter{lfrmc}{1}
% \\\hvline%
% }
% \NewTableCommand\lfrmf{\ftline}
在写一个演讲稿模板,已经基本全部写完,但是……在tblr里面执行逻辑操作的时候遇到了问题