fbox 内小页面右对齐

fbox 内小页面右对齐

我将 fbox 与 minipage 一起使用,在 minipage 中我有 multicols 和 enumerate 环境。这不是什么大问题,但我注意到框没有在右侧对齐。我尝试使用 \linewidth 而不是 \textwidth,但仍然得到相同的结果。关于如何将框在左侧和右侧对齐,有什么想法或建议吗?

以下是 MWE。

\documentclass[a4paper]{exam}
\usepackage{multicol}

\begin{document}
\small
\subsection*{Answer sheet}
\noindent\textsc{Name:} $\rule{2.9in}{0.15mm}$\hfill\textsc{Student Number:} $\rule{1.5in}{0.15mm}$
\vspace{2mm}
\\
\noindent\textsc{Instructor:} $\rule{2.6in}{0.15mm} $\hfill\textsc{Class Section: }$\rule{1.5in}{0.15mm}$
\normalsize
\newline \\
\fbox{
\begin{minipage}{0.5\textwidth}
\vspace{1mm}
\textbf{Part 1. Matching type.}
\begin{multicols}{2}
\begin{enumerate}
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item
\end{enumerate}
\end{multicols}
\vspace{1mm}
\end{minipage}}%
\fbox{
\begin{minipage}{0.5\textwidth}
\vspace{1mm}
\textbf{Part 2. True or False.}
\begin{multicols}{2}
\begin{enumerate}
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item    
\end{enumerate}    
\end{multicols}
\vspace{1mm}
\end{minipage}}
\newline
\fbox{
\begin{minipage}{1.0\textwidth}
\vspace{1mm}
\textbf{Part 3. Multiple Choice.}
\begin{multicols}{3}
\begin{enumerate}
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item 
    \item      
\end{enumerate}    
\end{multicols}
\vspace{1mm}
\end{minipage}}
\newline
\fbox{
\begin{minipage}{1.0\textwidth}
\vspace{1mm}
\textbf{Part 4. Problem 1. Fill in the blanks.}
\begin{enumerate}
    \item [(a)] 
    \item [(b)]
    \item [(c)] 
    \item [(d)]
    \item [(e)] 
\end{enumerate}
\vspace{1mm}
\end{minipage}
}
\newline
\fbox{
\begin{minipage}{1.0\textwidth}
\vspace{1mm}
\textbf{Part 4. Problem 2. Fill in the blanks.}
\begin{enumerate}
    \item [(a)]   
    \item [(b)] 
    \item [(c)] 
    \item [(d)] 
    \item [(e)]
    \item [(f)] 
\end{enumerate}
\vspace{1mm}
\end{minipage}
}
\end{document}

答案1

  • 迷你页面宽度太大。在定义它们时,您应该考虑\fboxsep\fboxrule相应地减少它们的宽度-
  • 代码行(在 MWE 中以 标记<---)在 的末尾\end{minipage}}应该以\end{minipage}}\fbox{终止。%

考虑到上述情况,你的 MWE 应该是:

\documentclass[a4paper]{exam}
\usepackage{multicol}

\begin{document}
\small
\subsection*{Answer sheet}
\noindent\textsc{Name:} $\rule{2.9in}{0.15mm}$\hfill\textsc{Student Number:} $\rule{1.5in}{0.15mm}$
\vspace{2mm}
\\
\noindent\textsc{Instructor:} $\rule{2.6in}{0.15mm} $\hfill\textsc{Class Section: }$\rule{1.5in}{0.15mm}$
\normalsize
\newline \\
\fbox{%
\begin{minipage}{\dimexpr0.5\textwidth-2\fboxsep-2\fboxrule}
\vspace{1mm}
\textbf{Part 1. Matching type.}
\begin{multicols}{2}
\begin{enumerate}
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
\end{enumerate}
\end{multicols}
\vspace{1mm}
\end{minipage}}%    <---
\fbox{%             <---
\begin{minipage}{\dimexpr0.5\textwidth-2\fboxsep-2\fboxrule} %    <---
\vspace{1mm}
\textbf{Part 2. True or False.}
\begin{multicols}{2}
\begin{enumerate}
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
\end{enumerate}
\end{multicols}
\vspace{1mm}
\end{minipage}}%    <---
\newline
\fbox{%             <---
\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule}%    <---
\vspace{1mm}
\textbf{Part 3. Multiple Choice.}
\begin{multicols}{3}
\begin{enumerate}
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
\end{enumerate}
\end{multicols}
\vspace{1mm}
\end{minipage}}%    <---
\newline
\fbox{%             <---
\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule}%    <---
\vspace{1mm}
\textbf{Part 4. Problem 1. Fill in the blanks.}
\begin{enumerate}
    \item [(a)]
    \item [(b)]
    \item [(c)]
    \item [(d)]
    \item [(e)]
