前言
先介绍一下 uestc-course ,最近在 GitHub 上建立了一个资源分享仓库,目标是为电子科技大学的学生免费提供各种课程和考研的复习资料。大家感兴趣的可以给个 Star,或者贡献一些自己的资源。
在收集资料的时候,我发现一些历年试题是学生用手机拍摄的,显示效果很不好,占用空间也比较大,于是我就想把这些试题重新转制为 PDF,因为平时也在用 LaTeX,就试了一下,感觉还可以,发在这里供大家参考。可以点击 样例 看看效果。
完整的文档请阅读 这篇指南 [1](全英文132页,我还是看了大半,读者如果有定制化的需求可以参考参考)。
LaTeX 代码
PS: 编译器应使用 XeLaTeX 。
一步一步来:
\documentclass[answer]{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 资本主义
\choice 无政府主义
\correctchoice 新时代中国特色社会主义
\choice 社会主义
\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[answer]{exam}
中的[answer]
参数控制着答案的显示与否。
答案写在\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}
\question[10] 你擅长\fillin。
\begin{oneparchoices}
\correctchoice 唱
\correctchoice 跳
\correctchoice RAP
\choice 篮球
\end{oneparchoices}
\question[80] 只有毫不动摇地坚持\fillin,才能实现中华民族的伟大复兴。
\begin{choices}
\choice 资本主义
\choice 无政府主义
\correctchoice 新时代中国特色社会主义
\choice 社会主义
\end{choices}
\question[10] 什么是中国特色社会主义?
\begin{solution}
中国特色社会主义是党和人民长期奋斗、创造、积累的根本成就。经过长期努力,中国特色社会主义进入了新时代。这是我国发展新的历史方位。在新的历史方位上实现新时代党的历史使命,就要高举中国特色社会主义伟大旗帜,更加自觉地增强中国特色社会主义道路自信、理论自信、制度自信、文化自信,为决胜全面建成小康社会、夺取新时代中国特色社会主义伟大胜利、实现中华民族伟大复兴的中国梦不懈奋斗。
\end{solution}
\question[10] \fillin[Xovee][2cm]是世界上最帅的人。
\end{questions}
\end{document}
Reference
- P. Hirschhorn. (2017). Using the exam document class. Retrieved from http://www-math.mit.edu/~psh/exam/examdoc.pdf
- 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