考试类别枚举中的缩进

考试类别枚举中的缩进

我正在使用考试文档类。在我的解决方案中,我使用的是枚举环境。但是,每个项目中的新行未与该项目的第一行对齐(请参阅下面的项目 1)。如何使用 enumitem 包来处理此对齐问题?我想将项目标签(1.、2. 等)保持在原位;我只想将每个项目中的任何其他行与该项目的第一行对齐。

\documentclass[answers]{exam}
\usepackage{amsmath, amssymb, amsfonts, amstext}
\usepackage{enumitem}
\usepackage{xpatch} % for horizontal spacing between choices in multiple-choice problems

\xpatchcmd{\oneparchoices}{\penalty -50\hskip 1em plus 1em\relax}{\qquad}{}{} % for multiple-choice problems 

%%%%%%%%%%%%%%%%%%%%%%%
%http://tex.stackexchange.com/questions/278345/changing-indent-after-question-exam-class
%
% Make question numbers align to the left margin
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}

% Change margins for choices and parts
\renewcommand{\partshook}{%
\setlength{\leftmargin}{1.2cm}%
%\setlength{\labelwidth}{0pt}%
\renewcommand\makelabel[1]{\rlap{##1}\hss}%
}
%%%%%%%%%%%%%%%%%%%%%%%

\parindent=0pt


\begin{document}
\begin{questions}
\question
Problem here.
\begin{solution}
Some text.
\begin{enumerate}
\item \textsc{First Step}

Here is stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. 


\item \textsc{Second Step}

Here is a stuff. 
\end{enumerate}
\end{solution}
\end{questions}
\end{document}

在此处输入图片描述

答案1

您可以使用calc包和

\begin{enumerate}[leftmargin=\leftmargin+\labelsep, itemindent=-\labelsep]

这会使整个项目向右缩进所需的量(\labelsep),然后将第一行向左移动相同的量以获得所需的效果(即,标签在默认位置,其余行从第一行文本开始的位置开始)。

\documentclass[answers]{exam}
\usepackage{amsmath, amssymb, amsfonts, amstext}
\usepackage{enumitem}
\usepackage{xpatch} % for horizontal spacing between choices in multiple-choice problems
\usepackage{calc}

\xpatchcmd{\oneparchoices}{\penalty -50\hskip 1em plus 1em\relax}{\qquad}{}{} % for multiple-choice problems 

%%%%%%%%%%%%%%%%%%%%%%%
%http://tex.stackexchange.com/questions/278345/changing-indent-after-question-exam-class
%
% Make question numbers align to the left margin
\renewcommand{\questionshook}{%
    \setlength{\leftmargin}{0pt}%
    \setlength{\labelwidth}{-\labelsep}%
}

% Change margins for choices and parts
\renewcommand{\partshook}{%
    \setlength{\leftmargin}{1.2cm}%
    %\setlength{\labelwidth}{0pt}%
    \renewcommand\makelabel[1]{\rlap{##1}\hss}%
}
%%%%%%%%%%%%%%%%%%%%%%%

\parindent=0pt


\begin{document}
    \begin{questions}
        \question
        Problem here.
        \begin{solution}
            Some text.
            \begin{enumerate}[leftmargin=\leftmargin+\labelsep, itemindent=-\labelsep]
                \item \textsc{First Step}

                Here is stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. 


                \item \textsc{Second Step}

                Here is a stuff. 
            \end{enumerate}

        \end{solution}
    \end{questions}
\end{document}

在此处输入图片描述

答案2

问题是由于您\questionshook重新定义了 而引起的labelwidth。您可以通过添加

\setlist[enumerate]{labelwidth=*}

有了这个,你就会得到(我认为)你想要的: 在此处输入图片描述

完整代码如下:

\documentclass[answers]{exam}
\usepackage{amsmath, amssymb, amsfonts, amstext}
\usepackage{enumitem}
\usepackage{xpatch} % for horizontal spacing between choices in multiple-choice problems

\xpatchcmd{\oneparchoices}{\penalty -50\hskip 1em plus 1em\relax}{\qquad}{}{} % for multiple-choice problems

\parindent=0pt

\setlist[enumerate]{labelwidth=*}
\renewcommand{\questionshook}{%
  \setlength{\leftmargin}{0pt}%
  \setlength{\labelwidth}{-\labelsep}%
}
% Change margins for choices and parts
\renewcommand{\partshook}{%
  \setlength{\leftmargin}{1.2cm}%
  %\setlength{\labelwidth}{0pt}%
  \renewcommand\makelabel[1]{\rlap{##1}\hss}%
}

\begin{document}
\begin{questions}
\question
Problem here.
\begin{solution}
Some text.
\begin{enumerate}[labelwidth=*]
\item \textsc{First Step}

  Here is stuff. Here is a stuff. Here is a stuff. Here is a stuff.
  Here is a stuff. Here is a stuff. Here is a stuff. Here is a
  stuff. Here is a stuff.


\item \textsc{Second Step}

Here is a stuff.
\end{enumerate}
\end{solution}
\end{questions}
\end{document}

相关内容