열거 환경의 동작에 대해

열거 환경의 동작에 대해

저는 숙제 문제를 위한 매우 간단한 사용자 정의 환경을 정의했습니다. 기본적으로는 enumerate들여쓰기가 없지만 다음과 같습니다.

\newcounter{hwprob}
\newenvironment{hwprob}{\refstepcounter{hwprob} \textbf{\thehwprob.} ~ }{}

enumerate내부의 실제 환경을 열면 hwprob다음과 같은 일이 발생합니다.

\begin{hwprob}
   \begin{enumerate}
      \item Some text.
      \item Some other text.
   \end{enumerate}
\end{hwprob}

첫 번째 항목 1이 왜 같은 줄에서 시작되지 않는지 잘 모르겠습니다.1.물결표를 제거하려고 시도했지만 소용이 없었습니다. 제가 당황스러운 점은 환경 enumerate내부에서 사용할 때 proof첫 번째 항목이 다음과 같은 줄에 있을 것이라는 점입니다.증거., 올바른 들여쓰기와 모든 것.

이 문제를 해결하려면 어떻게 해야 합니까? 이것은 내가 정의한 결과입니까 hwprob, 아니면 고유한 것입니까 enumerate?

답변1

"방법" 부분은 다음과 같습니다. hwprob목록 환경으로 정의하고 \item의 시작 부분에 자동으로 삽입합니다 hwprob.

\documentclass{article}
\usepackage{enumitem}

\newlist{hwprob}{enumerate}{1}
\setlist[hwprob]{label=\textbf{\arabic*.}, first*=\item}

\begin{document}
\begin{hwprob}
   \begin{enumerate}
      \item Some text.
      \item Some other text.
   \end{enumerate}
\end{hwprob}
\end{document}

여기에 이미지 설명을 입력하세요

"왜" 부분의 경우 목록 및 정리 환경 모두에서 사용되는 공통 기반인 \trivlist(아마도 )와 관련이 있는 것 같습니다 .\parshape

답변2

달성하려는 형식(목록의 첫 번째 항목이 enumerate줄 바꿈 이후 시작되지 않고 현재 줄에서 시작되도록 함)은 enumerate환경이 하나의 LaTeX list또는 trivlist환경 내에서 시작되는 경우 발생합니다.

형식 지정 목표를 달성하려면 enumitem 패키지를 로드하고 해당 패키지 \newlist\setlist매크로를 사용하여 이라는 맞춤형 열거형 목록 환경을 만드는 것이 좋습니다 hwprob.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage{enumitem}
\newlist{hwprob}{enumerate}{1}
\setlist[hwprob,1]{label=\bfseries\arabic*.,left=0pt}

\begin{document}
\begin{hwprob}
\item
   \begin{enumerate}
      \item Some text.
      \item Some other text.
   \end{enumerate}
\end{hwprob}
\end{document}

관련 정보