LaTeX Templates Câu hỏi bài tập 2
Link xem mã nguồn trên Overleaf: https://www.overleaf.com/read/qgtjpgfxzfsc
Tệp cauhoi.tex
\setcounter{ex}{0}
\begin{ex}%[Cau 1]
Gọi $A$ và $B$ là hai điểm cực trị của hàm số $f(x)=x^3-3x^2+m$ với $m\neq0$. Tìm tất cả giá trị của tham số $m$ để trong tâm của tam giác $OAB$ thuộc đường thẳng $3x+3y-8=0$.
\choice
{\True $m=5$}
{$m=2$}
{$m=6$}
{$m=4$}
\loigiai{
{\bf Cách 1}
Ta có $f'(x)=3x^2-6x=0\iff\hoac{x=0&\implies y=2\\ x=2&\implies y=m-4}\implies A(0;2),~B(2;m-4)$
Gọi $G$ là trọng tâm $\triangle OAB$, khi đó ta có $G\left(\frac23;\frac{2(m-2)}3\right)$
$G$ thuộc đường thẳng $3x+3y-8=0\iff 2+2(m-2)-8=0\iff m=5$
\\ {\bf Cách 2}
Gọi $M(x_o;y_o)$ là trung điểm của $AB$.
Khi đó $f''(x_o)=0\iff 6x_o-6=0\iff x_o=1\implies y_o=m-2\implies M(1;m-2)$
Gọi $G$ là trọng tâm $\triangle OAB$, khi đó ta có $\vec{OG}=\frac23\vec{OM}=\left(\frac23;\frac{2(m-2)}3\right)$
$G$ thuộc đường thẳng $3x+3y-8=0\iff 2+2(m-2)-8=0\iff m=5$
}
\end{ex}
\begin{ex}%[Cau 2]
Cho hàm số bậc ba $y=f(x)$ có đồ thị là đường cong trong hình bên.
\immini{ Điểm cực tiểu của đồ thị hàm số đã cho có toạ độ là
\choice[2]
{$(1; 3)$}
{$(3; 1)$}
{\True $(-1; -1)$}
{$(1; -1)$}
}{\begin{tikzpicture}[scale=.7]
\draw[-stealth] (-2.2,0) -- (2.5,0) node[below]{$x$};
\draw[-stealth] (0,-1.3) -- (0,3.5) node[left]{$y$};
\draw (0,0) node[below right]{\small $O$};
\draw[dashed] (-1,0)|-(0,-1)(1,0)|-(0,3);
\draw[thick,smooth] plot[domain=-2.04:2.05](\x,{-(\x)^3+3*(\x)+1});
\path(1,0)node[below,scale=.6]{$1$} (-1,0)node[above,scale=.6]{$-1$}
(0,-1)node[right,scale=.6]{$-1$} (0,3)node[left,scale=.6]{$3$};
\end{tikzpicture}}
\loigiai{
Điểm cực tiểu của đồ thị hàm số đã cho có toạ độ là $(-1;-1)$
}
\end{ex}
Tệp ex_test.sty
\ProvidesPackage{ex_test}[17/07/2019 for Ex_test version 2.4.5, Tran Anh Tuan]
\RequirePackage{ifthen}
\RequirePackage{fancyhdr}
\RequirePackage{multicol}
\RequirePackage{answers}
\RequirePackage{array}
\RequirePackage{multirow}
\RequirePackage{longtable}
\RequirePackage{fontawesome}
%\RequirePackage[utf8]{vietnam}
\RequirePackage{tikz}
\RequirePackage{ntheorem}
\RequirePackage{calc}
\RequirePackage{etoolbox}
\RequirePackage{probsoln}
\RequirePackage{picinpar}
%\RequirePackage{filecontents}
\RequirePackage {expl3,xparse,epic,cntformats,xtemplate,environ}
%Fix immini
\def\thindent{}
%Fix in đáp án trắc nghiệm cho các môi trường vd, bt,...
\newcommand{\fixshowans}[1]{
\foreach \xfixshowans in {#1} {%môi trường
\AtBeginEnvironment{\xfixshowans}{%
\setcounter{numTrueSol}{0}%
\def\dotEX{.}%
\setcounter{numChoice}{0}%
}
\AtEndEnvironment{\xfixshowans}{%
\ifnum\the\value{numTrue}=1
\scantokens{\begin{EXsol}A\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=2
\scantokens{\begin{EXsol}B\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=3
\scantokens{\begin{EXsol}C\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=4
\scantokens{\begin{EXsol}D\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=5
\scantokens{\begin{EXsol}E\end{EXsol}}
\fi
\setcounter{numTrue}{0}
\setcounter{numTrueSol}{0}
\labelex
}
}}
%Ghi đáp số bên phải câu hỏi
\newcommand{\dapso}[1]{\hspace{\fill}\mbox{}\linebreak[0]\hspace*{\fill}\textbf{ĐS:} #1}
\newcommand{\exitdapso}{%
\renewcommand{\dapso}[1]{%
\unskip%
}%
}%
%Gán tên và đánh số hình vẽ trong môi trường \immini
\def\IMname{}
\def\IMlabel{}
\newcommand{\imlabel}[2]{%
\def\IMname{\refstepcounter{figure}\label{#2}}
\def\IMlabel{Hình \thefigure: #1}
}
%hide choice
\newcommand{\hidechoice}[1]{
\AtBeginEnvironment{#1}{%
\renewcommand{\choice}[4]{}%
}
}
%hideenviron
\newcommand{\hideenviron}[1]{
\RenewEnviron{#1}{}
}
%dotlineEX equal number line
\newdimen\linepar
\newlength{\paroutindent}
\newlength{\lineheight}
\setlength{\lineheight}{\heightof{A}}
\newcommand{\dotlinefull}[1]{
\renewcommand{\FalseEX}{\stepcounter{dapan}{\textbf{\Alph{dapan}}}.}
\renewcommand{\TrueEX}{\stepcounter{dapan}{\textbf{\Alph{dapan}}}.}
\def\True{\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
\AtBeginEnvironment{#1}{%
\renewcommand{\loigiai}[1]{%%
\setlength{\paroutindent}{\expandafter\parindent}
\setbox0=\vbox{\hbox{
\noindent\begin{minipage}{\linewidth}
\setlength{\parindent}{\paroutindent}##1\end{minipage}
}}
\linepar=\ht0
\pgfmathparse{round((\linepar-\fboxsep)/(\lineheight))}
\par\noindent\textbf{\loigiaiEX }
\dotlineEX{\pgfmathresult}
}%%
}%
}
%Ẩn hiện công thức tự động
\newlength\wsh
\newlength\hsh
\newlength\dsh
\def\dotfillans#1{\cleaders\hbox to #1{.}\hfill}
\newcommand\dotlinesh[2][.5em]{\leavevmode\hbox to #2{\dotfillans{#1}\hfil}}
\newcommand{\sh}[1]{%
\settowidth\wsh{#1}%
\settoheight\hsh{#1}%
\settodepth\dsh{#1}%
\ifdim\wsh<20pt\relax\setlength{\wsh}{20pt}\fi%
\raisebox{0pt}[\hsh][\dsh]{%
\dotlinesh{\wsh}%
}}
\newcommand{\TF}[1]{\EXboxTF{\textbf{\colorEX#1}}}
\newcommand{\boxEX}[2][9pt]{%
\def\sizeboxEX{#1}%
\setbox1=\hbox{#2}%
\ \EXbox{#2}\ %
}
%Lệnh tagEX gán nhãn công thức thủ công
\newcommand{\tagEX}[1]{%
\hfill{\rm (#1)}%
\par
\@ifnextchar\begin%
{\vspace{-\baselineskip}}
{}
}
%Đánh dấu phương án đúng
\newcommand{\dapan}{Lệnh này giờ vô dụng}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw=blue,inner sep=1pt] (char) {\color{blue}\small #1};}}
\newcommand*\circEX[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw=red,inner sep=1pt,fill=yellow!50] (char) {\color{red}\small #1};}}
\newcommand*\squareEX[1]{\tikz[baseline=(char.base)]{\node[shape=rectangle,draw=red,inner sep=2.5pt,fill=yellow!50] (char) {\color{red}\small #1};}}
\newcounter{dapan}
\newcommand{\TrueEX}{\stepcounter{dapan}{\squareEX{\textbf{\Alph{dapan}}}}}
\newcommand{\FalseEX}{\stepcounter{dapan}{\circled{\textbf{\Alph{dapan}}}}}
\newlength\widthalpha
\newlength\widthalphaT
\newlength\widthalphaF
\settowidth\widthalphaT{\TrueEX}
\settowidth\widthalphaF{\FalseEX}
\ifdim\widthalpha<\widthalphaT\relax\setlength{\widthalpha}{\widthalphaT}\fi%
\ifdim\widthalpha<\widthalphaF\relax\setlength{\widthalpha}{\widthalphaF}\fi%
\newcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\TrueEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\newcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\TrueEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
%Hiện Chọn đáp án trong lời giải chi tiết
\def\selectA{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{A}}
\def\selectB{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{B}}
\def\selectC{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{C}}
\def\selectD{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{D}}
\def\selectE{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{E}}
\newcommand{\hidetextchoice}{
\def\selectA{}
\def\selectB{}
\def\selectC{}
\def\selectD{}
\def\selectE{}
}
\newcommand{\showtextchoice}{
\def\selectA{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{A}}
\def\selectB{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{B}}
\def\selectC{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{C}}
\def\selectD{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{D}}
\def\selectE{\par\noindent\color{violet}\faKey~ Chọn phương án \circEX{E}}
}
%Tương thích môi trường enumerate,itemize
\def\hfillEX{}
\BeforeBeginEnvironment{enumerate}
{\hfillEX}
\BeforeBeginEnvironment{itemize}
{\hfillEX}
\AtBeginEnvironment{multicols}
{\def\hfillEX{}}
\newcommand{\listenumerate}[1]{
\foreach \xenumerate in {#1} {%môi trường
\AtBeginEnvironment{\xenumerate}{%
\def\hfillEX{\hfillenum}%
}
\AtEndEnvironment{\xenumerate}{%
\def\hfillEX{}%
}
}}
\listenumerate{ex}
%Lời giải
\def\loigiaiEX{\color{blue} Lời giải.}
%Danh sách môi trường hiện dòng kẻ trong lời giải
\newcommand{\dotlineans}[2]{
\AtBeginEnvironment{#2}{%
\def\colorEX{}%
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\makeatletter
\renewcommand{\loigiai}[1]{
\dotlineEX{#1}
}}}
%Danh sách môi trường hiện dòng kẻ trong lời giải
\newcommand{\showansEX}[1]{
\AtBeginEnvironment{#1}{%
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\def\True{\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
\def\loigiaiEX{\color{blue}\faPencilSquareO~ Lời giải.}
\showanswers
%Xuất hiện chữ Lời giải trong môi trường onlysolution
\renewcommand{\do@onlysolution}[1]{%
\par\vspace{0.2cm}\noindent\hrule\vspace{0.1cm}
\par\noindent\centerline{\textbf{\loigiaiEX }}\vspace{-0.5cm}
\ifshowanswers
\@ifnextchar\immini
{}
{ \@ifnextchar\begin
{}
{\par\noindent}
}
##1
{}
\fi
\ifnum\the\value{numTrueSol}=1
\selectA
\fi
\ifnum\the\value{numTrueSol}=2
\selectB
\fi
\ifnum\the\value{numTrueSol}=3
\selectC
\fi
\ifnum\the\value{numTrueSol}=4
\selectD
\fi
\ifnum\the\value{numTrueSol}=5
\selectE
\fi
\setcounter{numTrueSol}{0}
\hfill\qedEX\par
}%
\renewcommand{\loigiai}[1]{
\labelex
\def\labelex{}
\begin{onlysolution}
##1
\end{onlysolution}
}
}}
%Danh sách môi trường hiện dòng kẻ trong lời giải
\newcommand{\hideansEX}[1]{
\AtBeginEnvironment{#1}{%
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\def\colorEX{}
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\renewenvironment{onlysolution}{%
\long@collect@body\do@onlysolution
}{}
\renewcommand{\loigiai}[1]{
}
}}
%Định nghĩa QED kết thúc chứng minh
\def\qedEX{\ensuremath{\square}}
%Đáp số câu hỏi tự luận
\Newassociation{solshort}{Solshort}{ansshort}
\renewcommand{\Solshortlabel}[1]{\color{violet}\textbf{#1.}
}
\newcommand{\shortsolnum}[1]
{
\renewenvironment{Solshort}[1]
{\begin{minipage}{\linewidth/#1-1.2\fboxsep}
\color{violet}\textbf{##1.}
\color{black}
}
{\end{minipage}}
}
\newcommand{\shortsol}[1]{
\scantokens{
\begin{solshort}
#1
\end{solshort}}
}
%Trích dẫn nguồn
\def\labelex{}
\newcommand{\nameex}{Câu}
%Dấu chấm, phảy sau mỗi phương án
\def\dotEX{.}
%Tương thích gói picinpar
\def\picinpar{\setlength{\linewidth}{\linewidth}}
\AtBeginEnvironment{window}{\def\picinpar{\setlength{\linewidth}{\linewidth-\picwd-\lwindowsep-2\fboxsep}}}
%Tùy chọn lời giải
\newcommand{\choicew}[1]{\setlength{\widthch}{#1}}
\newcommand{\loigiai}[1]{%
\begin{onlysolution}
#1
\end{onlysolution}
}
\def\colorEX{\color{red}}
\newcounter{numTrue}
\newcounter{numTrueSol}
\DeclareOption{solcolor}{
\renewcommand{\TF}[1]{\EXboxTF{\textbf{\colorEX#1}}}
\renewcommand{\boxEX}[2][9pt]{%
\setbox1=\hbox{#2}%
\def\sizeboxEX{#1}%
\ \EXbox{#2}\ %
}
\renewcommand{\sh}[1]{\text{#1}}
\renewcommand{\TrueEX}{\stepcounter{dapan}{\squareEX{\textbf{\Alph{dapan}}}}}
\renewcommand{\FalseEX}{\stepcounter{dapan}{\circled{\textbf{\Alph{dapan}}}}}
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\TrueEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\TrueEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\def\True{\leavevmode\colorEX\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
\def\loigiaiEX{\color{orange}\faPencilSquareO~ Lời giải.}
\showanswers
%Xuất hiện chữ Lời giải trong môi trường onlysolution
\renewcommand{\do@onlysolution}[1]{%
%\par\vspace{.2cm}\noindent\hrule\vspace{.1cm}
\par\noindent\textbf{\loigiaiEX}%\color{brown}\hrulefill
\ifshowanswers
\@ifnextchar\immini
{}
{ \@ifnextchar\begin
{}
{\par\noindent}
}
#1
\fi
\ifnum\the\value{numTrueSol}=1
\leavevmode\unskip\selectA\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=2
\leavevmode\unskip\selectB\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=3
\leavevmode\unskip\selectC\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=4
\leavevmode\unskip\selectD\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=5
\leavevmode\unskip\selectE\ignorespaces
\fi
\setcounter{numTrueSol}{0}
\dotfill\qedEX\par
{}
}%
\renewcommand{\loigiai}[1]{
\labelex
\def\labelex{}
\begin{onlysolution}
#1
\end{onlysolution}
}
}
\DeclareOption{loigiai}{
\renewcommand{\TF}[1]{\EXboxTF{\textbf{\colorEX#1}}}
\renewcommand{\boxEX}[2][9pt]{%
\setbox1=\hbox{#2}%
\def\sizeboxEX{#1}%
\ \EXbox{#2}\ %
}
\renewcommand{\sh}[1]{\text{#1}}
\renewcommand{\FalseEX}{\stepcounter{dapan}{\textbf{\Alph{dapan}}}.}
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\def\True{\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
\def\loigiaiEX{\color{purple}\faPencilSquareO~ Lời giải.~}
\showanswers
%Xuất hiện chữ Lời giải trong môi trường onlysolution
\renewcommand{\do@onlysolution}[1]{%
\par\noindent\vspace{.2cm}\textbf{\loigiaiEX }%\color{brown}\hrulefill
\ifshowanswers
\@ifnextchar\immini
{}
{ \@ifnextchar\begin
{}
{\par\noindent}
}
#1%
\fi
\ifnum\the\value{numTrueSol}=1
\leavevmode\unskip\selectA\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=2
\leavevmode\unskip\selectB\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=3
\leavevmode\unskip\selectC\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=4
\leavevmode\unskip\selectD\ignorespaces
\fi
\ifnum\the\value{numTrueSol}=5
\leavevmode\unskip\selectE\ignorespaces
\fi
\setcounter{numTrueSol}{0}
\dotfill\qedEX\par
{}
}
\renewcommand{\loigiai}[1]{
\labelex
\def\labelex{}
\begin{onlysolution}
#1
\end{onlysolution}
}
}
\DeclareOption{color}{
\renewcommand{\TrueEX}{\stepcounter{dapan}{\squareEX{\textbf{\Alph{dapan}}}}}
\renewcommand{\FalseEX}{\stepcounter{dapan}{\circled{\textbf{\Alph{dapan}}}}}
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\TrueEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\TrueEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\def\colorEX{\color{red}}
\def\True{\leavevmode\colorEX\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
}
\DeclareOption{book}{
\renewcommand{\FalseEX}{\stepcounter{dapan}{\textbf{\Alph{dapan}}}.}
\renewcommand{\TrueEX}{\stepcounter{dapan}{\textbf{\Alph{dapan}}}.}
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\def\loigiaiEX{\color{blue}\faPencilSquareO~ Lời giải.}
\showanswers
\makeatletter
\renewcommand{\loigiai}[1]{
\labelex
\def\labelex{}
\ifnum\the\value{numTrueSol}=1
\scantokens{
\begin{solbook}
\par\noindent
#1
\par\noindent
\selectA
\hfill\qedEX
\end{solbook}}
\fi
\ifnum\the\value{numTrueSol}=2
\scantokens{
\begin{solbook}
\par\noindent
#1
\par\noindent
\selectB
\hfill\qedEX
\end{solbook}}
\fi
\ifnum\the\value{numTrueSol}=3
\scantokens{
\begin{solbook}
\par\noindent
#1
\par\noindent
\selectC
\hfill\qedEX
\end{solbook}}
\fi
\ifnum\the\value{numTrueSol}=4
\scantokens{
\begin{solbook}
\par\noindent
#1
\par\noindent
\selectD
\hfill\qedEX
\end{solbook}}
\fi
\ifnum\the\value{numTrueSol}=5
\scantokens{
\begin{solbook}
\par\noindent
#1
\par\noindent
\selectE
\hfill\qedEX
\end{solbook}}
\fi
\ifnum\the\value{numTrueSol}=0
\scantokens{
\begin{solbook}
\par\noindent
#1
\hfill\qedEX
\end{solbook}}
\fi
\setcounter{numTrueSol}{0}
}
\def\True{\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
}
\DeclareOption{dethi}{
\renewcommand{\TF}[1]{\EXboxTF{}}
\renewcommand{\boxEX}[2][9pt]{%
\def\sizeboxEX{#1}%
\setbox1=\hbox{#2}%
\ \EXbox{}\ %
}
\renewcommand{\FalseEX}{\stepcounter{dapan}{\textbf{\Alph{dapan}}}.}
\makeatletter
\renewcommand{\begindapan}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{\dorong}
}
}
\renewcommand{\begindapanhaiba}{
\@ifnextchar\True
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
{
\begin{minipage}[t]{\widthalpha}
\FalseEX
\end{minipage}
\begin{minipage}[t]{0.67\dorong}
}
}
\def\True{\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
}
\ExecuteOptions{dethi}
\ProcessOptions
%Nội dung gói ex_test
\theorempreskipamount0.1\baselineskip
\theorempostskipamount0.2\baselineskip
\newlength\dorongfix
\dorongfix=\linewidth
\newlength\dorong
\dorong=\linewidth
\newcommand{\reducedstrut}{\vrule width 0pt height .9\ht\strutbox depth .9\dp\strutbox\relax}
\def\hfillenum{\hfill}
\makeatletter
%\newtheoremstyle{immini}%
%{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]
% \def\labelthm{##1}%
% \def\labelthmfull{{\theorem@headerfont ##1\ ##2\theorem@separator\ }}%
%}%
%{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]
% \def\labelthm{##1}%
% \def\labelthmfull{{\theorem@headerfont ##1\ ##2\ (##3)\theorem@separator\ }}%
%}
\newtheoremstyle{immini}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]
\def\thindent{%
\setbox0\vbox{\hbox{\leavevmode\unskip\theorem@headerfont ##1\ ##2\theorem@separator\ignorespaces}}%
\hspace*{\wd0}%
}%
\def\labelthm{##1}%
\def\labelthmfull{{\theorem@headerfont ##1\ ##2\theorem@separator\ }}
}%
{%
\setbox1\vbox{\hbox{\theorem@headerfont ##1\ ##2\ (##3)\theorem@separator\ignorespaces}}%
\ifdim\wd1>0.4\linewidth\relax%
\item\hbox to \linewidth{\theorem@headerfont ##1\ ##2\
(##3)\theorem@separator\hfill}
\else
\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]
\fi
\ifdim\wd1>0.4\linewidth\relax
\def\hfillenum{}
\def\thindent{%
}%
\def\labelthmfull{%
}
\else
\def\hfillenum{\hfill}
\def\thindent{%
\setbox0\vbox{\hbox{\leavevmode\unskip\theorem@headerfont ##1\ ##2\ (##3)\theorem@separator\ignorespaces}}%
\hspace*{\wd0}%
}%
\def\labelthmfull{{\theorem@headerfont ##1\ ##2\ (##3)\theorem@separator\ }}
\fi
\def\labelthm{##1}%
}
\newtheoremstyle{imminib}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]
\def\thindent{%
\setbox0\vbox{\hbox{\leavevmode\unskip\theorem@headerfont ##1\ ##2\theorem@separator\ignorespaces}}%
\hspace*{\wd0}%
}%
\def\labelthm{##1}%
\def\labelthmfull{{\theorem@headerfont ##1\ ##2\theorem@separator\ }}
}%
{%
\setbox1\vbox{\hbox{\theorem@headerfont ##1\ ##2\ (##3)\theorem@separator\ignorespaces}}%
\ifdim\wd1>0.4\linewidth\relax%
\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]
\else
\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]
\fi
\ifdim\wd1>0.4\linewidth\relax
\def\labelex{%
\begin{flushright}
\vspace*{-5pt}
\textit{\textbf{(##3)}}
\vspace*{-5pt}
\end{flushright}}
\def\thindent{%
\setbox0\vbox{\hbox{\leavevmode\unskip\theorem@headerfont ##1\ ##2\theorem@separator\ignorespaces}}%
\hspace*{\wd0}%
}%
\def\labelthmfull{{\theorem@headerfont ##1\ ##2\theorem@separator\ }}
\else
\def\thindent{%
\setbox0\vbox{\hbox{\leavevmode\unskip\theorem@headerfont ##1\ ##2\ (##3)\theorem@separator\ignorespaces}}%
\hspace*{\wd0}%
}%
\def\labelthmfull{{\theorem@headerfont ##1\ ##2\ (##3)\theorem@separator\ }}
\fi
\def\labelthm{##1}%
}
\newtheoremstyle{exbreak}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
{\item\hbox to \linewidth{\theorem@headerfont ##1\ ##2\
(##3)\theorem@separator\hfill}}
\newtheoremstyle{explain}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]\def\labelex{
\begin{flushright}
\vspace*{-5pt}
\textit{\textbf{(##3)}}
\vspace*{-5pt}
\end{flushright}}}
%Danh sách môi trường trích dẫn nguồn câu hỏi
\newcommand{\listtheorem}[1]{
\foreach \x in {#1} {%môi trường
\AtEndEnvironment{\x}{%
\labelex
}}%
}
\makeatother
\theoremstyle{immini}
\theoremseparator{:}
\theorembodyfont{\rm}
\Newassociation{solbook}{Solbook}{ansbook}
\renewcommand{\Solbooklabel}[1]{\textbf{\nameex\ #1.}
}
\Newassociation{EXsol}{Solution}{ans}
\Newassociation{sol}{Solution}{ans_old}
\newtheorem{ex}{\nameex}
\AtBeginEnvironment{Solbook}{
\renewcommand{\IMleftright}[3]{
\par\noindent
\begin{minipage}[t][][t]{\linewidth-\widthimmini-4\fboxsep-#1\linewidth}
#2
\end{minipage}
\hspace{#1\linewidth}\hspace{2\fboxsep}
\begin{minipage}[t][][b]{\widthimmini}\vspaceIM
#3
\end{minipage}
\par\nointerlineskip
}
}
\AtBeginEnvironment{ex}{%
\setcounter{numTrueSol}{0}%
\def\dotEX{.}%
\setcounter{numChoice}{0}%
}
\AtEndEnvironment{ex}{%
\ifnum\the\value{numTrue}=1
\scantokens{\begin{EXsol}A\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=2
\scantokens{\begin{EXsol}B\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=3
\scantokens{\begin{EXsol}C\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=4
\scantokens{\begin{EXsol}D\end{EXsol}}
\fi
\ifnum\the\value{numTrue}=5
\scantokens{\begin{EXsol}E\end{EXsol}}
\fi
\setcounter{numTrue}{0}%
\setcounter{numTrueSol}{0}%
\labelex%
}
\newtheorem{vdex}{Ví dụ}
\AtBeginEnvironment{vdex}{\setcounter{numTrueSol}{0}\def\dotEX{.}}
\newcommand{\boncot}[4]{
\picinpar
\setlength{\dorong}{0.25\linewidth-0.02\dorongfix-\widthalpha-2\fboxsep}
\par\setcounter{dapan}{0}
\noindent\hspace{0.02\dorongfix}\begindapan
#1\dotEX
\end{minipage}
\noindent\begindapan
#2\dotEX
\end{minipage}
\noindent\begindapan
#3\dotEX
\end{minipage}
\noindent\begindapan
#4\dotEX
\end{minipage}
}
%%%%
\def\parskipchoice{0cm}
\newcommand{\haicot}[4]{
\picinpar
\setlength{\dorong}{0.5\linewidth-0.02\dorongfix-\widthalpha-2\fboxsep}
\par\setcounter{dapan}{0}
\noindent\hspace{0.02\dorongfix}\begindapan
#1\dotEX
\end{minipage}
\noindent\begindapan
#2\dotEX
\end{minipage}
\par\setlength{\parskip}{\parskipchoice}\noindent\hspace{0.02\dorongfix}\begindapan
#3\dotEX
\end{minipage}
\noindent\begindapan
#4\dotEX
\end{minipage}
}
\newcommand{\motcot}[4]{
\picinpar
\setlength{\dorong}{\linewidth-0.02\dorongfix-\widthalpha-2\fboxsep}
\par\setcounter{dapan}{0}
\noindent\hspace{0.02\dorongfix}\begindapan
#1\dotEX\strut
\end{minipage}
\par\setlength{\parskip}{\parskipchoice}
\noindent\hspace{0.02\dorongfix}\begindapan
#2\dotEX\strut
\end{minipage}
\par\setlength{\parskip}{\parskipchoice}
\noindent\hspace{0.02\dorongfix}\begindapan
#3\dotEX\strut
\end{minipage}
\par\setlength{\parskip}{\parskipchoice}
\noindent\hspace{0.02\dorongfix}\begindapan
#4\dotEX\strut
\end{minipage}
}
%%%%%%%Tự động chọn \motcot, \haicot, \boncot
\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthche
\newlength\widthch
\newlength\tabmaxwidth
\newlength\fourthtabwidth
\newlength\halftabwidth
\newlength\fifthtabwidth
\newlength\thirdtabwidth
\newcommand{\choice}[5][0]{
\setlength\tabmaxwidth{\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\setlength\fourthtabwidth{0.25\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\setlength\halftabwidth{0.5\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\settowidth\widthcha{#2}
\ifdim\widthch<\widthcha\relax\setlength{\widthch}{\widthcha}\fi%
\settowidth\widthchb{#3}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchc{#4}%
\ifdim\widthch<\widthchc\relax\setlength{\widthch}{\widthchc}\fi%
\settowidth\widthchd{#5}%
\ifdim\widthch<\widthchd\relax\setlength{\widthch}{\widthchd}\fi%
\ifthenelse{\equal{#1}{0}}
{
\ifdim\widthch<\fourthtabwidth
\boncot{#2}{#3}{#4}{#5}
\else\ifdim\widthch<\halftabwidth
\haicot{#2}{#3}{#4}{#5}
\else
\motcot{#2}{#3}{#4}{#5}
\fi\fi
}
{
\ifthenelse{\equal{#1}{1}}
{
\def\parskipchoice{0.2cm}
\motcot{#2}{#3}{#4}{#5}}
{
\ifthenelse{\equal{#1}{2}}
{
\def\parskipchoice{0.2cm}
\haicot{#2}{#3}{#4}{#5}}
{
\ifthenelse{\equal{#1}{4}}
{
\def\parskipchoice{0.2cm}
\boncot{#2}{#3}{#4}{#5}}
{
\def\parskipchoice{#1}
\ifdim\widthch<\fourthtabwidth
\boncot{#2}{#3}{#4}{#5}
\else\ifdim\widthch<\halftabwidth
\haicot{#2}{#3}{#4}{#5}
\else
\motcot{#2}{#3}{#4}{#5}
\fi\fi
}}}}
}
\newcommand{\choicefix}[4]{%
\setlength\tabmaxwidth{\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\setlength\fourthtabwidth{0.25\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\setlength\halftabwidth{0.5\linewidth-0.02\dorongfix-\widthalpha-3\fboxsep}
\settowidth\widthcha{#1}
\ifdim\widthch<\widthcha\relax\setlength{\widthch}{\widthcha}\fi%
\settowidth\widthchb{#2}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\settowidth\widthchc{#3}%
\ifdim\widthch<\widthchc\relax\setlength{\widthch}{\widthchc}\fi%
\settowidth\widthchd{#4}%
\ifdim\widthch<\widthchd\relax\setlength{\widthch}{\widthchd}\fi%
\ifdim\widthch<\fourthtabwidth
\boncot{#1}{#2}{#3}{#4}
\else\ifdim\widthch<\halftabwidth
\haicot{#1}{#2}{#3}{#4}
\else
\motcot{#1}{#2}{#3}{#4}
\fi\fi
}
%Trắc nghiệm 5 lựa chọn
\newcommand{\nammot}[5]{
\picinpar
\setlength{\dorong}{0.2\linewidth-0.022\dorongfix-2\fboxsep-\widthalpha}
\par\setcounter{dapan}{0}
\noindent\hspace{0.02\dorongfix}\begindapan
#1\dotEX
\end{minipage}
\noindent\begindapan
#2\dotEX
\end{minipage}
\noindent\begindapan
#3\dotEX
\end{minipage}
\noindent\begindapan
#4\dotEX
\end{minipage}
\noindent\begindapan
#5\dotEX
\end{minipage}
}
\newcommand{\bahai}[5]{
\picinpar
\setlength{\dorong}{0.5\linewidth-0.02\dorongfix-\fboxsep-3\widthalpha}
\setcounter{dapan}{0}
\par\noindent\hspace{0.02\dorongfix}\begindapanhaiba
#1\dotEX
\end{minipage}
\noindent\begindapanhaiba
#2\dotEX
\end{minipage}
\noindent\begindapanhaiba
#3\dotEX
\end{minipage}
\par\noindent\hspace{0.02\dorongfix}\begindapan
#4\dotEX
\end{minipage}
\noindent\begindapan
#5\dotEX
\end{minipage}
}
\newcommand{\haiba}[5]{
\picinpar
\setlength{\dorong}{0.5\linewidth-0.02\dorongfix-\fboxsep-3\widthalpha}
\setcounter{dapan}{0}
\par\noindent\hspace{0.02\dorongfix}\begindapan
#1\dotEX
\end{minipage}
\noindent\begindapan
#2\dotEX
\end{minipage}
\par\noindent\hspace{0.02\dorongfix}\begindapanhaiba
#3\dotEX
\end{minipage}
\noindent\begindapanhaiba
#4\dotEX
\end{minipage}
\noindent\begindapanhaiba
#5\dotEX
\end{minipage}
}
\newcommand{\motnam}[5]{
\picinpar
\setlength{\dorong}{\linewidth-0.02\dorongfix-\fboxsep-2\widthalpha}
\par\setcounter{dapan}{0}
\noindent\hspace{0.02\dorongfix}\begindapan
#1\dotEX\strut
\end{minipage}
\par\noindent\hspace{0.02\dorongfix}\begindapan
#2\dotEX\strut
\end{minipage}
\par\noindent\hspace{0.02\dorongfix}\begindapan
#3\dotEX\strut
\end{minipage}
\par\noindent\hspace{0.02\dorongfix}\begindapan
#4\dotEX\strut
\end{minipage}
\par\noindent\hspace{0.02\dorongfix}\begindapan
#5\dotEX\strut
\end{minipage}
}
\newlength\wmothai
\newlength\wmothaiba
\newlength\wmothaibabon
\newlength\wbonnam
\newlength\wbabonnam
\newlength\whaibabonnam
\newcounter{numChoice}
\newcommand{\choicefive}[5]{%
\setlength\tabmaxwidth{\linewidth-\picwd-\lwindowsep}
\setlength\fourthtabwidth{0.25\linewidth-0.25\picwd-0.25\lwindowsep-\widthalpha}
\setlength\halftabwidth{0.5\linewidth-0.5\picwd-0.5\lwindowsep-\widthalpha}
\setlength\fifthtabwidth{0.2\linewidth-0.2\picwd-0.2\lwindowsep-\widthalpha}
\setlength\thirdtabwidth{0.33\linewidth-0.33\picwd-0.33\lwindowsep-\widthalpha}
\settowidth\widthcha{AM.#1}
\ifdim\widthch<\widthcha\relax\setlength{\widthch}{\widthcha}\fi%
\ifdim\wmothai<\widthcha\relax\setlength{\wmothai}{\widthcha}\fi%
\ifdim\wmothaiba<\widthcha\relax\setlength{\wmothaiba}{\widthcha}\fi%
\ifdim\wmothaibabon<\widthcha\relax\setlength{\wmothaibabon}{\widthcha}\fi%
\settowidth\widthchb{BM.#2}%
\ifdim\widthch<\widthchb\relax\setlength{\widthch}{\widthchb}\fi%
\ifdim\wmothai<\widthchb\relax\setlength{\wmothai}{\widthchb}\fi%
\ifdim\wmothaiba<\widthchb\relax\setlength{\wmothaiba}{\widthchb}\fi%
\ifdim\wmothaibabon<\widthchb\relax\setlength{\wmothaibabon}{\widthchb}
\fi%
\ifdim\whaibabonnam<\widthchb\relax\setlength{\whaibabonnam}{\widthchb}
\fi%
\settowidth\widthchc{CM.#3}%
\ifdim\widthch<\widthchc\relax\setlength{\widthch}{\widthchc}\fi%
\ifdim\wmothaiba<\widthchc\relax\setlength{\wmothaiba}{\widthchc}\fi%
\ifdim\wmothaibabon<\widthchc\relax\setlength{\wmothaibabon}{\widthchc}\fi%
\ifdim\wbabonnam<\widthchc\relax\setlength{\wbabonnam}{\widthchc}\fi%
\ifdim\whaibabonnam<\widthchc\relax\setlength{\whaibabonnam}{\widthchc}
\fi%
\settowidth\widthchd{DM.#4}%
\ifdim\widthch<\widthchd\relax\setlength{\widthch}{\widthchd}\fi%
\ifdim\wmothaibabon<\widthchd\relax\setlength{\wmothaibabon}{\widthchd}\fi%
\ifdim\wbabonnam<\widthchd\relax\setlength{\wbabonnam}{\widthchd}\fi%
\ifdim\wbonnam<\widthchd\relax\setlength{\wbonnam}{\widthchd}\fi%
\ifdim\whaibabonnam<\widthchd\relax\setlength{\whaibabonnam}{\widthchd}
\fi%
\settowidth\widthche{EM.#5}%
\ifdim\widthch<\widthche\relax\setlength{\widthch}{\widthche}\fi%
\ifdim\wbabonnam<\widthche\relax\setlength{\wbabonnam}{\widthche}\fi%
\ifdim\wbonnam<\widthche\relax\setlength{\wbonnam}{\widthche}\fi%
\ifdim\whaibabonnam<\widthchd\relax\setlength{\whaibabonnam}{\widthchd}
\fi%
%Khởi tạo điều kiện
\setcounter{numChoice}{0}
\ifdim\wmothai<\halftabwidth
\ifdim\wbabonnam<\thirdtabwidth
\setcounter{numChoice}{1}
\fi\fi
\ifdim\wmothaiba<\thirdtabwidth
\ifdim\wbonnam<\halftabwidth
\setcounter{numChoice}{2}
\fi\fi
\ifdim\widthch<\fifthtabwidth
\setcounter{numChoice}{3}
\fi
%Lựa chọn cách sắp xếp
\ifnum\the\value{numChoice}=3
\nammot{#1}{#2}{#3}{#4}{#5}
\else
\ifnum\the\value{numChoice}=2
\bahai{#1}{#2}{#3}{#4}{#5}
\else
\ifnum\the\value{numChoice}=1
\haiba{#1}{#2}{#3}{#4}{#5}
\else
\motnam{#1}{#2}{#3}{#4}{#5}
\fi\fi\fi
}
%HẾT trắc nghiệm 5 lựa chọn
%Các phương pháp đưa hình vào văn bản
\def\vspaceIM{\vspace{-0.5\baselineskip}}
\def\breakIM{\filbreak}
\def\numpicinpar{0}
\newdimen\heightline
\newdimen\widthimmini
\newdimen\heightimmini
\newdimen\heighttextimmini
\newdimen\himmini
\newdimen\spaceleft
\newbox\imbox
\newbox\imboxtext
\newcommand{\hspaceIM}[1]{
\def\hspaceIMEX{\hspace{#1\linewidth}}
\def\hspaceEXIM{#1\linewidth}
}
\newcommand{\IMleftright}[3]{
\hfill\par\noindent
\begin{minipage}[t][][t]{\linewidth-\widthimmini-4\fboxsep-#1\linewidth}
#2
\end{minipage}
\hspace{#1\linewidth}\hspace{2\fboxsep}
\begin{minipage}[t][][b]{\widthimmini}\vspaceIM
#3
\centering \IMname\IMlabel
\end{minipage}
\par\nointerlineskip
}
\newcommand{\IMrightleft}[3]{
\hfill\par\noindent
\begin{minipage}[t][][b]{\widthimmini}\vspaceIM
#3
\centering \IMname\IMlabel
\end{minipage}
\hspace{#1\linewidth}\hspace{2\fboxsep}
\begin{minipage}[t][][t]{\linewidth-\widthimmini-4\fboxsep-#1\linewidth}
#2
\end{minipage}
\par\nointerlineskip
}
\newcommand{\immini}[3][0]{
\savebox{\imbox}{#3}
\widthimmini=\wd\imbox
\heightimmini=\ht\imbox
\ifthenelse{\equal{#1}{thm}}
{%
\savebox{\imboxtext}{\vbox{#2}}
\leavevmode\nopagebreak\IMleftright{0}{\protect\leavevmode\labelthmfull#2}{#3}
}
{
\IMleftright{#1}{#2}{#3}
}
}
%\newcommand{\immini}[3][0]{%Trước 22/5
% \savebox{\imbox}{#3}
% \widthimmini=\wd\imbox
% \heightimmini=\ht\imbox
% \ifthenelse{\equal{#1}{thm}}
% {%
% \savebox{\imboxtext}{\vbox{#2}}
% \leavevmode\vspace{-\baselineskip}\IMleftright{0}{\protect\leavevmode\labelthmfull#2}{#3}
% }
% {
% \IMleftright{#1}{#2}{#3}
% }
%}
%\NewDocumentCommand{\immini}{
% O{0}%
% D(){-13pt}%
% D<>{}%
% m%
% m%
%}{%
% \setbox\imbox=\vbox{\hbox{#5}}
% \widthimmini=\wd\imbox
% \heightimmini=\ht\imbox
% \def\vspaceIM{\vspace{#2}}
% \ifthenelse{\equal{#3}{thm}}
% {
% \setbox\imboxtext=\vbox{\hbox{#4}}
% \heighttextimmini=\ht\imboxtext
% \spaceleft=\dimexpr\textheight-\pagetotal-2\baselineskip\relax
% \himmini=\heightimmini
% \ifdim\himmini<\heighttextimmini \himmini=\heighttextimmini\fi
% \ifdim\himmini>\spaceleft
% \breakIM
% \fi
% \leavevmode\vspace{-\baselineskip}\IMleftright{#1}{\thindent#4}{#5}}
% {\IMleftright{#1}{#4}{#5}}
%}
\newcommand{\imminiL}[3][0]{
\setbox\imbox=\vbox{\hbox{#3}}
\widthimmini=\wd\imbox
\heightimmini=\ht\imbox
\spaceleft=\dimexpr\textheight-\pagetotal-2\baselineskip\relax
\ifdim\heightimmini>\spaceleft
\breakIM
\fi
\IMrightleft{#1}{#2}{#3}
}
\newcommand{\impicinpar}[2]{
\begin{window}[\numpicinpar,r,{
#2
}, {}]
\begin{flushleft}
#1
\end{flushleft}
\end{window}
}
%Hết cách đưa hình vào văn bản
% Biểu diễn khoảng, đoạn trên trục số
\usetikzlibrary{decorations.pathreplacing,decorations.markings,patterns}
\def\colorInterval{black}
\def\skipInterval{0.4cm}
\newcommand{\Interval}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (#2,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (#4,0);
\draw[color=\colorInterval] decorate[decoration={ticks,amplitude=3pt,segment length=1mm}] {(a)--(b)};
}
\newcommand{\IntervalR}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (#2,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (#4,0);
\draw decorate[decoration={markings,mark=% actually add a mark
between positions 0 and 1 step 1mm
with
{
\draw[color=\colorInterval] (-3pt,-3pt) -- (3pt,3pt);
}}] {(a)--(b)};
}
\newcommand{\IntervalL}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (#2,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (#4,0);
\draw decorate[decoration={
markings,
mark=between positions 0 and 1 step 1mm
with
{
\draw[color=\colorInterval] (-3pt,3pt) -- (3pt,-3pt);
}
}
] {(a)--(b)};
}
\newcommand{\IntervalLF}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (#2,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (#4,0);
\fill[pattern=north west lines,pattern color=\colorInterval](#2,-3pt)rectangle(#4,3pt);
}
\newcommand{\IntervalRF}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (#2,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (#4,0);
\fill[pattern=north east lines,pattern color=\colorInterval](#2,-3pt)rectangle(#4,3pt);
}
\def\pre{0}
\def\next{2}
\newcommand{\IntervalLR}[2]{
\def\pre{#1}
\def\next{#2}
}
\newcommand{\IntervalG}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (\pre,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (\next,0);
\draw[color=\colorInterval] decorate[decoration={ticks,amplitude=3pt,segment length=1mm}] {(a)--(b)};
}
\newcommand{\IntervalGL}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (\pre,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (\next,0);
\draw decorate[decoration={markings,mark=% actually add a mark
between positions 0 and 1 step 1mm
with
{
\draw[color=\colorInterval] (-3pt,3pt) -- (3pt,-3pt);
}}] {(a)--(b)};
}
\newcommand{\IntervalGR}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (\pre,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (\next,0);
\draw decorate[decoration={markings,mark=% actually add a mark
between positions 0 and 1 step 1mm
with
{
\draw[color=\colorInterval] (-3pt,-3pt) -- (3pt,3pt);
}}] {(a)--(b)};
}
\newcommand{\IntervalGLF}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (\pre,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (\next,0);
\fill[pattern=north west lines,pattern color=\colorInterval](\pre,-3pt)rectangle(\next,3pt);
}
\newcommand{\IntervalGRF}[4]{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{\skipInterval}#2$] (a) at (\pre,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{\skipInterval}#4$] (b) at (\next,0);
\fill[pattern=north east lines,pattern color=\colorInterval](\pre,-3pt)rectangle(\next,3pt);
}
%Định nghĩa dots fill
\newcommand{\dotlineEX}[1]{
\def\numlinedot{#1}
\par
\foreach \dotline in{1,...,\numlinedot}
{
\noindent\dotfill
\par
}
}
%Liệt kê danh sách đáp án
\newsavebox{\myboxans}
\newcommand{\boxans}
{
\renewenvironment{Solution}[1]
{\begin{lrbox}{\myboxans}\begin{minipage}{.1\linewidth-4\fboxsep}
\parbox[b]{.55\linewidth}{\color{blue}##1 -}
\color{purple}
}
{\end{minipage}\end{lrbox}\fbox{\usebox{\myboxans}}}
}
\newcommand{\listans}
{
\renewenvironment{Solution}[1]
{{\color{blue}##1}\hspace*{-4pt}}
{\hspace*{-5pt}}
}
\newcommand{\tabans}[1]
{
\renewenvironment{Solution}[1]
{\begin{minipage}{\linewidth/#1-1.2\fboxsep}
\parbox[b]{0.45\linewidth}{
\raggedleft\color{blue}##1.
}
\color{violet}
}
{\end{minipage}}
}
\newcommand{\rowans}
{
\renewenvironment{Solution}[1]
{\begin{minipage}{0.1\linewidth-1.2\fboxsep}
\parbox[b]{0.45\linewidth}{
\raggedleft\color{blue}##1.
}
\color{violet}
}
{\end{minipage}}
}
\newcommand{\inputans}[2]{
\renewenvironment{Solution}[1]
{\begin{minipage}{\linewidth/#1-1.2\fboxsep}
\parbox[b]{0.45\linewidth}{
\raggedleft\color{blue}##1.
}
\color{violet}
}
{\end{minipage}}
\begin{flushleft}
\input{#2}
\end{flushleft}
}
\newcommand{\inputansbox}[2]{
\renewenvironment{Solution}[1]
{\begin{lrbox}{\myboxans}\begin{minipage}{\linewidth/#1-4\fboxsep}
\parbox[b]{0.55\linewidth}{\color{blue}##1.}
\color{violet}
}
{\end{minipage}\end{lrbox}\fbox{\usebox{\myboxans}}}
\begin{flushleft}
\input{#2}
\end{flushleft}
}
\makeatletter
\@ifclasswith{article}{a5paper}
{%
\renewcommand{\rowans}
{
\renewenvironment{Solution}[1]
{\begin{minipage}{0.2\linewidth-1.2\fboxsep}
\parbox[b]{0.45\linewidth}{\color{blue}##1.}
\color{violet}
}
{\end{minipage}}
}
}{%
}
\@ifclasswith{book}{a5paper}
{%
\renewcommand{\rowans}
{
\renewenvironment{Solution}[1]
{\begin{minipage}{0.2\linewidth-1.2\fboxsep}
\parbox[b]{0.45\linewidth}{\color{blue}##1.}
\color{violet}
}
{\end{minipage}}
}
}{%
}
\makeatother
\def\hideans{
\renewcommand{\inputansbox}[2]{%
}%
\renewcommand{\inputans}[2]{%
}%
\renewcommand{\tabans}[1]{%
}%
}
%Hỗ trợ gói ex_test_rd
\newenvironment{fileEX}{\filecontents}{\endfilecontents}
\newcommand{\bankEX}[2]{
\input{#1}
}
\newtheorem{exrd}{Câu}
\def\listfile{
\bankEX{onefile.tex}{50}
}
\def\testname{
\begin{center}
\textbf{ĐỀ THI MẪU}
\end{center}
\rightline{
\setlength\fboxrule{2pt}
\setlength\fboxsep{5pt}
\fbox{\textbf{Mã đề thi\ \x}}
}
}
\newcommand{\randombank}[1]{
%\testname
\begin{center}
\textbf{
\color{red}
Bạn đang chạy bằng gói ex\_test xuất ra MỌI CÂU HỎI của ngân hàng nhằm soát lỗi.\\
Khi mọi thứ đã OK, hãy thay khai báo gói ex\_test bằng gói ex\_test\_rd
}
\end{center}
\Opensolutionfile{ans}[ans/ans_ex_test]
\listfile
\Closesolutionfile{ans}
}
\newcommand{\showansfull}{\par Các mã đề: }
\newcommand{\showans}{\par Các mã đề: }
%Đường tròn LG
\usetikzlibrary{plotmarks}
\newcommand{\trucLG}{
\draw[->] (0,-1.3) -- (0,1.3) node[left] {$\sin$};
\draw[->] (-1.3,0) -- (1.3,0) node[below] {$\cos$};
\draw (0,0) circle (1cm);
}
\newcommand{\pointLG}[4]
{
\foreach \i in {0,...,#2}
{
\draw[color=#4]
plot[mark=#3] coordinates {({#1+\i*360/#2}:1)};
}
}
\makeatletter
\def\sizeboxEX{9pt}
\def\EXbox#1{%
\begingroup%
\setlength{\fboxsep}{0.3ex}%
\setlength{\@tempdima}{\sizeboxEX}%
\setlength{\@tempdimb}{(\@tempdima-\ht1+\dp1)/2}%
\raise-\@tempdimb\hbox{\fbox{\vbox to \@tempdima{%
\vfil\hbox to \@tempdima{\hfil#1\hfil}\vfil}}}%
\endgroup%
}
\def\EXboxTF#1{%
\begingroup%
\setlength{\fboxsep}{0.3ex}%
\setbox1=\hbox{#1}%
\setlength{\@tempdima}{\sizeboxEX}%
\fbox{\vbox to \@tempdima{%
\vfil\hbox to \@tempdima{\hfil\copy1\hfil}\vfil}}%
\endgroup%
}
\makeatother
% Môi trường liệt kê dàn theo nhiều dòng khác nhau
\ExplSyntaxOn
% variants of kernel functions:
\cs_generate_variant:Nn \tl_if_eq:nnTF { V }
\cs_generate_variant:Nn \tl_if_eq:nnT { V }
% --------------------------------------------------------------------------
% variables:
\seq_new:N \l__listsEX_seq
\int_new:N \l__listsEX_depth_int
\int_new:N \g__listsEX_int
\int_new:N \g__listsEX_total_items_int
\int_new:N \l__listsEX_columns_int
\int_new:N \l__listsEX_rows_int
\int_new:N \g__listsEX_current_col_num_int
\int_new:N \g__listsEX_current_row_num_int
\int_new:N \l__listsEX_item_columns_int
\bool_new:N \l__listsEX_enumerate_bool
\bool_new:N \l__listsEX_resume_bool
\bool_new:N \l__listsEX_load_listsEX_bool
\bool_new:N \l__listsEX_label_width_bool
\bool_new:N \l__listsEX_item_indent_bool
\bool_new:N \l__listsEX_label_offset_bool
\bool_new:N \l__listsEX_custom_label_bool
\bool_new:N \l__listsEX_custom_after_item_skip_bool
\bool_new:N \l__listsEX_debug_bool
\bool_new:N \l__listsEX_item_full_line_bool
\bool_new:N \l__listsEX_item_rest_of_line_bool
\tl_new:N \l__listsEX_instance_tl
\tl_new:N \l__listsEX_label_tl
\tl_new:N \l__listsEX_custom_label_tl
\tl_new:N \l__listsEX_label_pattern_tl
\tl_new:N \l__listsEX_custom_label_pattern_tl
\tl_new:N \l__listsEX_label_format_tl
\tl_new:N \l__listsEX_custom_label_format_tl
\tl_new:N \l__listsEX_item_format_tl
\tl_new:N \l__listsEX_custom_item_format_tl
\tl_new:N \l__listsEX_item_fill_left_tl
\tl_new:N \l__listsEX_item_fill_right_tl
\tl_new:N \l__listsEX_label_align_tl
% \tl_new:N \listEX
\tl_new:N \l__listsEX_item_tl
\tl_new:N \l__listsEX_tmp_label_tl
\dim_new:N \l__listsEX_item_indent_dim
\dim_new:N \l__listsEX_item_default_indent_dim
\dim_new:N \l__listsEX_item_width_dim
\dim_new:N \l__listsEX_label_width_dim
\dim_new:N \l__listsEX_label_default_width_dim
\dim_new:N \l__listsEX_label_offset_dim
\dim_new:N \l__listsEX_label_default_offset_dim
\dim_new:N \l__listsEX_column_sep_dim
\skip_new:N \l__listsEX_after_item_skip
\skip_new:N \l__listsEX_custom_after_item_skip
\skip_new:N \l__listsEX_before_list_skip
\skip_new:N \l__listsEX_after_list_skip
\coffin_new:N \l__listsEX_item_coffin
\coffin_new:N \l__listsEX_label_coffin
\NewCounterPattern* [ listsEX ] { listEX } { tsk }
\ReadCounterFrom [ listsEX ] { listEX } \g__listsEX_int
% temporary variables:
\int_new:N \l__listsEX_tmpa_int
\int_new:N \l__listsEX_tmpb_int
\tl_new:N \l__listsEX_tmpa_tl
\coffin_new:N \l__listsEX_tmpa_coffin
\cs_new:Npn \__listsEX_debug:n #1
{
\bool_if:NTF \l__listsEX_debug_bool
{ \fbox {#1} }
{ \use:n {#1} }
}
% --------------------------------------------------------------------------
% collect the listsEX:
\cs_new_protected:Npn \__listsEX_collect_listsEX:nww #1#2 \end #3
{
\tl_put_right:Nn \l__listsEX_body_tl {#1}
\end {#3}
\tl_if_eq:nnF {#1} {#3}
{ \__listsEX_collect_listsEX:nww {#1} }
}
% #1: instance
% #2: number of columns
% #3: item separator
% #4: environment body
\cs_new_protected:Npn \__listsEX:nnnn #1#2#3#4
{
\bool_if:NT \l__listsEX_debug_bool { \dim_set:Nn \fboxsep {0pt} }
\seq_set_split:Nnn \l__listsEX_seq {#3} {#4}
% remove the first (empty) item:
\seq_pop_left:NN \l__listsEX_seq \l__listsEX_tmpa_tl
\tl_if_blank:VF \l__listsEX_tmpa_tl { \@noitemerr }
\int_gset:Nn \g__listsEX_total_items_int
{ \seq_count:N \l__listsEX_seq }
\UseInstance {listsEX} {#1}
{ \g__listsEX_total_items_int }
{#2}
{ \l__listsEX_custom_label_pattern_tl }
% just to be sure:
\seq_clear:N \l__listsEX_seq
}
\cs_generate_variant:Nn \__listsEX:nnnn { VnnV }
% #1: label
% #2: item format
% #3: item
\cs_new_protected:Npn \__listsEX_listEX:nnn #1#2#3
{
% start a new item line if \l__listsEX_item_full_line_bool
\bool_if:NT \l__listsEX_item_full_line_bool
{
% add skip if we were in the middle of a line, i.e., in horizontal
% mode:
\mode_if_horizontal:T
{ \skip_vertical:N \l__listsEX_after_item_skip }
\listsEX_new_row:
}
% step column position:
\int_gincr:N \g__listsEX_current_col_num_int
\dim_set:Nn \l__listsEX_item_width_dim
{
\bool_if:NTF \l__listsEX_item_full_line_bool
{ \linewidth }
{
(
\linewidth
-\fboxsep
- \l__listsEX_columns_int \l__listsEX_column_sep_dim
+ \l__listsEX_column_sep_dim
) / \l__listsEX_columns_int
}
- \l__listsEX_depth_int \l__listsEX_item_indent_dim
\bool_if:NT \l__listsEX_debug_bool { -2\fboxrule }
}
\__listsEX_gset_rows_num:NN
\g__listsEX_total_items_int
\l__listsEX_columns_int
% set \g__listsEX_current_col_num_int to 1 if at the start of a row,
% then also step \g__listsEX_current_row_num_int :
\int_compare:nNnT
{ \g__listsEX_current_col_num_int } > { \l__listsEX_columns_int }
{
\int_gset:Nn \g__listsEX_current_col_num_int { 1 }
\int_incr:N \g__listsEX_current_row_num_int
}
\bool_if:NT \l__listsEX_item_rest_of_line_bool
{
\int_set:Nn \l__listsEX_tmpa_int
{ \l__listsEX_columns_int - \g__listsEX_current_col_num_int + 1 }
\int_compare:nNnTF { \l__listsEX_item_columns_int } = { 0 }
{
\int_set:Nn \l__listsEX_tmpb_int { \l__listsEX_tmpa_int - 1 } % 8
}
{
\int_compare:nNnTF
{ \l__listsEX_tmpa_int } > { \l__listsEX_item_columns_int }
{ \int_set_eq:NN \l__listsEX_tmpa_int \l__listsEX_item_columns_int }
{ \int_zero:N \l__listsEX_item_columns_int }
\bool_if:nT
{
\l__listsEX_item_rest_of_line_bool &&
!\int_compare_p:nNn { \l__listsEX_item_columns_int} = { 0 }
}
{
\int_gadd:Nn \g__listsEX_current_col_num_int
{ \l__listsEX_item_columns_int -1 }
\int_gadd:Nn \g__listsEX_total_items_int
{ \l__listsEX_item_columns_int -1 }
}
\int_set:Nn \l__listsEX_tmpb_int { \l__listsEX_tmpa_int -1 }
}
\dim_set:Nn \l__listsEX_item_width_dim
{
\l__listsEX_tmpa_int \l__listsEX_item_width_dim
+ \l__listsEX_tmpb_int \l__listsEX_column_sep_dim
+ \l__listsEX_tmpb_int \l__listsEX_item_indent_dim
\bool_if:NT \l__listsEX_debug_bool
{ + \int_eval:n { \l__listsEX_tmpb_int * 2 } \fboxrule }
}
}
% set the item box:
\hcoffin_set:Nn \l__listsEX_item_coffin
{
\vcoffin_set:Nnn \l__listsEX_tmpa_coffin
{ \l__listsEX_item_width_dim }
{ \__listsEX_setup: #2 {#3} \strut }
\__listsEX_debug:n
{
\coffin_typeset:Nnnnn \l__listsEX_tmpa_coffin
{l} {T} {0pt} {0pt}
}
}
% set the label box:
\hcoffin_set:Nn \l__listsEX_label_coffin
{
\vcoffin_set:Nnn \l__listsEX_tmpa_coffin
{
\l__listsEX_label_width_dim
\bool_if:NT \l__listsEX_debug_bool {-2\fboxrule }
}
{
\noindent
\tl_use:N \l__listsEX_item_fill_left_tl
\strut #1
\tl_use:N \l__listsEX_item_fill_right_tl
}
\__listsEX_debug:n
{
\coffin_typeset:Nnnnn \l__listsEX_tmpa_coffin
{l} {T} {0pt} {0pt}
}
}
% attach the label box at the left of the item box, shifted by
% \l__listsEX_label_offset_dim :
\coffin_attach:NnnNnnnn
\l__listsEX_item_coffin {l} {T}
\l__listsEX_label_coffin {l} {T}
{
\dim_compare:nNnTF
{ \l__listsEX_item_indent_dim }
<
{ \l__listsEX_label_offset_dim + \l__listsEX_label_width_dim }
{0pt}
{ - \l__listsEX_label_width_dim - \l__listsEX_label_offset_dim }
} { 0pt }
% when a new row starts enter vertical mode:
\int_compare:nNnT { \g__listsEX_current_col_num_int } = { 1 }
{ \skip_vertical:N \c_zero_skip }
% skip horizontally by \l__listsEX_item_indent_dim
\noindent
\skip_horizontal:N \l__listsEX_item_indent_dim
% typeset the item (with the attached label protruding to the left):
\coffin_typeset:Nnnnn \l__listsEX_item_coffin
{l}
{T}
{0pt}
{0pt}
\bool_if:nT
{
\l__listsEX_item_full_line_bool ||
(
\l__listsEX_item_rest_of_line_bool &&
\int_compare_p:nNn { \l__listsEX_item_columns_int } = { 0 }
)
}
{ \listsEX_new_row: }
% are we between items in a row? The skip by \l__listsEX_column_sep_dim :
\int_compare:nNnT
{ \g__listsEX_current_col_num_int } < { \l__listsEX_columns_int }
{ \skip_horizontal:N \l__listsEX_column_sep_dim }
% if we ended a row and a new row is still to come skip vertically by
% \l__listsEX_after_item_skip :
\bool_if:nT
{
( \int_compare_p:nNn { \g__listsEX_current_col_num_int } = { \l__listsEX_columns_int } )
&&
( \int_compare_p:n { \g__listsEX_current_row_num_int != \l__listsEX_rows_int } )
}
{ \skip_vertical:N \l__listsEX_after_item_skip }
% clean up:
\coffin_clear:N \l__listsEX_item_coffin
\coffin_clear:N \l__listsEX_label_coffin
\coffin_clear:N \l__listsEX_tmpa_coffin
\bool_set_false:N \l__listsEX_item_full_line_bool
\bool_set_false:N \l__listsEX_item_rest_of_line_bool
}
\cs_generate_variant:Nn \__listsEX_listEX:nnn { VVV }
\cs_new_protected:Npn \__listsEX_setup:
{
\dim_set:Nn \parskip { 0pt }
\skip_set:Nn \parfillskip { 0pt plus 1fil }
\dim_set_eq:NN \parskip \parsep
\dim_set_eq:NN \parindent \listparindent
\noindent
\dim_compare:nNnT
{ \l__listsEX_item_indent_dim }
<
{ \l__listsEX_label_offset_dim + \l__listsEX_label_width_dim }
{
\skip_horizontal:n
{
\l__listsEX_label_offset_dim
+ \l__listsEX_label_width_dim
- \l__listsEX_item_indent_dim
}
}
\strut
}
\cs_new_protected:Npn \__listsEX_gset_rows_num:NN #1#2
{
\int_gset:Nn \l__listsEX_rows_int { \int_div_truncate:nn {#1} {#2} }
\int_compare:nNnT { \int_mod:nn {#1} {#2} } > { 0 }
{ \int_gincr:N \l__listsEX_rows_int }
}
\cs_new_protected:Npn \__listsEX_label_align:n #1
{
\str_case:nnF {#1}
{
{left}
{
\tl_clear:N \l__listsEX_item_fill_left_tl
\tl_set_eq:NN \l__listsEX_item_fill_right_tl \hfill
}
{right}
{
\tl_set_eq:NN \l__listsEX_item_fill_left_tl \hfill
\tl_clear:N \l__listsEX_item_fill_right_tl
}
{center}
{
\tl_set_eq:NN \l__listsEX_item_fill_left_tl \hfill
\tl_set_eq:NN \l__listsEX_item_fill_right_tl \hfill
}
}
{
\tl_clear:N \l__listsEX_item_fill_left_tl
\tl_set_eq:NN \l__listsEX_item_fill_right_tl \hfill
}
}
\cs_generate_variant:Nn \__listsEX_label_align:n { V }
\__listsEX_label_align:n {left}
% --------------------------------------------------------------------------
% the `listsEX' object:
% #1: number of items
% #2: number of columns
% #3: label-format
\DeclareObjectType {listsEX} {3}
% the `default' template interface:
\DeclareTemplateInterface {listsEX} {default} {3}
{
enumerate : boolean = true ,
label : tokenlist ,
indent : length = 2.5em ,
counter-format : tokenlist = tsk[a]) ,
label-format : tokenlist ,
label-width : length = 1em ,
label-offset : length = .3333em ,
item-format : tokenlist ,
after-item-skip : skip = 1ex plus 1ex minus 1ex
}
% in the next three commands we want a really unlikely to occur marker; for
% this we use $ with unusual catcode in ``$listsEX$default$label$'':
\cs_set:Nx \__listsEX_restore_dollar:
{ \char_set_catcode:nn {36} { \char_value_catcode:n {36} } }
\char_set_catcode_alignment:N \$
% the `default' template code:
\DeclareTemplateCode {listsEX} {default} {3}
{
enumerate = \l__listsEX_enumerate_bool ,
label = \l__listsEX_label_tl ,
indent = \l__listsEX_item_default_indent_dim ,
counter-format = \l__listsEX_label_pattern_tl ,
label-format = \l__listsEX_label_format_tl ,
label-width = \l__listsEX_label_default_width_dim ,
label-offset = \l__listsEX_label_default_offset_dim ,
item-format = \l__listsEX_item_format_tl ,
after-item-skip = \l__listsEX_after_item_skip
}
{
\AssignTemplateKeys
\bool_if:NF \l__listsEX_label_width_bool
{
\dim_set_eq:NN
\l__listsEX_label_width_dim
\l__listsEX_label_default_width_dim
}
\bool_if:NF \l__listsEX_item_indent_bool
{
\dim_set_eq:NN
\l__listsEX_item_indent_dim
\l__listsEX_item_default_indent_dim
}
\bool_if:NF \l__listsEX_label_offset_bool
{
\dim_set_eq:NN
\l__listsEX_label_offset_dim
\l__listsEX_label_default_offset_dim
}
\bool_if:NT \l__listsEX_custom_after_item_skip_bool
{
\skip_set_eq:NN
\l__listsEX_after_item_skip
\l__listsEX_custom_after_item_skip
}
\bool_if:NT \l__listsEX_custom_label_bool
{
\tl_set_eq:NN
\l__listsEX_label_tl
\l__listsEX_custom_label_tl
\bool_set_false:N \l__listsEX_enumerate_bool
}
\__listsEX_label_align:V \l__listsEX_label_align_tl
% need this for enumerate list:
\bool_if:nT { !\l__listsEX_resume_bool && \l__listsEX_enumerate_bool }
{ \int_gzero:N \g__listsEX_int }
\int_set:Nn \l__listsEX_columns_int {#2}
% set all the items in their own coffins and join with the ground:
\int_gzero:N \g__listsEX_current_col_num_int
\int_set:Nn \g__listsEX_current_row_num_int {1}
\tl_if_blank:VF \l__listsEX_custom_label_pattern_tl
{
\tl_set_eq:NN
\l__listsEX_label_pattern_tl
\l__listsEX_custom_label_pattern_tl
}
\tl_if_blank:VF \l__listsEX_custom_label_format_tl
{
\tl_set_eq:NN
\l__listsEX_label_format_tl
\l__listsEX_custom_label_format_tl
}
\tl_if_blank:VF \l__listsEX_custom_item_format_tl
{
\tl_set_eq:NN
\l__listsEX_item_format_tl
\l__listsEX_custom_item_format_tl
}
\seq_map_inline:Nn \l__listsEX_seq
{
\__listsEX_read_item:www ##1 \q_stop
\bool_if:NTF \l__listsEX_enumerate_bool
{
\tl_if_eq:VnT \l__listsEX_tmp_label_tl { $listsEX$default$label$ }
{
\int_gincr:N \g__listsEX_int
\SaveCounterPatternFrom [listsEX]
\l__listsEX_tmpa_tl
\l__listsEX_label_tl
\l__listsEX_label_pattern_tl
}
}
{
\tl_if_blank:VT \l__listsEX_label_tl
{ \tl_set_eq:NN \l__listsEX_label_tl \labelitemi }
}
\tl_put_left:NV \l__listsEX_label_tl \l__listsEX_label_format_tl
% \tl_put_left:NV \l__listsEX_item_tl \l__listsEX_item_format_tl
\tl_if_eq:VnTF \l__listsEX_tmp_label_tl { $listsEX$default$label$ }
{
\__listsEX_listEX:VVV
\l__listsEX_label_tl
\l__listsEX_item_format_tl
\l__listsEX_item_tl
}
{
\__listsEX_listEX:VVV
\l__listsEX_tmp_label_tl
\l__listsEX_item_format_tl
\l__listsEX_item_tl
\tl_clear:N \l__listsEX_tmp_label_tl
}
}
}
\cs_new_protected:Npn \__listsEX_read_item:www
{
\peek_meaning_remove:NTF !
{
\bool_set_true:N \l__listsEX_item_full_line_bool
\__listsEX_read_item_aux:ww
}
{
\peek_meaning_remove:NTF *
{
\bool_set_true:N \l__listsEX_item_rest_of_line_bool
\__listsEX_read_item_rest_of_line:ww
}
{ \__listsEX_read_item_aux:ww }
}
}
\cs_new_protected:Npn \__listsEX_read_item_rest_of_line:ww
{
\peek_meaning:NTF ( % )
{ \__listsEX_read_item_rest_of_line_aux:ww }
{ \__listsEX_read_item_rest_of_line_aux:ww (0) }
}
\cs_new_protected:Npn \__listsEX_read_item_rest_of_line_aux:ww (#1)
{
\int_set:Nn \l__listsEX_item_columns_int {#1}
\__listsEX_read_item_aux:ww
}
\cs_new_protected:Npn \__listsEX_read_item_aux:ww
{
\peek_meaning:NTF [ % ]
{ \__listsEX_read_item_aux_ii:ww }
{ \__listsEX_read_item_aux_ii:ww [$listsEX$default$label$] }
}
\cs_new_protected:Npn \__listsEX_read_item_aux_ii:ww [#1]#2 \q_stop
{
\tl_set:Nn \l__listsEX_tmp_label_tl {#1}
\tl_if_eq:nnF { #1 } { $listsEX$default$label$ }
{ \tl_put_left:NV \l__listsEX_tmp_label_tl \l__listsEX_label_format_tl }
\tl_set:Nx \l__listsEX_item_tl { \tl_trim_spaces:n {#2} }
}
\__listsEX_restore_dollar:
% --------------------------------------------------------------------------
% choice box:
\bool_new:N \l__listsEX_choice_checked_bool
\dim_new:N \l__listsEX_choice_width_dim
\dim_set:Nn \l__listsEX_choice_width_dim { 1.25ex }
\dim_new:N \l__listsEX_choice_linewidth_dim
\dim_set:Nn \l__listsEX_choice_linewidth_dim { .3pt }
\dim_new:N \l__listsEX_choice_checkwidth_dim
\dim_set:Nn \l__listsEX_choice_checkwidth_dim { .5pt }
\dim_new:N \l__listsEX_choice_raise_dim
\dim_set:Nn \l__listsEX_choice_raise_dim { .1ex }
\cs_new_protected:Npn \listsEX_choice:
{
\leavevmode
\group_begin:
\bool_set_false:N \l__listsEX_choice_checked_bool
\box_move_up:nn
{ \l__listsEX_choice_raise_dim }
{ \hbox:n { \__listsEX_choice: } }
\group_end:
}
\cs_new_protected:Npn \listsEX_choice_checked:
{
\leavevmode
\group_begin:
\bool_set_true:N \l__listsEX_choice_checked_bool
\box_move_up:nn
{ \l__listsEX_choice_raise_dim }
{ \hbox:n { \__listsEX_choice: } }
\group_end:
}
\cs_new_protected:Npn \__listsEX_choice:
{%
\dim_set:Nn \unitlength { .1\l__listsEX_choice_width_dim }
\begin{picture}(10,0)
\linethickness \l__listsEX_choice_linewidth_dim
\drawline(0,0)(0,10)(10,10)(10,0)(0,0)
\linethickness \l__listsEX_choice_checkwidth_dim
\bool_if:NT \l__listsEX_choice_checked_bool
{
\drawline(2,2)(8,8)
\drawline(2,8)(8,2)
}
\end{picture}%
}
\providecommand* \choicebox { \listsEX_choice: }
\providecommand* \checkedchoicebox { \listsEX_choice_checked: }
% --------------------------------------------------------------------------
% base instance:
% ALPHABETIZE: a) b) c)
\DeclareInstance {listsEX} {alphabetize} {default} { }
\keys_define:nn {listsEX/list}
{
debug .bool_set:N = \l__listsEX_debug_bool ,
style .tl_set:N = \l__listsEX_instance_tl ,
style .initial:n = alphabetize ,
counter-format .tl_set:N = \l__listsEX_custom_label_pattern_tl ,
label .code:n =
\bool_set_true:N \l__listsEX_custom_label_bool
\tl_set:Nn \l__listsEX_custom_label_tl {#1} ,
label-format .tl_set:N = \l__listsEX_custom_label_format_tl ,
label-width .code:n =
\dim_set:Nn \l__listsEX_label_width_dim {#1}
\bool_set_true:N \l__listsEX_label_width_bool ,
label-offset .code:n =
\dim_set:Nn \l__listsEX_label_offset_dim {#1}
\bool_set_true:N \l__listsEX_label_offset_bool ,
label-align .tl_set:N = \l__listsEX_label_align_tl ,
item-format .tl_set:N = \l__listsEX_custom_item_format_tl ,
item-indent .code:n =
\dim_set:Nn \l__listsEX_item_indent_dim {#1}
\bool_set_true:N \l__listsEX_item_indent_bool ,
column-sep .dim_set:N = \l__listsEX_column_sep_dim ,
before-skip .skip_set:N = \l__listsEX_before_list_skip ,
after-skip .skip_set:N = \l__listsEX_after_list_skip ,
after-item-skip .code:n =
\bool_set_true:N \l__listsEX_custom_after_item_skip_bool
\skip_set:Nn \l__listsEX_custom_after_item_skip {#1} ,
resume .bool_set:N = \l__listsEX_resume_bool
}
% --------------------------------------------------------------------------
% the generic environment:
\NewEnviron {__listsEX_env:} [3]
{
\if@inlabel
\noindent\par\nobreak\vskip-\parskip\vskip-\baselineskip\hrule\@height\z@
\fi
\dim_compare:nNnF { \l__listsEX_before_list_skip } = { 0pt }
{ \vspace {\l__listsEX_before_list_skip} }
\list {}
{
\keys_set:nn {listsEX/list} {#2}
\dim_set:Nn \leftmargin {0pt}
\dim_set:Nn \rightmargin {0pt}
}
\item \scan_stop:
\int_incr:N \l__listsEX_depth_int
\__listsEX:VnnV \l__listsEX_instance_tl {#3} {#1} \BODY
\endlist
\dim_compare:nNnF { \l__listsEX_after_list_skip } = { 0pt }
{ \vspace {\l__listsEX_after_list_skip} }
}
% --------------------------------------------------------------------------
% command to start a new row:
\cs_new_protected:Npn \listsEX_new_row:
{
\int_gset:Nn \g__listsEX_total_items_int
{
\g__listsEX_total_items_int +
\l__listsEX_columns_int -
\g__listsEX_current_col_num_int
}
\__listsEX_gset_rows_num:NN
\g__listsEX_total_items_int
\l__listsEX_columns_int
\int_gset_eq:NN \g__listsEX_current_col_num_int \l__listsEX_columns_int
}
\NewDocumentCommand \startnewitemlineEX {}
{ \listsEX_new_row: }
% --------------------------------------------------------------------------
% the user environment:
\NewDocumentCommand \NewListsEX { O{}mO{\listEX}D(){1} }
{
\NewDocumentEnvironment {#2} { O{}D(){#4} }
{ \__listsEX_env: {#3} { #1,##1 } {##2} }
{ \end__listsEX_env: }
}
% --------------------------------------------------------------------------
% default list:
\NewListsEX {listsEX}
\file_if_exist:nT {listsEX.cfg} { \file_input:n {listsEX.cfg} }
% --------------------------------------------------------------------------
% setup:
\cs_new_protected:Npn \listsEX_setup:n #1
{ \keys_set:nn {listsEX/list} {#1} }
\NewDocumentCommand \setlistsEX { m }
{ \listsEX_setup:n {#1} }
\newcommand{\StartNumber}[1]{
\int_gset:Nn \g__listsEX_int {#1}
}
%tasks
\NewListsEX{taskEX}[\item]
\NewEnviron{listEX}[1][]{%
\ifstrempty{#1}{%
\begin{enumerate}%
\BODY%
\end{enumerate}%
}{%
\ifthenelse{\equal{#1}{1}}%
{%
\begin{enumerate}%
\BODY%
\end{enumerate}%
}%
{\def\tempbegin{\begin{taskEX}(#1)}%
\expandafter\tempbegin\BODY%
\end{taskEX}}%
}%
}
\NewEnviron{enumEX}[2][]{%
\ifthenelse{\equal{#2}{1}}
{
\ifstrempty{#1}
{
\begin{enumerate}
\BODY
\end{enumerate}
}
{
\begin{enumerate}[#1]
\BODY
\end{enumerate}}
}
{
\ifstrempty{#1}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[a])](#2)}%
}{%
\ifthenelse{\equal{#1}{a.}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[a].](#2)}%
}{
\ifthenelse{\equal{#1}{(a)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=(tsk[a]),label-width=1.3em](#2)}%
}{
\ifthenelse{\equal{#1}{a)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[a])](#2)}%
}{
\ifthenelse{\equal{#1}{A.}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[A].](#2)}%
}{
\ifthenelse{\equal{#1}{(A)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=(tsk[A]),label-width=1.3em](#2)}%
}{
\ifthenelse{\equal{#1}{A)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[A])](#2)}%
}{
\ifthenelse{\equal{#1}{1.}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[1].](#2)}%
}{
\ifthenelse{\equal{#1}{(1)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=(tsk[1]),label-width=1.3em](#2)}%
}{
\ifthenelse{\equal{#1}{1)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[1])](#2)}%
}{
\ifthenelse{\equal{#1}{i.}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[r].](#2)}%
}{
\ifthenelse{\equal{#1}{(i)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=(tsk[r]),label-width=1.4em](#2)}%
}{
\ifthenelse{\equal{#1}{i)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[r])](#2)}%
}{
\ifthenelse{\equal{#1}{I.}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[R].,label-width=1.4em](#2)}%
}{
\ifthenelse{\equal{#1}{(I)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=(tsk[R]),label-width=1.6em](#2)}%
}{
\ifthenelse{\equal{#1}{I)}}{%
\def\tempbegin{\begin{taskEX}[counter-format=tsk[R]),label-width=1.4em](#2)}%
}{
\def\tempbegin{\begin{taskEX}[label=#1](#2)}%
}}}}}}}}}}}}}}}
}
\expandafter\tempbegin\BODY
\end{taskEX}
}
}
\NewEnviron{enumEXV}[2][]{%
\ifstrempty{#1}
{
\begin{multicols}{#2}
\begin{enumerate}
\BODY
\end{enumerate}
\end{multicols}
}
{
\begin{multicols}{#2}
\begin{enumerate}[#1]
\BODY
\end{enumerate}
\end{multicols}
}%
}
%End of file `ex_test.sty'.
Tệp main.tex
\documentclass[11pt,a4paper]{article}
%\usepackage{eulervm}
%\usepackage{charter}
\usepackage[utf8]{vietnam}
\usepackage{amsmath,amssymb}
\usepackage{mathrsfs}
\usepackage{fancyhdr}
\usepackage{enumerate}
\usepackage{tikz,tkz-tab}
%\usepackage{tkz-euclide}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,calc,intersections,angles,patterns,shapes.geometric}
\usepackage[most]{tcolorbox}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.9}
\usepackage[top=1cm, bottom=1.5cm, left=1.5cm, right=1.5cm] {geometry}
\usepackage[hidelinks,unicode]{hyperref} %\usepackage[unicode, bookmarks=false]{hyperref}
\usepackage{currfile}
%\usepackage[loigiai]{ex_test}
% \renewcommand{\FalseEX}{\stepcounter{dapan}\textbf{\color{blue}\Alph{dapan}.}}
\usepackage[solcolor]{ex_test}
\renewcommand{\TrueEX}{\stepcounter{dapan}{\circled{\textbf{\Alph{dapan}}}}}
%Định nghĩa lại môi trường \nosolution ẩn lời giải.
\newcommand{\solutionhide}[1]{%
\def\True{\setcounter{numTrue}{\thedapan}\setcounter{numTrueSol}{\thedapan}}
\AtBeginEnvironment{#1}{%
\renewcommand{\loigiai}[1]{%
}}}
\newtcolorbox[auto counter]{boxEx}{
breakable,top=2.2mm,fonttitle=\bfseries,title={
\textbf{Câu} \thetcbcounter:},enhanced,before skip=5mm,after skip=5mm,boxsep=-1mm,boxrule=1pt,colframe=cyan,colback=cyan!5,sharp corners,rounded corners=southeast,arc=3mm,drop fuzzy shadow=cyan!50!gray,coltitle=blue,attach boxed title to top left={xshift=0mm,yshift=-\tcboxedtitleheight},boxed title style={interior empty,frame code={
\fill([xshift=-2mm]frame.north east)arc(180:0:1mm);
\fill[right color=cyan,left color=yellow,middle color=green!50] ([shift={(.3,.1)}]frame.north west)--([shift={(-.1,.1)}]frame.north east)[rounded corners=1mm]--([xshift=-2mm]frame.north east)--([xshift=-3mm]frame.south east)--([xshift=1mm]frame.south west)--([xshift=2mm]frame.north west)--cycle;
}}}
\def\beginbox{\begin{boxEx}}
\def\endbox{\end{boxEx}}
\newcommand{\solutionshow}[1]{%
\def\loigiaiEX{\centerline{\color{teal}Lời giải}}
\AtBeginEnvironment{#1}{%
\beginbox
\renewcommand{\loigiai}[1]{%
\endbox
\noindent
\begin{onlysolution}{\color{brown}##1}
\end{onlysolution}
}}}
\def\colorEX{}% màu phương án đúng
\renewtheorem{ex}{\color{blue}\textbf{Câu}}
\newcommand\gbox[1]{\noindent
\begin{tikzpicture}[gray,ultra thin]
\def\gw{1.77} \def\gh{.67}\def\gl{.3}\def\gt{.05}
\path(0,0)node[rectangle,draw=white,fill=white,inner sep=4pt] (box){\begin{minipage}{\textwidth}{#1}\end{minipage}};
\foreach\i in{0,...,10}\draw([shift={(\i*\gw+\gl,\gt)}]box.north west)--([shift={(\i*\gw+\gl,\gt-5*\gh)}]box.north west);
\foreach\i in{0,...,5}\draw([shift={(\gl,\gt-\i*\gh)}]box.north west)--([shift={(10*\gw+\gl,\gt-\i*\gh)}]box.north west);
\end{tikzpicture}
}
\newcommand{\boxanss}{
\renewenvironment{Solution}[1]
{\begin{minipage}{0.09\linewidth}\hfill{\color{blue}##1~-~}\color{purple}}{\end{minipage}}
}
\everymath{\displaystyle}
\usepackage{esvect}
\def\madethi{Mã đề thi: 000}
\def\vec{\overrightarrow}
\newcommand{\hoac}[1]{
\left[\begin{aligned}#1\end{aligned}\right.}
\newcommand{\heva}[1]{
\left\{\begin{aligned}#1\end{aligned}\right.}
\renewcommand{\baselinestretch}{1.4}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{\scriptsize ĐỀ CHÍNH THỨC 2022}
\rfoot{\scriptsize Trang \thepage/1\, --- \madethi }
\begin{document}
%%\centerline{\textbf{CÂU HỎI TRẮC NGHIỆM}}
%%\vspace{1em}
%%\solutionhide{ex}
%%\Opensolutionfile{ans}[ansde]
%%\input{cauhoi}
%%\Closesolutionfile{ans}
%%\centerline{\bf ------------ HẾT ------------}
%%\newpage
%%\setcounter{page}{1}
\lfoot{\scriptsize CÂU HỎI VÀ LỜI GIẢI CHI TIẾT}
\rfoot{\scriptsize Trang \thepage/1\, --- \madethi }
%%\centerline{\textbf{BẢNG KHOÁ CÂU TRẮC NGHIỆM}}
%%\gbox{\boxanss\begin{flushleft}{\bf\input{ansde}}\end{flushleft}}
\centerline{\textbf{ĐỀ VÀ LỜI GIẢI CHI TIẾT}}
\vspace{-1cm}
\solutionshow{ex}
\Opensolutionfile{ans}[ansda]
\input{cauhoi}
\Closesolutionfile{ans}
\end{document}