Files
ouc_latex_template/点名册/oucroll.sty
T
laoyang b3df669850 新增《点名册》模板:A4 横向,18 周考勤表 #26
- 20 列表格:序号 / 学号 / 姓名 / 第 1~17 周
- A4 横向 297x210mm,单页 30 行
- 课程信息区:课程名称、课程号、选课号、学分、任课教师、学年学期
- 字体来自 ../fonts.tex,与其他模板一致
- 已加入 verify_all.sh

全库 17/17 编译通过,点名册 1 页、error 0、Overfull 0。
2026-11-03 21:38:34 +08:00

187 lines
6.7 KiB
TeX
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{oucroll}[2026/11/03 v1.0 OUC roll-call sheet]
%======================================================================
% oucroll.sty —— 点名册版式包
%
% 横版 A4,20 列表格:序号 / 学号 / 姓名 / 第1~17周
% 用法见同目录 README.md
%======================================================================
\RequirePackage{geometry}
\RequirePackage{fontspec}
\RequirePackage{xeCJK}
\RequirePackage{tabularray}
\RequirePackage{calc}
%======================================================================
% 一、页面:A4 横向
%======================================================================
\geometry{
paperwidth = 297mm,
paperheight = 210mm,
left = 14mm,
right = 14mm,
top = 12mm,
bottom = 16mm,
headheight = 0pt,
headsep = 0pt,
footskip = 8mm,
}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\pagestyle{empty} % 点名册单页,不排页码
\input{../fonts.tex}
%======================================================================
% 二、字号
%======================================================================
\newcommand{\rollbasefont}{%
\linespread{1}\relax
\fontsize{10.5bp}{13bp}\selectfont}
\newcommand{\rolltitlefont}{\linespread{1}\relax\fontsize{20bp}{24bp}\selectfont}
\newcommand{\rollinfofont} {\linespread{1}\relax\fontsize{10.5bp}{13bp}\selectfont}
\newcommand{\rollheadfont} {\linespread{1}\relax\fontsize{8bp}{9.5bp}\selectfont}
\newcommand{\rollcellfont} {\linespread{1}\relax\fontsize{10bp}{12.5bp}\selectfont}
\newcommand{\rollweekfont} {\linespread{1}\relax\fontsize{7.5bp}{9bp}\selectfont}
%======================================================================
% 三、列宽
%
% 版心宽 269mm(297 − 14×2)。
% tabularray 的实际表宽 = Σwd + 2×colsep×列数 + 竖线宽×列数
% 20 列时:2×0.4×20 = 16.00mm,竖线 0.4pt×20 = 2.82mm,共 18.82mm
% 故 Σwd 只能取 269 − 18.82 = 250.18mm
%
% 序号 9 + 学号 26 + 姓名 20 = 55mm
% 余 195.18mm 分给 17 周,每周 11.4810mm
%======================================================================
\newcommand{\rollrule}{0.4pt}
\newcommand{\rollcolsep}{0.4mm}
\newcommand{\rollwno}{9mm} % 序号
\newcommand{\rollwid}{26mm} % 学号
\newcommand{\rollwname}{20mm} % 姓名
\newcommand{\rollwweek}{11.4734mm} % 每周
%======================================================================
% 四、课程信息
%
% \rollinfo{课程名称}{数值}
% 信息行按「标签 + 值」成对排版,一行放三项。
%======================================================================
\newcommand{\rollcourse}{} % 课程名称
\newcommand{\rollcno}{} % 课程号
\newcommand{\rollsno}{} % 选课号
\newcommand{\rollcredit}{} % 学分
\newcommand{\rollteacher}{} % 任课教师
\newcommand{\rollterm}{} % 学年学期
\newcommand{\rolldept}{} % 开课单位
\newcommand{\rollsetcourse}[1]{\renewcommand{\rollcourse}{#1}}
\newcommand{\rollsetcno}[1]{\renewcommand{\rollcno}{#1}}
\newcommand{\rollsetsno}[1]{\renewcommand{\rollsno}{#1}}
\newcommand{\rollsetcredit}[1]{\renewcommand{\rollcredit}{#1}}
\newcommand{\rollsetteacher}[1]{\renewcommand{\rollteacher}{#1}}
\newcommand{\rollsetterm}[1]{\renewcommand{\rollterm}{#1}}
\newcommand{\rollsetdept}[1]{\renewcommand{\rolldept}{#1}}
% 一项:标签(黑体) + 值
\newcommand{\rollfield}[2]{%
{\heiti #1}:#2}
%======================================================================
% 五、标题
%======================================================================
\newcommand{\rolltitle}[1]{%
\par\begingroup\centering
{\heiti\rolltitlefont #1\par}%
\endgroup\vspace*{2mm}}
%======================================================================
% 六、课程信息区
%
% 两行,每行三项,用 \hfill 撑开
%======================================================================
\newcommand{\rollinfo}{%
\begingroup\rollinfofont
\noindent
\rollfield{课程名称}{\rollcourse}\hfill
\rollfield{课程号}{\rollcno}\hfill
\rollfield{选课号}{\rollsno}\par\vspace*{1.2mm}
\noindent
\rollfield{学分}{\rollcredit}\hfill
\rollfield{任课教师}{\rollteacher}\hfill
\rollfield{学年学期}{\rollterm}\par
\endgroup\vspace*{2.5mm}}
%======================================================================
% 七、周次表头
%
% 「第 1 周」写成「1」,表头下方一行标注「周次」,这样表头只占
% 一行高度,横向也省空间 —— 20 列挤在一行里,竖排会撑高表头。
%======================================================================
\newcommand{\rollweekhead}[1]{%
{\heiti\rollheadfont #1}}
%======================================================================
% 八、表格环境
%
% 20 列:3 固定 + 17 周
% 表头单行:序号 / 学号 / 姓名 / 1 / 2 / … / 17
%======================================================================
\newcounter{rollrow}
\newenvironment{rolltable}{%
\par\begingroup\rollcellfont
\begin{tblr}[label=none, expand=\rollrow]{
colspec={
Q[c,m,wd=\rollwno]
Q[c,m,wd=\rollwid]
Q[c,m,wd=\rollwname]
*{17}{Q[c,m,wd=\rollwweek]}
},
colsep=\rollcolsep, rowsep=0pt, stretch=0,
hline{1-Z}={\rollrule}, vline{1-Z}={\rollrule},
row{1}={ht=7.0mm},
row{2-Z}={ht=4.5mm},
}%
% ---- 表头 ----
{\heiti\rollheadfont 序号} &
{\heiti\rollheadfont 学号} &
{\heiti\rollheadfont 姓名} &
\rollweekhead{1} & \rollweekhead{2} & \rollweekhead{3} & \rollweekhead{4} &
\rollweekhead{5} & \rollweekhead{6} & \rollweekhead{7} & \rollweekhead{8} &
\rollweekhead{9} & \rollweekhead{10} & \rollweekhead{11} & \rollweekhead{12} &
\rollweekhead{13} & \rollweekhead{14} & \rollweekhead{15} & \rollweekhead{16} &
\rollweekhead{17} \\
}{%
\end{tblr}\par\endgroup}
%======================================================================
% 九、数据行
%
% \rollrow{序号}{学号}{姓名}
% 后面 17 个空格留给手填考勤。
%
% ⚠️ 必须用 \def 而不是 \newcommand:tblr 的 expand= 选项在读取
% 环境体时就展开,\newcommand 生成的宏不可展开,& 会被当成
% 「Misplaced alignment tab」报错。
%======================================================================
\def\rollrow#1#2#3{%
#1 & #2 & #3 &
& & & & & & & & & & & & & & & & \\
}
%======================================================================
% 十、脚注(可选)
%======================================================================
\newcommand{\rollfoot}[1]{%
\par\vspace*{2mm}%
\begingroup\rollinfofont{\heiti 说明:}#1\par\endgroup}
\AtBeginDocument{\rollbasefont}
\endinput