修复列表问题

修复列表问题

让我们考虑以下 MWE:

\documentclass[letterpaper]{article}
\usepackage[marginparwidth=2in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{calc}
\usepackage{marginnote}
\usepackage{enumitem}

\newenvironment{test}[1][3.8ex]{%
\renewcommand{\theenumi}{\alph{enumi}}%
\renewcommand{\labelenumi}{\theenumi)}%
\renewcommand{\theenumii}{\roman{enumii}}%
\renewcommand{\labelenumii}{\theenumii)}%
\renewcommand{\marginparsep}{1em}%
\marginnote{List}[#1]%
  \list{}{%
  \setlength{\leftmargin}{0pt}%
  \setlength{\rightmargin}{0pt}%
  \setlength{\parfillskip}{0pt plus 2fil}%
  \setlength{\itemsep}{0pt}%
  \setlength{\topsep}{1ex}%
  \setlength{\partopsep}{0ex}
  \setlength{\parskip}{0pt}%
  \item\relax%
  }%
}{
  \endlist\ignorespacesafterend}

\reversemarginpar
\setlength{\parindent}{0pt}
\begin{document}    
     \begin{test}%
     Some random text
        \begin{enumerate}
        \item To answer the first part, we are going to find $A \cup B $ followed by the intersection of this with set $C$. Thus,
        \[(A \cup B ) \cap C =\{1,2,3,4,5,6,8\} \cap \{4,5,7\}= \{4,5\}\]
        \item In the second part, we will first find $B \cap C$ followed by the union of this with set $A$. Hence,
            \[A \cup (B \cap C)=\{1,2,3,4\} \cup \{5\} =\{1,2,3,4,5\}\]
        \end{enumerate}
        \end{test}
\end{document}

在此处输入图片描述

如果您注意到,枚举没有与边注水平对齐。如何实现这一点?对上述代码的任何改进都将不胜感激。我的方法是将topsep可能改为0ex但这还不够。A\vspace{<length>}是我的最后手段,但似乎太明显了。有几个问题:

  1. 环境。我知道它不是最好的,但至少它可以编译
  2. 用来[3.8ex]调整边注。不明白为什么它不能自然发生,如果可以,该如何补救。
  3. 出现在 的a地方b

我正在尝试创建一个示例\解决方案环境。

答案1

要制作 MWE,您需要剪掉保留问题的部分,这里是标签的叠印。您可以删除marginparenumitem开始:

在此处输入图片描述

\documentclass[letterpaper]{article}

\newenvironment{test}[1][3.8ex]{%
  \list{}{%
  \item\relax
  }%
}{%
  \endlist\ignorespacesafterend}

\begin{document}    
     \begin{test}%
     Some random text
        \begin{enumerate}
        \item To answer 
        \item In the 
        \end{enumerate}
        \end{test}
\end{document}

问题出在哪里(终于:-)一目了然:\item在错误的地方。它应该在列表环境的主体中,而不是在其参数中。

在此处输入图片描述

\documentclass[letterpaper]{article}

\newenvironment{test}[1][3.8ex]{%
  \list{}{%
  }%
  \item\relax
}{%
  \endlist\ignorespacesafterend}

\begin{document}    
     \begin{test}%
     Some random text
        \begin{enumerate}
        \item To answer 
        \item In the 
        \end{enumerate}
        \end{test}
\end{document}

将其放回并固定为不\marginparsep设置边注后,现在可以将其放置在(空)物品标签上,以便自然对齐而不需要任何偏移。\setlength\renewcommand

在此处输入图片描述

\documentclass[letterpaper]{article}
\usepackage[marginparwidth=2in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{calc}
\usepackage{marginnote}
\usepackage{enumitem}

\newenvironment{test}{%
\renewcommand{\theenumi}{\alph{enumi}}%
\renewcommand{\labelenumi}{\theenumi)}%
\renewcommand{\theenumii}{\roman{enumii}}%
\renewcommand{\labelenumii}{\theenumii)}%
\setlength{\marginparsep}{1em}%
  \list{}{%
  \setlength{\leftmargin}{0pt}%
  \setlength{\rightmargin}{0pt}%
  \setlength{\parfillskip}{0pt plus 2fil}%
  \setlength{\itemsep}{0pt}%
  \setlength{\topsep}{1ex}%
  \setlength{\partopsep}{0ex}
  \setlength{\parskip}{0pt}%
  }%
  \item\relax\leavevmode\marginnote{List}\ignorespaces
}{
  \endlist\ignorespacesafterend}

\reversemarginpar
\setlength{\parindent}{0pt}
\begin{document}    
     \begin{test}%
     Some random text
        \begin{enumerate}
        \item To answer the first part, we are going to find $A \cup B $ followed by the intersection of this with set $C$. Thus,
        \[(A \cup B ) \cap C =\{1,2,3,4,5,6,8\} \cap \{4,5,7\}= \{4,5\}\]
        \item In the second part, we will first find $B \cap C$ followed by the union of this with set $A$. Hence,
            \[A \cup (B \cap C)=\{1,2,3,4\} \cup \{5\} =\{1,2,3,4,5\}\]
        \end{enumerate}
        \end{test}
\end{document}

相关内容