-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyles.sty
44 lines (37 loc) · 1.25 KB
/
styles.sty
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
% styles.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{styles}[2023/05/24 Custom LaTeX environment for adding questions and answers of MCQ type]
\RequirePackage{graphicx} % For including images
\RequirePackage{xparse} % For defining commands with optional arguments
% Define a counter for the question numbering
\newcounter{questionnumber}[section] % Reset counter at each section
\renewcommand{\thequestionnumber}{\arabic{questionnumber}}
\newenvironment{entry}{%
\par\noindent\ignorespaces%
\stepcounter{questionnumber}% Increment the question number
\begin{minipage}{\textwidth}%
}{%
\end{minipage}%
\par\bigskip%
}
\newcommand{\question}[1]{%
\par\bigskip%
\textbf{\thequestionnumber.} #1\par%
}
% Define the \option command with optional image, counter, and option text arguments
\NewDocumentCommand{\option}{o m m}{%
\par\medskip%
\IfNoValueTF{#1}{% Check if the image argument is provided
\textbf{#2.} #3%
}{% No image provided
\textbf{#2.} \includegraphics[width=0.4\textwidth]{#1} #3%
}%\par
}
% Define a command to generate answer options
\newcommand{\options}[1]{%
\renewcommand{\arraystretch}{1.5}% Adjust vertical spacing in the table
\begin{tabular}{@{}lp{0.45\textwidth}lp{0.45\textwidth}@{}}%
#1%
\end{tabular}%
\par%
}