列表中的垂直对齐

列表中的垂直对齐

我想对齐enumerate以下列表中的复选框:

\documentclass{article}
\begin{document}

\begin{enumerate}
\item mbood \hspace{0.2cm} \framebox(10,10){}
\item frall \hspace{0.5cm} \framebox(10,10){}
\item coofp \hspace{0.5cm} \framebox(10,10){}
\item ktleem    \hspace{0.2cm} \framebox(10,10){}
\item sproke    \hspace{0.2cm} \framebox(10,10){}
\item flube     \hspace{0.2cm} \framebox(10,10){}
\item sglop \hspace{0.2cm} \framebox(10,10){}
\item blick     \hspace{0.2cm} \framebox(10,10){}
\item bnick \hspace{0.2cm} \framebox(10,10){}
\item strock    \hspace{0.2cm} \framebox(10,10){}
\end{enumerate}

\end{document}

我尝试使用该\hspace{}命令,但我想知道是否有更快的方法来执行此操作。谢谢!

enter image description here

答案1

\parbox在您的物品周围使用并\hfill包含:

\begin{enumerate}
\item \parbox{.5\textwidth}{mbood \hfill \framebox(10,10){}}
\item \parbox{.5\textwidth}{frall \hfill \framebox(10,10){}}
\item \parbox{.5\textwidth}{coofp \hfill \framebox(10,10){}}
\item \parbox{.5\textwidth}{ktleem    \hfill \framebox(10,10){}}
\item \parbox{.5\textwidth}{sproke    \hfill \framebox(10,10){}}
%% ...
\end{enumerate}

现在文本看起来不再与列表的数字对齐了......

然后从内到外尝试一下:

\parbox{.5\textwidth}{%
   \begin{enumerate}
    \item mbood\hfill \framebox(10,10){}
    \item frall\hfill \framebox(10,10){}
    \item coofp\hfill \framebox(10,10){}
    \item ktleem\hfill \framebox(10,10){}
    \item sproke\hfill \framebox(10,10){}
    %% ...
    \end{enumerate}%
}

答案2

一种可能的解决方案是在表格环境中使用自动编号和对齐。

longtable如果分页是一个问题,请使用环境!

\documentclass{article}
\usepackage{array}
\newcounter{linecounter}
\newcolumntype{N}{>{\refstepcounter{linecounter}\thelinecounter.}r}
\newcolumntype{B}{>{\framebox(10,10){}}c}
\begin{document}

\begin{tabular}{NlB}
  & mbood  & \tabularnewline
  & frall  & \tabularnewline
  & coofp  & \tabularnewline
  & ktleem     & \tabularnewline
  & sproke     & \tabularnewline
  & flube      & \tabularnewline
  & sglop &  \tabularnewline
  & blick      & \tabularnewline
  & bnick &  \tabularnewline
  & strock     & \tabularnewline
\end{tabular}

\end{document}

enter image description here

答案3

我认为,综合考虑所有因素,以下是简单性和有效性之间的良好权衡:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\newcommand*{\robertitem}[1]{%
    \item\relax % "\relax" not really needed, but I'm neurotic!
    \makebox[.5\linewidth][l]{#1\hfill \framebox(10,10)}%
}



\begin{document}

Some text here, just for the purpose of showing where the prevailing text 
margins lie.
\begin{enumerate}
    \robertitem{Mrs. Dalloway}
    \robertitem{Said}
    \robertitem{She would buy}
    \robertitem{The flowers}
    \robertitem{Herself}
\end{enumerate}
(Please note that I~am quoting from memory.)

\end{document}

输出:

output of the code

相关内容