제목이 거의 모든 것을 설명합니다. 열거형을 중첩하고 있습니다. 또한 특정 항목에 대한 내용을 작성하고 싶기 때문에 열거형을 중단하여 프레임된 텍스트를 삽입합니다. 이를 위해서는 패키지 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
업데이트된 질문에 대한 해결책은 다음과 같습니다. 하나의 선택적 인수를 사용 하여 listcomment
현재 목록 수준과 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}