exam-minipage:在标题内使用 minipage

exam-minipage:在标题内使用 minipage

跟进我之前的问题[12]相反,我尝试使用minipage环境,以便能够自由地断线并使用exam宏(例如\numquestions),而使用盒子时则无法做到这一点。

但是,还有一些问题需要解决:

1-对于第一行,我如何分别控制所有三个规则之间的顶部和底部间隔minipages以及顶部和底部规则?此外,为什么顶部间隔比底部间隔小得多?

2-在第二行,如何使 mdframed-box 紧密地放置在水平规则之间,而没有顶部和底部的空白?

3- 在第三行中,为什么小页面倾斜且放置不正确,尽管它们的总宽度加起来为\textwidth,并且位置选项设置为是吗?虽然当我稍微减小这两个小页面的宽度并尝试其他小页面时,它们又会垂直对齐,这对我来说没有意义。同样,我需要一种方法来控制相邻水平规则的顶部和底部分离。

\documentclass[
addpoints,
]{exam}
\usepackage[]{geometry}
\usepackage{lipsum,graphbox,mdframed,array,ragged2e,booktabs,fmtcount,multicol,multirow,tabularx,cellspace,calc}
\usepackage[thinlines]{easytable}

\usepackage[table]{xcolor}
\usepackage[export]{adjustbox}

\pagestyle{headandfoot}

\extraheadheight{7cm}

\firstpageheader%
{}%
{%
    \rule{\textwidth}{0.5pt}
    \begin{minipage}[b][2cm][b]{0.33\linewidth}
        \flushleft
        left\\next left
    \end{minipage}%
    \begin{minipage}[b][2cm][b]{0.34\linewidth}
        \centering
        \includegraphics[height=2cm]{example-image}
    \end{minipage}%
    \begin{minipage}[b][2cm][b]{0.33\linewidth}
        \flushright
        right
    \end{minipage}
    %
    \rule{\textwidth}{0.4pt}
    %
    \begin{mdframed}[backgroundcolor=gray]
        \centering
        some text
    \end{mdframed}
    %
    \rule{\textwidth}{0.4pt}
    %
    \begin{minipage}[b][2cm][c]{0.5\linewidth}
        \flushleft
        text
    \end{minipage}%
    \begin{minipage}[t][2cm][c]{0.5\linewidth}
        \flushright
        \includegraphics[height=2cm]{example-image}
    \end{minipage}
    \rule{\textwidth}{0.4pt}
}%
{}


\begin{document}
    \setlength{\parindent}{0cm}
    \begin{questions}
        \question some question
        \question some question
    \end{questions}
\end{document}

在此处输入图片描述

答案1

我修改了代码,将 mdframed 框替换为 tcolorbox 框,最终使其可以工作。

\documentclass[
addpoints,
]{exam}
\usepackage[]{geometry}
\usepackage{lipsum,graphbox,mdframed,array,ragged2e,booktabs,fmtcount,multicol,multirow,tabularx,cellspace,calc,tcolorbox,etoolbox}

\makeatletter
\let\NAMEquestions\numquestions
\patchcmd{\NAMEquestions}{\exam@numquestions}{{\NUMBERstringnum\exam@numquestions}}{}{}
\let\NAMEpages\numpages
\patchcmd{\NAMEpages}{\exam@lastpage}{{\NUMBERstringnum\exam@lastpage}}{}{}
\let\NAMEpoints\numpoints
\patchcmd{\NAMEpoints}{\exam@numpoints}{{\NUMBERstringnum\exam@numpoints}}{}{}
\makeatother

%\usepackage[table]{xcolor}
\usepackage[export]{adjustbox}

\pagestyle{headandfoot}

\extraheadheight{7cm}

\firstpageheader%
{}%
{%
    \begin{minipage}[t][2cm][b]{0.5\textwidth}
        first\\ second\\ third
    \end{minipage}%
    \begin{minipage}[t][2cm][b]{0.5\textwidth}
        \flushright \includegraphics[scale=0.2]{example-image}
    \end{minipage}%
    \vspace{2pt}
    \hrule%\vspace{5pt}
    \begin{minipage}[b][5mm][c]{0.33\textwidth}
        Semester
    \end{minipage}%
    \begin{minipage}[b][5mm][c]{0.34\textwidth}
        \centering Code
    \end{minipage}%
    \begin{minipage}[b][5mm][c]{0.33\textwidth}
        \flushright Time: 3.00 Hrs.
    \end{minipage}
    %
    \hrule
    %
    \begin{tcolorbox}[width=\textwidth,boxrule=0pt,arc=0pt,top=0mm,bottom=0mm,boxsep=5pt,colback=gray!20]
        \centering Long text
    \end{tcolorbox}
    %
    \hrule\vspace{2pt}
    %
    \begin{minipage}[b][10mm][c]{0.8\textwidth}
        This exam contains \textbf{\NAMEquestions\ questions}  in 
        \textbf{\NAMEpages\ pages}  (including this cover).\\
        The total marks are \textbf{\NAMEpoints}.
    \end{minipage}%
    \begin{minipage}[b][10mm][c]{0.2\textwidth}
        \flushright \thepage/\numpages
    \end{minipage}
    \hrule
}%
{}

\begin{document}
    \setlength{\parindent}{0cm}
    \begin{questions}
        \question some question
        \question some question
        \lipsum[1-8]
    \end{questions}
\end{document}

在此处输入图片描述

相关内容