\end{enumerate}
\vspace{1mm}
\end{minipage}}%    <---
\newline
\fbox{%             <---
\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule}%    <---
\vspace{1mm}
\textbf{Part 4. Problem 2. Fill in the blanks.}
\begin{enumerate}
    \item [(a)]
    \item [(b)]
    \item [(c)]
    \item [(d)]
    \item [(e)]
    \item [(f)]
\end{enumerate}
\vspace{1mm}
\end{minipage}}
\end{document}

在此处输入图片描述

答案2

这不是专家解决方案,只是反复试验的解决方案:

在此处输入图片描述

代码(对建议的代码做了一些修改):

\documentclass[a4paper]{exam}
\usepackage{multicol}

\begin{document}
    \small
    \subsection*{Answer sheet}
    \noindent\textsc{Name:} $\rule{2.9in}{0.15mm}$\hfill\textsc{Student Number:} $\rule{1.5in}{0.15mm}$
    \vspace{2mm}
    \\
    \noindent\textsc{Instructor:} $\rule{2.6in}{0.15mm} $\hfill\textsc{Class Section: }$\rule{1.5in}{0.15mm}$
    \normalsize
    \newline \\
    \fbox{
        \begin{minipage}{7.98cm}
            \vspace{1mm}
            \textbf{Part 1. Matching type.}
            \begin{multicols}{2}
                \begin{enumerate}
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item
                \end{enumerate}
            \end{multicols}
            \vspace{1mm}
    \end{minipage}}%
    \fbox{
        \begin{minipage}{7.98cm}
            \vspace{1mm}
            \textbf{Part 2. True or False.}
            \begin{multicols}{2}
                \begin{enumerate}
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item    
                \end{enumerate}    
            \end{multicols}
            \vspace{1mm}
    \end{minipage}}
    \newline
    \fbox{
        \begin{minipage}{16.31 cm}
            \vspace{1mm}
            \textbf{Part 3. Multiple Choice.}
            \begin{multicols}{3}
                \begin{enumerate}
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item 
                    \item      
                \end{enumerate}    
            \end{multicols}
            \vspace{1mm}
    \end{minipage}}
    \newline
    \fbox{
        \begin{minipage}{16.2cm}
            \vspace{1mm}
            \textbf{Part 4. Problem 1. Fill in the blanks.}
            \begin{enumerate}
                \item [(a)] 
                \item [(b)]
                \item [(c)] 
                \item [(d)]
                \item [(e)] 
            \end{enumerate}
            \vspace{1mm}
        \end{minipage}
    }
    \newline
    \fbox{
        \begin{minipage}{16.2cm}
            \vspace{1mm}
            \textbf{Part 4. Problem 2. Fill in the blanks.}
            \begin{enumerate}
                \item [(a)]   
                \item [(b)] 
                \item [(c)] 
                \item [(d)] 
                \item [(e)]
                \item [(f)] 
            \end{enumerate}
            \vspace{1mm}
        \end{minipage}
    }
\end{document}

相关内容