当前位置:网站首页>Use latex to typeset multiple-choice test paper
Use latex to typeset multiple-choice test paper
2022-07-26 05:34:00 【_ Jesse_】
Food Guide : Use python The language implements latex Pure text Automated choreography
One 、 Requirements describe
Work reason , You need to make a sheet containing 100 Multichannel selection Choose the test paper .
For beautiful typesetting , I got a job LaTeX Multiple choice question template ,
It's too troublesome to manually input each line , Then we found the corresponding Automation module
The most embarrassing thing happened , I found that the editor has its own replacement function ,
And support regular expressions
Two 、 Solution
1. Content processing
(1) Text answer digging
Copy several pages of the questionnaire txt In the text file , In order to dig out these correct answers , Replace with regular expressions directly

2. Typesetting processing
(1) The template is local miktex The compiler in
In order to achieve this step , There are three main points to pay attention to .
- install miktex Choose to install... For all users
( Make sure the software starts , to update , The old version has some deadly bug) - Use xelatex compile
( In order to compile some macro packages normally ) - Use ctex In the macro package ctexart Document class
( Don't display Chinese correctly , Make sure it is installed ctex Macro package , Installation can refer to The lack of lastpage Macro package processing method )

(2) Source code analysis of templates
3. Text and latex Interaction
Think of each topic as a basic unit , Function encapsulation of this basic unit
And then call 100 The second function can realize the writing of the whole manuscript .
3、 ... and 、 Encountered bug
1. LaTeX Problems arise
take LaTeX Multiple choice question template Copied to the TeXworks In the process , The following error has been reported .
Duplicate installation , Remember to choose for all users
The use of wildcards

By reference This blog The method is as follows :
I solved this problem perfectly
Environmental problems

[ resolved ] LaTeX Medium enumerate The environment appears overfull box The situation of
Four 、 Exotic curiosity-a solution looking
##( One ) Copied to the WPS Handle (word It's the same , Support genuine domestic )
##( Two ) Use word Replacement sequence of
Use wildcards to replace
1. Question number replacement ( Replace two digits first , Replace one digit : As for why not replace it all at once , Because I won't )
First look at the content of wildcards :^# For any number , Don't forget the back “、”, Otherwise, it may match the number in the stem
^#^#、
I want to change the sequence directly to latex Medium item command , because \item The command can automatically generate a sequence , Here is latex Source code , In contrast , It's easy to understand , Replacement target 
But the sad thing is that direct replacement will report an error ,

So I improved 
Here is my fifth replacement ,} must Because if you import latex in ,D You will find that there is no alternative slogan after choosing , Do you want to add one by one manually , Later, I found that I could change the serial number , Just manually Delete the first , to The last one is added with brackets That's it .^p Line break , It's OK to , Or add a few more as you need . It's for my latex The source code is more readable .(latex Source code inside , Segmentation equals newline , It should be because the compiler has to eat an empty line to know the end of a line )^092 I won't say why ,~ It is used as a space , stay latex in , Otherwise \item There is no gap with the following Chinese , The command cannot be recognized
^#^#、
}^p^092item~
##( 3、 ... and ) The answer is hollowed out
Use it directly
( )
Make a selection parenthesis
Replace with 
~^092underline{
~~~~~~~~}
##( Four )A The option is replaced by the command
This order determines that I line up the multiple-choice questions , Or two lines , Or four elements .
Because most of the options are short , For the purpose of reducing manual modification , Select single line command ,
Insert picture description here
Don't compile when you finish modifying , Definitely , There should be some options only ABC No, D, I refer to the single line function written to compare dishes , You can't adapt to the three options .
^#^#、
}^p^092item~
##( 5、 ... and )B,CD Replace the selection with the corresponding brackets }{
^$ Represents any letter
This is the most embarrassing thing

