当前位置:网站首页>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{ ~~~~~~~}
(*)
边栏推荐
- If MySQL calculates the current month change / current month increase / year-on-year change / year-on-year increase?
- Hack The Box - Web Requests Module详细讲解中文教程
- STL常用模板库
- 一招教你轻松看懂波特图
- Real scientific weight loss
- Redis official visualization tool, with high appearance value and powerful functions!
- CANoe-XML在Test Modules中的应用
- flex布局原理及常见的父项元素
- 芯片的翻新和造假,人被坑麻了
- mysql如果计算本月变动/本月增幅/同比变动/同比增幅?
猜你喜欢

TZC 1283: simple sorting - function method

520送什么?DIY一个高颜值RGB时钟,女生看了都想要

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

中文文本纠错任务简介

no networks found in /etc/cni/net.d

SAP report development steps

Polymer physics test question bank

TZC 1283: simple sort - select sort

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 - Introduction to networking module detailed Chinese tutorial
随机推荐
轻量级单片机命令行交互项目,全部开源
TZC 1283: simple sort - Comparative sort
一招教你轻松看懂波特图
Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
Hack the box - Introduction to networking module detailed Chinese tutorial
Qt编写物联网管理平台47-通用数据库设置
Go exceed API source code reading (VI) -- deletesheet (sheet string)
ES Cluster in Red status: what about write & delete operations?
mysql如果计算本月变动/本月增幅/同比变动/同比增幅?
Lesson 2 getting to know slam for the first time
Lightweight MCU command line interaction project, all open source
Thread三种实现方式 和 Handler的用法
[personal summary] end of July 24, 2022
高手是怎样炼成的?
no networks found in /etc/cni/net.d
The first positive number missing in question 41 of C language. Two methods, preprocessing, fast sorting and in situ hashing
Reason for pilot importerror: cannot import name 'pilot_ Version 'from' PIL ', how to install pilot < 7.0.0
攻防世界-FlatScience
TZC 1283: simple sorting - function method
Three graduates, three years of experience in embedded software