列挙内の 1 つの項目だけのインデントを削除するにはどうすればよいですか?

列挙内の 1 つの項目だけのインデントを削除するにはどうすればよいですか?

タイトルがほとんどすべてを説明しています。列挙をネストしています。また、特定の項目に関するコンテンツを書きたいので、列挙を中断してフレーム テキストを挿入しています。これには、パッケージframedとが必要ですenumitem。現在、これを生成できます。

ここに画像の説明を入力してください

最小限の動作例のコードは次のとおりです。

\documentclass[]{article}
\usepackage{framed}
\usepackage{enumitem}
\usepackage{color}

\begin{document}

  \begin{enumerate}
  \def\labelenumi{\arabic{enumi}.}
  \item First item
    \begin{enumerate}
    \def\labelenumii{\arabic{enumii}.}
    \item Another item
    \item Yet another foo item
    \end{enumerate} % TASK COMMENT SECTION
        \begin{framed}
            \textcolor{red}{This section be aligned to the left side of the box}
        \end{framed}
    \begin{enumerate}[resume]
    \def\labelenumii{\arabic{enumii}.}
    \item Foo item
    \end{enumerate}
      \begin{framed}
          \textcolor{red}{This section should also be aligned to the left side of the box.}
      \end{framed}
    \begin{enumerate}[resume]
    \def\labelenumii{\arabic{enumii}.}
    \item Foo foo item
    \item Bar item

    \begin{enumerate}
    \def\labelenumiii{\arabic{enumiii}.}
    \item Nested item
    \item Second nested item
    \end{enumerate}

      \begin{framed} % TASK COMMENT SECTION
      \noindent
          Bla bla to explain the reasons of this enumerations.\\
          \textcolor{red}{EVERYTHING ON THIS BOX SHOULD HAVE A NORMAL LEFT ALIGNMENT.}\\
          \underline{Mock title}
          \begin{itemize}
            \item A deeply embedded foo
            \item Another deeply embedded foo
          \end{itemize}
          \underline{Gosh, no more mock titles please!}
          \begin{itemize}
           \item Bored foo
           \item Yet another bored foo
          \end{itemize}
            \underline{Shameful copy of the last enum}
          \begin{itemize}
           \item Bored foo
           \item Yet another bored foo
          \end{itemize}
      \end{framed}
      \begin{enumerate}[resume]
      \def\labelenumiii{\arabic{enumiii}.}

      \item Almost finished
      \item Finished
      \end{enumerate}
    \item Oh, not yet??
    \item At the end
    \end{enumerate}

    \begin{framed} % TASK COMMENT SECTION
        I promise this is the last box \textcolor{red}{THAT SHOULD BE ALIGNED TO THE LEFT!}
    \end{framed}

    \begin{enumerate}[resume]
    \def\labelenumiii{\arabic{enumiii}.}

    \item This one is not well numbered because I got lost in the freakish nesting of enums, but you get the idea.
    \end{enumerate}

  \end{enumerate}

\end{document}

フレーム内のテキストはインデントされていますが、これはenumerateセクションの項目に期待されるインデントになっているのではないかと思います。

  1. フレームが配置されているアイテムのインデントを削除するにはどうすればよいですか?
  2. 列挙体の単一項目のインデントを回避することは可能ですか?

答え1

更新された質問に対する解決策は次のとおりです (私の考えでは)。listcomment環境を定義します。オプションの引数として、現在のリスト レベルと の差を 1 つ指定しますfirst level。デフォルトは です1。 コマンドを使用して、コードを簡素化する機会を得ました\setlist

\documentclass[]{article}
\usepackage[showframe]{geometry}
\usepackage{framed}
\setlength{\FrameSep}{0.5em}
\usepackage{enumitem}

\setlist[enumerate]{label =\arabic*., wide =0pt, leftmargin = *}
\setlist[enumerate, 1]{label =\arabic*., wide, leftmargin = *}
\usepackage{color}
\usepackage{changepage}
\newenvironment{listcomment}[1][1]{\framed\adjustwidth{-\dimexpr #1\leftmargin + \fontdimen2\font}{}}{\endadjustwidth\endframed}

\begin{document}

  \begin{enumerate}
  \item First item\\
    Firstitem
    \begin{enumerate}
    \item Another item
    \item Yet another foo item
    \end{enumerate} % TASK COMMENT SECTION
        \begin{listcomment}
        \color{red} This section should be aligned to the left side of the box. This section should be aligned to the a left side of the box.
        \end{listcomment}
    \begin{enumerate}[resume]
    \item Foo item
    \end{enumerate}
      \begin{listcomment}
       \color{red} This section should also be aligned to the left side of the box.
      \end{listcomment}
    \begin{enumerate}[resume]
    \item Foo foo item
    \item Bar item

    \begin{enumerate}
    \item Nested item
    \item Second nested item
    \end{enumerate}

      \begin{listcomment}[2] % TASK COMMENT SECTION
      \noindent
          Bla bla to explain the reasons of this enumerations.\\
          \textcolor{red}{EVERYTHING ON THIS BOX SHOULD HAVE A NORMAL LEFT ALIGNMENT.}\\
          \underline{Mock title}
          \begin{itemize}
            \item A deeply embedded foo
            \item Another deeply embedded foo
          \end{itemize}
          \underline{Gosh, no more mock titles please!}
          \begin{itemize}
           \item Bored foo
           \item Yet another bored foo
          \end{itemize}
            \underline{Shameful copy of the last enum}
          \begin{itemize}
           \item Bored foo
           \item Yet another bored foo
          \end{itemize}
      \end{listcomment}
      \begin{enumerate}[resume]

      \item Almost finished
      \item Finished
      \end{enumerate}
    \item Oh, not yet??
    \item At the end
    \end{enumerate}

    \begin{listcomment} % TASK COMMENT SECTION
        I promise this is the last box \textcolor{red}{THAT SHOULD BE ALIGNED TO THE LEFT!}
    \end{listcomment}

    \begin{enumerate}[resume]
    \item This one is not well numbered because I got lost in the freakish nesting of enums, but you get the idea.
    \end{enumerate}

  \end{enumerate}

\end{document} 

ここに画像の説明を入力してください

関連情報