-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctsol.cls
102 lines (90 loc) · 2.28 KB
/
ctsol.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ctsol}[2022/05/03 v1.1 Contest Solution Template document class]
\LoadClass[lang=cn,color=blue]{elegantbook}
\RequirePackage{tabularx}
\RequirePackage{booktabs}
\RequirePackage{sourcecodepro}
\renewcommand{\thechapter}{\Alph{chapter}.}
\renewcommand{\chaptername}{\thechapter}
\renewcommand{\xchaptertitle}{\chaptername}
\makeatletter
\renewcommand{\maketitle}
{
\clearpage
\thispagestyle{empty}
\begin{center}
{
\LARGE
\textbf{\@title}
\par
}
\vspace{0.5cm}
\@date
\end{center}
}
\newcommand{\labeltext}[2]
{
\@bsphack
\csname phantomsection \endcsname
\def\@currentlabel{#1}{\label{#2}}
\@esphack
}
\makeatother
\newcounter{solamo}
\newcommand{\addsolution}[3]
{
\stepcounter{solamo}
\labeltext{#1}{pro:\thesolamo}
\labeltext{#2}{aut:\thesolamo}
\labeltext{#3}{ans:\thesolamo}
}
\newcounter{solcnt}
\newcommand{\makesolution}
{
\stepcounter{solcnt}
\ifnum \value{solcnt}>\value{solamo}
\PackageError{ctsol}
{
You don't have enough solutions, you only have \thesolamo solutions!
Check if you are using makesolution too many times
}
\fi
\chapter{\ref*{pro:\thesolcnt}}
}
\newcolumntype{M}{>{\centering\arraybackslash}X}
\newcommand{\solutiontab}
{
\begin{center}
\begin{tabularx}{\textwidth}{MMMM}
\toprule
\textbf{题目编号} & \textbf{题目名称} & \textbf{命题人} & \textbf{做法} \\
\midrule
\end{tabularx}
\newcounter{i}
\setcounter{i}{1}
\whiledo{\value{i}<\numexpr\value{solamo}+1\relax}
{
\begin{tabularx}{\textwidth}{MMMM}
\Alph{i} & \ref*{pro:\thei} & \ref*{aut:\thei} & \ref*{ans:\thei} \\
\ifnum \value{i}=\value{solamo}
\bottomrule
\fi
\end{tabularx}
\stepcounter{i}
}
\end{center}
}
\newcommand{\stdpath}{../std/}
\newcommand{\std}[1]
{
\lstinputlisting
[
language=c++,
frame=none,
numbers=left,
breaklines=true,
xleftmargin=.25in,
xrightmargin=.25in,
basicstyle=\ttfamily\scriptsize
]{\stdpath #1.cpp}
}