Other references
AttributeError: module ‘scipy.sparse’ has no attribute ‘coo_array’
attributeError: modular ’scipy.sparse’ There is no attribute ’coo_array’
Two additional steps
The smallest workable solution
\documentclass{
ctexart}%
\usepackage{
lineno,hyperref}
\usepackage{
colortbl}
\usepackage{
amsmath,amssymb,amsfonts}
\usepackage{
algorithmic}
\usepackage{
graphicx}
\usepackage{
float}
\usepackage[T1]{
fontenc}%
\usepackage[utf8]{
inputenc}%
\usepackage{
lmodern}%
\usepackage{
textcomp}%
\usepackage{
ctex}
\usepackage{
enumerate}
\usepackage{
geometry}
\geometry{
a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm}
\newcommand{
\twolines}[4]{
\\\begin{
tabular}{
*{
2}{
@{
}p{
8cm}}}(A)~#1 & (B)~#2\end{tabular}\\
\begin{
tabular}{
*{
2}{
@{
}p{
8cm}}}(C)~#3 &(D)~#4\end{tabular}} % Two lines, four
\newcommand{
\twolinesT}[3]{
\\\begin{
tabular}{
*{
2}{
@{
}p{
8cm}}}(A)~#1 & (B)~#2\end{tabular}\\
\begin{
tabular}{
*{
2}{
@{
}p{
8cm}}}(C)~#3\end{tabular}} % Two lines, four
\newcommand{
\fourlines}[4]{
\\(A)~#1 \\ (B)~#2 \\ (C)~#3 \\ (D)~#4} %
\newcommand{
\fourlinesT}[3]{
\\(A)~#1 \\ (B)~#2 \\ (C)~#3} % 3 Every line 1 individual
%===========================================
\begin{
document}
\par
\section{
Multiple choice questions ( common 90 topic )}
\begin{
enumerate}
\item When food producers and operators purchase food raw materials , In addition to the need to check the supplier's license , Also check ~\underline{
~~~~~~~~}
\twolines{
Product qualification certificate }{
emdical certificate }{
Training certificate }{
Power of attorney of legal person }
\end{
enumerate}
\section{
Multiple choice questions ( common 10 topic )}
\begin{
enumerate}
\item~ Imported food additives should have ~\underline{
~~~~~~~~}.
\twolines{
Export country logo }{
Chinese label }{
Chinese instructions }{
English description }
\item~ In the investigation of food safety accidents , No unit or individual shall be responsible for food safety accidents ~\underline{
~~~~~~~~}, Do not destroy relevant evidence .
\twolines{
hide }{
Lie about }{
Report to the media }{
Delayed reporting }
\end{
enumerate}
\end{
document}
Second parts : Use the replacement function
It is also possible to excavate directly in this way

My brackets are full angle , But some cases , The number doesn't matter
……092underline{ ~~~~~~~}
(*)
边栏推荐
- 我又发现了超赞的软硬件项目,全部开源
- Mongodb tutorial Chapter 08 comparison operators
- Use playbook in ansible
- 中文文本纠错任务简介
- Chinese character style transfer --- learn the conversion and generation of one to many programmed Chinese characters through generation confrontation network
- 517. Super washing machine
- Ansible中常用的模块
- 动态内存管理及柔性数组
- no networks found in /etc/cni/net.d
- Shell process control (emphasis), if judgment, case statement, let usage, for ((initial value; loop control condition; variable change)) and for variable in value 1 value 2 value 3..., while loop
猜你喜欢

Hack The Box - Web Requests Module详细讲解中文教程

OD-Paper【1】:Rich feature hierarchies for accurate object detection and semantic segmentation

kubernetes install completed

高分子物理知识点

Hack The Box -SQL Injection Fundamentals Module详细讲解中文教程

High frequency electronic circuit review examination questions and answers

517. Super washing machine

SSTI payload and various bypass methods

Hack the box -sql injection fundamentals module detailed Chinese tutorial

DOM operation -- operation node
随机推荐
中文文本纠错任务简介
《MongoDB入门教程》第08篇 比较运算符
Efficient, reliable and safe open source solution for serial communication
Go exceed API source code reading (VI) -- deletesheet (sheet string)
STL常用模板库
If MySQL calculates the current month change / current month increase / year-on-year change / year-on-year increase?
Application and value of IVR in VoIP telephone system
517. Super washing machine
Code audit CMS
The first positive number missing in question 41 of C language. Two methods, preprocessing, fast sorting and in situ hashing
学生如何申请免费IDEA
OD-Paper【1】:Rich feature hierarchies for accurate object detection and semantic segmentation
ALV report flow diagram
LNMP架构
Reason for pilot importerror: cannot import name 'pilot_ Version 'from' PIL ', how to install pilot < 7.0.0
87. Disturb string
How to handle aggregate collection code
SAP report development steps
TZC 1283: simple sort Bubble Sort
调试利器!一款轻量级日志库 log.c