使用 LaTeX 制作考试试卷

前言

先介绍一下 uestc-course ,最近在 GitHub 上建立了一个资源分享仓库,目标是为电子科技大学的学生免费提供各种课程和考研的复习资料。大家感兴趣的可以给个 Star,或者贡献一些自己的资源。

在收集资料的时候,我发现一些历年试题是学生用手机拍摄的,显示效果很不好,占用空间也比较大,于是我就想把这些试题重新转制为 PDF,因为平时也在用 LaTeX,就试了一下,感觉还可以,发在这里供大家参考。可以点击 样例 看看效果。

完整的文档请阅读 这篇指南 [1](全英文132页,我还是看了大半,读者如果有定制化的需求可以参考参考)。

LaTeX 代码

PS: 编译器应使用 XeLaTeX

一步一步来:

\documentclass[answers]{exam}

\documentclass{exam}

如果使用了[answer]参数,那么最终编译出来的 PDF 中会显示试题的答案,如果没有,则会自动把答案隐藏。后面介绍\begin{solution}的时候会用到。

\usepackage{xeCJK} 			% 写中文要用到
\usepackage{zhnumber} 		% 可以把题号变为中文
\usepackage{graphicx} 		% 插入图片
\usepackage{hyperref} 		% 插入链接
\usepackage{amsmath} 		% 数学符号
\usepackage{booktabs} 		% 表格样式

上面是一些常用的包,不多说了。

定义页眉和页脚

\pagestyle{headandfoot}
\firstpageheadrule
\firstpageheader{电子科技大学}{随机过程与排队论}{期末考试}
\runningheader{电子科技大学}
{随机过程与排队论}
{期末考试}
\runningheadrule
\firstpagefooter{}{第\thepage\ 页(共\numpages 页)}{}
\runningfooter{}{第\thepage\ 页(共\numpages 页)}{}

分别定义第一页和其余页的页眉页脚,效果如下:

页眉
页眉
页脚
页脚
然后定义题的分数的样式:

\pointname{ 分}
\pointformat{(\thepoints)}

显示效果为(10 分),其他类型的样式读者可以按需定义,例如

\pointname{ points}
\pointformat{(\thepoints)}

的显示效果为(10 points)

解、答

\renewcommand{\solutiontitle}{\noindent\textbf{答:}}

\renewcommand{\solutiontitle}{\noindent\textbf{解:}\par\noindent}

显示答案的时候,显示或者,或者你想定义的任何字符。

题号

\renewcommand{\thequestion}{\arabic{question}}
\renewcommand{\questionlabel}{\thequestion .}
\renewcommand{\thepartno}{\arabic{partno}}
\renewcommand{\partlabel}{(\thepartno)}
\renewcommand{\thesubpart}{}
\renewcommand{\subpartlabel}{\thesubpart.}
\renewcommand{\thesubsubpart}{}
\renewcommand{\subsubpartlabel}{\thesubsubpart)}
\renewcommand{\thechoice}
\renewcommand{\choicelabel}{\thechoice.}
%\arabic \alph \Alph \roman \Roman \greeknum

定义多级题号,例如一、(1)这些。

然后就可以开始文档了:

\begin{document}

...

\end{document}

可以写一些考试科目、考试时间、注意事项一类的话在前面。

题目

\begin{questions}

\question[10] 为什么天是蓝的?

\question[10] LaTeX 是最好的语言吗?如果不是,请说明理由。

\end{questions}

效果如下:
题目

二级题目

\question[20] 假如$x+y=3, x-y=1$,试求:
\begin{parts}
\part $x$
\part $y$
\end{parts}

效果如下:
二级题目

选择题

\question[10] 你擅长\fillin。

\begin{oneparchoices}
\correctchoice 唱
\correctchoice 跳
\correctchoice RAP
\choice 篮球
\end{oneparchoices}

\question[90] 只有\fillin,才能。

\begin{choices}
\choice 1主义
\choice 2主义
\correctchoice 3主义
\choice 4主义
\end{choices}

效果如下:
选择题

填空题

\question[10] \fillin[Xovee][2cm]是世界上最帅的人。

留空

\vspace{12cm}
% 直接留空

%%%
\vspace{\stretch{1}}
% 在页面给给多个问题平均留空,例如:
\question[10] Example One
\vspace{\stretch{1}}
\question[10] Example Two
\vspace{\stretch{1}}
\newpage
%%%

\newpage
% 换下一页

答案

\documentclass[answers]{exam}中的[answers]参数控制着答案的显示与否。
答案写在\begin{solution} \end{solution}环境里:

\question[10] 1+1=?
\begin{solution}
2
\end{solution}

效果如下:
答案

密封线(2019年6月20日更新)

看到很多人在搜如何用 LaTeX 制作试卷的密封线,读者可以参考这个页面 [2],里面介绍了三种在 LaTeX 中添加垂直线的方法。

模板

\documentclass[addpoints,answers]{exam}
% \documentclass[addpoints]{exam}

\usepackage{xeCJK}
\usepackage{zhnumber}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{booktabs}

\pagestyle{headandfoot}
\firstpageheadrule
\firstpageheader{电子科技大学}{}{期末考试}
\runningheader{电子科技大学}
{}
{期末考试}
\runningheadrule
\firstpagefooter{}{第\thepage\ 页(共\numpages 页)}{}
\runningfooter{}{第\thepage\ 页(共\numpages 页)}{}

% no box for solutions
% \unframedsolutions

\pointname{ 分}
\pointformat{(\thepoints)}

\totalformat{共\totalpoints 分}

\setlength\linefillheight{.5in}

\renewcommand{\solutiontitle}{\noindent\textbf{答:}}
% \renewcommand{\solutiontitle}{\noindent\textbf{解:}\par\noindent}

\renewcommand{\thequestion}{\zhnum{question}}
\renewcommand{\questionlabel}{\thequestion .}
\renewcommand{\thepartno}{\arabic{partno}}
\renewcommand{\partlabel}{\thepartno .}
%\renewcommand{\thesubpart}{}
%\renewcommand{\subpartlabel}{\thesubpart.}
%\renewcommand{\thesubsubpart}{}
%\renewcommand{\subsubpartlabel}{\thesubsubpart)}
%\renewcommand{\thechoice}
%\renewcommand{\choicelabel}{\thechoice.}
%\arabic \alph \Alph \roman \Roman \greeknum

\begin{document}

\begin{questions}

\question[10] 你擅长\fillin。

\begin{oneparchoices}
\correctchoice 唱
\correctchoice 跳
\correctchoice RAP
\choice 篮球
\end{oneparchoices}

\question[80] 只有\fillin,才能。

\begin{choices}
\choice 1主义
\choice 2主义
\correctchoice 3主义
\choice 4主义
\end{choices}

\question[10] What?

\begin{solution}
自强
\end{solution}

\question[10] \fillin[Xovee][2cm]是世界上最帅的人。

\end{questions}

\end{document}

Reference

  1. P. Hirschhorn. (2017). Using the exam document class. Retrieved from http://www-math.mit.edu/~psh/exam/examdoc.pdf
  2. LaTeX: How to make a fullpage vertical rule on every page? (June 20, 2019). Retrieved from https://stackoverflow.com/questions/2986240/latex-how-to-make-a-fullpage-vertical-rule-on-every-page
  • 25
    点赞
  • 117
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 16
    评论
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Xovee

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值