summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-11-21 21:59:30 +0000
committerKarl Berry <karl@freefriends.org>2018-11-21 21:59:30 +0000
commit228e5563a08cef3526d4f4a9b744ce328d243797 (patch)
treed59ba53751f7b2d4c569fa2cc30d8868e7cdda38 /Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls
parent9e976587f069902490e28823c0fb71edfb087d0f (diff)
jnuexam (21nov18)
git-svn-id: svn://tug.org/texlive/trunk@49212 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls')
-rw-r--r--Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls376
1 files changed, 323 insertions, 53 deletions
diff --git a/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls b/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls
index 0b2b11fc4f4..e839799d0e8 100644
--- a/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls
+++ b/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls
@@ -6,15 +6,19 @@
% ----------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{jnuexam}[2018/07/07 v0.3 An exam class for Jinan University]
+\ProvidesClass{jnuexam}[2018/11/21 v0.5 An exam class for Jinan University]
\newif\ifsidebyside \sidebysidefalse % 是否 A3 纸张
\newif\ifreverse \reversefalse % 是否逆序出题
\newif\ifanswer \answertrue % 是否显示答案
+\newif\ifsourcehan \sourcehanfalse % 切换思源字体
+\newif\ifcollection \collectionfalse % 用于试卷题库
\DeclareOption{a3paper}{\sidebysidetrue}
\DeclareOption{reverse}{\reversetrue}
\DeclareOption{noanswer}{\answerfalse}
+\DeclareOption{sourcehan}{\sourcehantrue}
+\DeclareOption{collection}{\collectiontrue}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{ctexart}} %其它选项
@@ -30,6 +34,26 @@
\RequirePackage[a4paper,left=30mm,right=30mm,top=25mm,bottom=25mm]{geometry}
\fi
+\RequirePackage{tabu}
+\RequirePackage{amssymb}
+\RequirePackage{lastpage}
+\RequirePackage{fancyhdr}
+\RequirePackage{xcolor}
+\RequirePackage{comment}
+\RequirePackage{environ}
+\RequirePackage{etoolbox}
+\RequirePackage{calc}
+
+\setlength{\parindent}{0em}
+\setlength{\lineskiplimit}{3pt}
+\setlength{\lineskip}{3pt}
+
+%% ---------------------------------------------------------------------------
+%% 密封线命令 \mifengxian
+%% 草稿纸命令 \caogaozhi
+%% 这两个命令仅在 A3 纸张中用到,且需要编译两次才能得到正确结果
+%% ---------------------------------------------------------------------------
+
\newcommand{\mifengxian}{%
\def\1{\\[50mm]}\def\2{\\[15mm]}%
\begin{tikzpicture}[remember picture,overlay,very thick,font=\large]
@@ -47,18 +71,6 @@
\node[text=lightgray!40] at (current page.center) {草\quad 稿\quad 纸};
\end{tikzpicture}}
-\RequirePackage{amsmath}
-\RequirePackage{tabu}
-\RequirePackage{multirow}
-\RequirePackage{pifont}
-\RequirePackage{lastpage}
-\RequirePackage{fancyhdr}
-\RequirePackage{xcolor}
-\RequirePackage{comment}
-\RequirePackage{environ}
-\RequirePackage{etoolbox}
-\RequirePackage{CJKfntef}
-
\ifsidebyside
\RequirePackage{tikz}
\RequirePackage{everypage}
@@ -75,9 +87,9 @@
\@ifundefined{@setmarks}{\let\@setmarks\relax}{}
\fi
-\setlength{\parindent}{0em}
-\setlength{\lineskiplimit}{3pt}
-\setlength{\lineskip}{3pt}
+%% ---------------------------------------------------------------------------
+%% 试卷表头命令 \makehead
+%% ---------------------------------------------------------------------------
\newcommand{\niandu}{2016-2017}
\newcommand{\xueqi}{2}
@@ -91,12 +103,12 @@
\newcommand{\neizhao}{1} % 1 打勾,0 不勾
\newcommand{\waizhao}{1} % 1 打勾,0 不勾
-\newcommand{\underspace}[1]{\underline{\hspace{#1}}}
-\newcommand{\underbox}[2]{\underline{\makebox[#1]{#2}}}
-\newcommand{\underparbox}[2]{\underline{\parbox[b]{#1}{#2}}}
+\newcommand{\underspace}[1]{\kern0pt\underline{\hspace{#1}}\kern0pt\relax}
+\newcommand{\underbox}[2]{\kern0pt\underline{\makebox[#1]{#2}}\kern0pt\relax}
+\newcommand{\underparbox}[2]{\kern0pt\underline{\parbox[b]{#1}{#2}}\kern0pt\relax}
-\newcommand{\ischeck}[1]{\ifnum#1>0\,\ding{51}\,\else\quad\fi}
-\newcommand{\isquad}[1]{\ifnum#1=0\,\ding{51}\,\else\quad\fi}
+\newcommand{\ischeck}[1]{\ifnum#1>0\,$\checkmark$\,\else\quad\fi}
+\newcommand{\isquad}[1]{\ifnum#1=0\,$\checkmark$\,\else\quad\fi}
\newcommand\my@temp@a{A}
\newcommand\my@temp@c{C}
@@ -104,7 +116,7 @@
\newcommand{\head@table@a}{%
\begin{tabular}{l}
- \underbox{10em}{\niandu} 学年度第 \underbox{5.5em}{\xueqi} 学期 \\
+ \underbox{11em}{\niandu}学年度第\underbox{5.5em}{\xueqi}学期 \\
课程名称:\underbox{17.5em}{\kecheng\ifx\zhuanye\my@empty\else\kern0pt(\zhuanye)\fi} \\
授课教师:\underparbox{17.5em}{\centering\rule{0pt}{3ex}\jiaoshi} \\
考试时间:\underbox{17.5em}{\shijian} \\
@@ -124,8 +136,8 @@
\newcommand{\head@table@c}{%
\begin{tabular}{l}
- \underspace{10em} 学院 \underspace{8em} 专业 \underspace{5.5em}~班~(级) \\[1em]
- 姓名\underspace{8em} 学号 \underspace{10em}\hfill
+ \underspace{10em}学院\underspace{8em}专业\underspace{7.5em}班\kern0pt(\kern0pt{}级\kern0pt) \\[1em]
+ 姓名\underspace{8em}学号\underspace{10em}\hfill
\bfseries 内招~[\ischeck{\neizhao}] 外招~[\ischeck{\waizhao}] %\\[0.8em]
\end{tabular}
}
@@ -160,6 +172,10 @@
\end{tabu}
}
+%% ---------------------------------------------------------------------------
+%% 页眉页脚设定
+%% ---------------------------------------------------------------------------
+
\newcommand{\my@columnbox}[1]{\makebox[\columnwidth]{#1}}
\newcommand{\my@headleft}{暨南大学\kern-0.3em《\kecheng》\kern-0.3em 试卷\,\shijuan}
\newcommand{\my@headright}{姓名\hspace{6em}学号\hspace{6em}}
@@ -191,10 +207,19 @@
\cfoot{\small\my@foottext}
\fi
+%% ---------------------------------------------------------------------------
+%% 题型命令 \makepart
+%% 附录命令 \makedata
+%% 题目环境 problem
+%% 解答环境 solution
+%% 逆序选项 reverse
+%% ---------------------------------------------------------------------------
+
\xdef\allproblems{}
\xdef\lastproblem{}
\newcounter{problem}
-\newcounter{choice}
+\newcounter{choice} % 后面选择题的 abcd 环境要用到
+\newcounter{step} % 后面解答题的 \step 命令要用到
\newcommand{\printproblems}{\ifreverse\lastproblem\allproblems\fi\xdef\allproblems{}\xdef\lastproblem{}}
@@ -220,28 +245,16 @@
\preto{\@enddocumenthook}{\printproblems\my@stop@reverse}
-\newcommand{\answer}[1]{\ifanswer#1\else\phantom{#1}\fi}
-
-\newcommand{\ulinefill}[1]{\xleaders\hbox{\underline{\vphantom{#1}\kern1pt}}\hfill\kern0pt}
-\newcommand{\fillout}[1]{\ulinefill{#1}\underline{\color{blue}\answer{#1}}\ulinefill{#1}}
-\newcommand{\fillin}[1]{\underline{\hspace{1em}\color{blue}\answer{#1}\hspace{1em}}}
-
-\newcommand{\pickout}[1]{\hfill(\makebox[1.5em]{\color{blue}\answer{#1}})}
-\newcommand{\pickin}[1]{(\makebox[1.5em]{\color{blue}\answer{#1}})}
-
-\newcommand{\my@item}{\ifnum\value{choice}=0\par\fi\stepcounter{choice}}
-\newcommand{\fullitem}[1]{\my@item\parbox{\linewidth}{(\Alph{choice})\ #1\rule[-0.5em]{0pt}{0.5em}}\hfill\ignorespaces}
-\newcommand{\halfitem}[1]{\my@item\makebox[0.5\linewidth][l]{(\Alph{choice})\ #1}\hfill\ignorespaces}
-\newcommand{\quaritem}[1]{\my@item\makebox[0.25\linewidth][l]{(\Alph{choice})\ #1}\hfill\ignorespaces}
-
\newcommand\ignorepars{\@ifnextchar\par{\expandafter\ignorepars\@gobble}{}}
\newenvironment{problemreal}{%
- \stepcounter{problem}\setcounter{choice}{0}%
+ \stepcounter{problem}\setcounter{choice}{0}\setcounter{step}{0}%
\textsf{\color{blue}\arabic{problem}}.\;\,\ignorespaces
}{\par}
-\newenvironment{solutionreal}{\textsf{\color{blue}解答}\quad\ignorepars}{\par}
-\newenvironment{proofreal}{\textsf{\color{blue}证明}\quad\ignorepars}{\par}
+\newenvironment{solutionreal}{%
+ \setcounter{step}{0}%
+ \textsf{\color{blue}解答}\quad\ignorepars
+}{\par}
\let \oldnewpage = \newpage
\let \oldvfill = \vfill
@@ -269,14 +282,6 @@
\unexpanded{\end{solutionreal}}%
}%
}
- \NewEnviron{proof}{%
- \xdef\lastproblem{%
- \unexpanded\expandafter{\lastproblem}%
- \unexpanded{\begin{proofreal}}%
- \unexpanded\expandafter{\BODY}%
- \unexpanded{\end{proofreal}}%
- }%
- }
\renewcommand{\newpage}{\xdef\lastproblem{\noexpand\oldnewpage\unexpanded\expandafter{\lastproblem}}}
\renewcommand{\vfill}{\xdef\lastproblem{\unexpanded\expandafter{\lastproblem\oldvfill}}}
\renewcommand{\smallskip}{\xdef\lastproblem{\unexpanded\expandafter{\lastproblem\oldsmallskip}}}
@@ -287,7 +292,6 @@
\else
\newenvironment{problem}{\problemreal}{\endproblemreal}
\newenvironment{solution}{\solutionreal}{\endsolutionreal}
- \newenvironment{proof}{\proofreal}{\endproofreal}
\let \newpagea = \newpage
\let \newpageb = \relax
\fi
@@ -296,7 +300,6 @@
\ifreverse
\renewenvironment{problem}{\problemreal}{\endproblemreal}%
\renewenvironment{solution}{\solutionreal}{\endsolutionreal}%
- \renewenvironment{proof}{\proofreal}{\endproofreal}%
\let \newpage = \oldnewpage
\let \vfill = \oldvfill
\let \smallskip = \oldsmallskip
@@ -310,6 +313,273 @@
\AtBeginDocument{%
\ifanswer\else
\excludecomment{solution}
- \excludecomment{proof}
\fi
}
+
+%% ---------------------------------------------------------------------------
+%% 答题栏命令 \answertable
+%% ---------------------------------------------------------------------------
+
+\gdef\answer@lines@temp{}%
+\newcommand{\answer@lines@add}[1]{%
+ \xdef\answer@lines@temp{\answer@lines@temp#1}%
+}
+
+\newrobustcmd{\answer@number@hided}[1]{小题} % 在 PDFLaTeX 中需要保护中文
+\newrobustcmd{\answer@cell@strut}[1]{\parbox[c][#1][c]{2em}{\hbox{答案}}}
+
+\newcounter{answer@col}
+\newcounter{answer@row}
+\newcounter{answer@total}
+
+\newcommand{\answer@lines}[3]{%
+ % #1 答题栏各栏指定高度
+ % #2 答题栏总共答案个数
+ % #3 答题栏每行答案个数
+ \setcounter{answer@row}{(#2-1)/#3+1}% 除法向下取整,改为向上取整
+ \begingroup
+ \let\hline=\relax \let\\=\relax % 禁止展开
+ \gdef\answer@lines@temp{}%
+ \setcounter{answer@total}{1}%
+ \whileboolexpr{
+ test{\ifnumgreater{\value{answer@row}}{0}}
+ }{%
+ \addtocounter{answer@row}{-1}%
+ \answer@lines@add{\answer@number@hided}%
+ \setcounter{answer@col}{1}%
+ \unlessboolexpr{%
+ test{\ifnumgreater{\value{answer@col}}{#3}}%
+ }{%
+ \answer@lines@add{&}%
+ \ifnumgreater{\value{answer@total}}{#2}{}{%
+ \answer@lines@add{\arabic{answer@total}}%
+ }%
+ \stepcounter{answer@col}%
+ \stepcounter{answer@total}%
+ }%
+ \answer@lines@add{\\ \hline \answer@cell@strut{#1}}%
+ \setcounter{answer@col}{1}%
+ \unlessboolexpr{
+ test{\ifnumgreater{\value{answer@col}}{#3}}
+ }{%
+ \answer@lines@add{&}%
+ \stepcounter{answer@col}%
+ }%
+ \answer@lines@add{\\ \hline}%
+ }%
+ \endgroup
+ \answer@lines@temp
+}
+
+\newcommand{\answertable}[3][1em]{%
+ 答题须知:本题答案必须写在如下表格中,否则不给分.\par
+ \begin{tabu}{|c|*{#3}{X[c]|}}
+ \hline
+ \answer@lines{#1}{#2}{#3}
+ \end{tabu}%
+ \par\vspace{0.8em}%
+}
+
+%% ---------------------------------------------------------------------------
+%% 答案切换命令 \answer
+%% 填空命令 \fillin 和 \fillout
+%% 选择命令 \pickin 和 \pickout
+%% 四个选项排版环境 abcd,根据四个选项的长度自动排成一行、两行或四行
+%% ---------------------------------------------------------------------------
+
+\newcommand{\answer}[1]{\ifanswer#1\else\phantom{#1}\fi}
+
+\newcommand{\ulinefill}[1]{\xleaders\hbox{\underline{\vphantom{#1}\kern1pt}}\hfill\kern0pt}
+\newcommand{\fillout}[1]{\allowbreak\hbox{}\nobreak\ulinefill{#1}\underline{\color{blue}\answer{#1}}\ulinefill{#1}}
+\newcommand{\fillin}[1]{\underline{\hspace{1em}\color{blue}\answer{#1}\hspace{1em}}}
+
+\newcommand{\cdotfill}{\leavevmode\xleaders\hbox to 0.5em{\hss$\cdot$\hss}\hfill\kern0pt\relax}
+\newcommand{\pickout}[1]{\unskip\nobreak\cdotfill(\makebox[1.5em]{\color{blue}\answer{#1}})}
+\newcommand{\pickin}[1]{\unskip\nobreak\hspace{0.3em}(\makebox[1.5em]{\color{blue}\answer{#1}})\hspace{0.3em}\ignorespaces}
+
+\newlength{\my@item@len}
+\newcommand\my@item@temp{%
+ \unskip\cr\stepcounter{choice}(\Alph{choice})\ %
+}
+\newcommand\my@item@box{%
+ \hfill\egroup\hfill\hbox to \my@item@len\bgroup
+ \stepcounter{choice}(\Alph{choice})\ \ignorespaces
+}
+\newcommand\my@item@par{%
+ \par\stepcounter{choice}(\Alph{choice})\ \ignorespaces
+}
+\NewEnviron{abcd}{
+ \unskip
+ \setlength{\parindent}{0pt}%
+ \setlength{\parskip}{0pt}%
+ \setcounter{choice}{0}%
+ \let\item=\my@item@temp
+ \settowidth{\my@item@len}{\vbox{\halign{##\hfil\cr\BODY\crcr}}}%
+ \setcounter{choice}{0}%
+ \ifdim\my@item@len>0.486\linewidth
+ \setlength{\my@item@len}{\linewidth}%
+ \let\item=\my@item@par
+ \BODY\par
+ \else
+ \ifdim\my@item@len>.243\linewidth
+ \setlength{\my@item@len}{0.5\linewidth}%
+ \else
+ \setlength{\my@item@len}{0.25\linewidth}%
+ \fi
+ \let\item=\my@item@box
+ \par\bgroup\BODY\hfill\egroup\par
+ \fi
+}
+
+%\newcommand{\my@item}{\ifnum\value{choice}=0\par\fi\stepcounter{choice}}
+%\newcommand{\fullitem}[1]{\my@item\parbox{\linewidth}{(\Alph{choice})\ #1\rule[-0.5em]{0pt}{0.5em}}\hfill\ignorespaces}
+%\newcommand{\halfitem}[2][0.5]{\my@item\makebox[#1\linewidth][l]{(\Alph{choice})\ #2}\hfill\ignorespaces}
+%\newcommand{\quaritem}[2][0.25]{\my@item\makebox[#1\linewidth][l]{(\Alph{choice})\ #2}\hfill\ignorespaces}
+
+%% ---------------------------------------------------------------------------
+%% 解答题步骤命令 \step
+%% ---------------------------------------------------------------------------
+
+\newcommand{\step}{%
+ \stepcounter{step}%
+ \makebox[2em][l]{\ttfamily(\arabic{step})}%
+}
+
+%% ---------------------------------------------------------------------------
+%% 评分命令 \score
+%% ---------------------------------------------------------------------------
+
+\PassOptionsToPackage{tbtags}{amsmath}
+\RequirePackage{amsmath}
+
+\newcommand{\myscore}[1]{\textcolor{blue}{#1\kern0.2em 分}}
+
+\newcommand{\scoretext}[1]{\cdotfill\myscore{#1}\par\noindent\ignorespaces}
+\newcommand{\scoreeqno}[1]{\eqno{\cdots\cdots\text{\myscore{#1}}}}
+\newcommand{\scoretag}[1]{\tag*{$\cdots\cdots$\myscore{#1}}}
+
+\newrobustcmd{\score}[1]{%
+ \ifbool{mmode}{%
+ \ifdefstrequal{\tag}{\dft@tag}{\scoreeqno{#1}}{\scoretag{#1}}%
+ }{%
+ \scoretext{#1}%
+ }%
+}
+
+%% ---------------------------------------------------------------------------
+%% 载入个人定制文件 jnuexam.cfg
+%% 中文字体切换选项 sourcehan
+%% ---------------------------------------------------------------------------
+
+\InputIfFileExists{jnuexam.cfg}{}{}
+
+\newcommand{\my@set@sourcehan}{
+ \setCJKmainfont[BoldFont=Source Han Sans SC]{Source Han Serif SC}
+ \setCJKsansfont{Source Han Sans SC}
+ % 用中文字体名时 LuaTeX 找不到该字体,XeTeX 正常
+ %\setCJKmainfont[BoldFont=思源黑体]{思源宋体}
+ %\setCJKsansfont{思源黑体}
+}
+
+\ifbool{sourcehan}{
+ \RequirePackage{iftex}
+ % https://sourceforge.net/p/xetex/code/ci/master/tree/source/texk/web2c/xetexdir/NEWS
+ \ifbool{XeTeX}{ % TeXLive 2015
+ \ifdimless{\the\XeTeXversion\XeTeXrevision pt}{0.99992pt}{}{\my@set@sourcehan}
+ }{}
+ \ifbool{LuaTeX}{\my@set@sourcehan}{}
+}{}
+
+%% ---------------------------------------------------------------------------
+%% 试卷题库选项 collection
+%% ---------------------------------------------------------------------------
+
+\ifcollection
+ \RequirePackage{hyperref}
+ \hypersetup{
+ pdfstartview={FitH},
+ bookmarksnumbered=true,
+ unicode=true,
+ hidelinks=true
+ %colorlinks=true,
+ %linkcolor=black
+ }
+ \appto{\endproblem}{\medskip}
+ \appto{\endsolution}{\medskip}
+ \preto{\problem}{\ifnum\value{problem}=9 \setcounter{problem}{-1}\fi}
+ \pagestyle{plain}
+\fi
+
+%% ---------------------------------------------------------------------------
+%% 载入常用宏包,定义常用命令
+%% ---------------------------------------------------------------------------
+
+\AtBeginDocument{
+ \setlength{\abovedisplayskip}{4pt minus 2pt}
+ \setlength{\belowdisplayskip}{4pt minus 2pt}
+ \setlength{\abovedisplayshortskip}{2pt}
+ \setlength{\belowdisplayshortskip}{2pt}
+}
+
+\setlength\arraycolsep{4pt}
+
+\RequirePackage{CJKfntef}
+\RequirePackage{multirow}
+\RequirePackage{diagbox}
+
+\RequirePackage{relsize}
+\newcommand{\Int}{\mathop{\mathlarger{\int}}}
+
+\newcommand{\e}{\mathrm{e}}
+\newcommand{\limit}{\lim\limits}
+\newcommand{\R}{\mathbb{R}}
+
+\DeclareMathOperator{\Corr}{\rho}
+\DeclareMathOperator{\Cov}{Cov}
+\DeclareMathOperator{\grad}{grad}
+\DeclareMathOperator{\Prj}{Prj}
+\DeclareMathOperator{\Var}{Var}
+
+\newcommand{\diff}{\mathop{}\!\mathrm{d}}
+\newcommand{\dx}{\diff x}
+\newcommand{\dy}{\diff y}
+\def\dz{\diff z} % 不确定命令是否已经定义
+\newcommand{\du}{\diff u}
+\newcommand{\dv}{\diff v}
+\newcommand{\dr}{\diff r}
+\newcommand{\ds}{\diff s}
+\newcommand{\dt}{\diff t}
+\newcommand{\dS}{\diff S}
+% 有些宏包比如 hyperref 会修改 \d 的定义,所以放在 document 开始处
+% 利用 etoolbox 将 \d 定义为健壮命令,以避免在 align 等环境中错误地展开
+\AtBeginDocument{%
+ \let\oldd=\d
+ \renewrobustcmd{\d}{\ifbool{mmode}{\diff}{\oldd}}%
+}
+
+\newcommand{\va}{\vec{a\vphantom{b}}}
+\newcommand{\vb}{\vec{b}}
+\newcommand{\vc}{\vec{c\vphantom{b}}}
+\newcommand{\vd}{\vec{d}}
+\newcommand{\ve}{\vec{e}}
+\newcommand{\vi}{\vec{i}}
+\newcommand{\vj}{\vec{j}}
+\newcommand{\vk}{\vec{k}}
+\newcommand{\vn}{\vec{n}}
+\newcommand{\vs}{\vec{s}}
+\newcommand{\vv}{\vec{v}}
+
+\let\ov=\overrightarrow
+
+\let\le=\leqslant
+\let\ge=\geqslant
+
+\let\lb=\{
+\let\rb=\}
+
+\def\T{\mathrm{T}\kern-.5pt}
+
+\newrobustcmd{\wfrac}[3][2pt]{%
+ {\begingroup\hspace{#1}#2\hspace{#1}\endgroup\over\hspace{#1}#3\hspace{#1}}%
+}
+