반 공백 선을 제거하고 공간을 정확하게 계산합니다.

반 공백 선을 제거하고 공간을 정확하게 계산합니다.

다음 MWE를 고려하십시오.

Some text, Some text, Some text, Some text, Some text, Some text,
Some text, Some text, Some text, Some text, Some text, Some text
\begin{enumerate}
\item This is a line \mbox{\parbox[t][][t]{\textwidth-\widthof{MMMx This is a line}}{

\begin{enumerate}[label=\textit{(\roman{enumii})}]
\item  Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 
\item Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 
\end{enumerate}

}}\end{enumerate}

질문이 있습니다:

1) "(i) Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1"을 "This is a line"과 같은 줄에 표시하고 싶습니다. 어떻게 해야 합니까?

2) "This is a line"의 마지막 단어, 즉 "line"과 "(i) Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1"의 첫 단어 사이의 간격, 즉 "텍스트"는 일반적인 공백입니다. "This is a line"은 이미 들여쓰기되어 있기 때문에 \widthof. 그러나 이것은 단지 눈으로 측정한 것일 뿐입니다. 이것을 어떻게 정확하게 만들 수 있습니까?

답변1

추측할 필요가 없습니다. minipage다음 대신 사용 \parbox하고 제거하십시오 \mbox.

\documentclass{article}
\usepackage{enumitem,calc}
\begin{document}
Some text, Some text, Some text, Some text, Some text, Some text,
Some text, Some text, Some text, Some text, Some text, Some text
\begin{enumerate}
\item This is a line
  \begin{minipage}[t]{\textwidth-\labelwidth-\labelsep-\widthof{This is a line}}
  \begin{enumerate}[label=(\textit{\roman*})]
  \item Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
  \item Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 1 Text 1 Text 1 Text 1 Text 1
  \end{enumerate}
  \end{minipage}
\end{enumerate}
\end{document}

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

모든 수준에서 중첩을 허용하는 더 나은 정의입니다. 하지만 여러 열거형을 중첩하는 것은 나쁜 스타일이라는 점을 명심하세요.

\documentclass{article}
\usepackage{showframe} % just for showing the page margins
\usepackage{enumitem,calc}

\newenvironment{xenumerate}[1]
 {\begin{minipage}[t]{\linewidth-\widthof{#1}}
  \begin{enumerate}[label=(\textit{\roman*})]}
 {\end{enumerate}\end{minipage}}

\begin{document}
Some text, Some text, Some text, Some text, Some text, Some text,
Some text, Some text, Some text, Some text, Some text, Some text
\begin{enumerate}
\item This is a line 
  \begin{xenumerate}{This is a line}
  \item Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
  \item Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 1 Text 1 Text 1 Text 1 Text 1
  \end{xenumerate}
\item Text text text text text text
  \begin{enumerate}
  \item Text Text Text Text
    \begin{xenumerate}{Text Text Text Text}
    \item Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
    \item Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 1 Text 1 Text 1 Text 1 Text 1
    \end{xenumerate}
  \item End of the story
  \end{enumerate}  
\end{enumerate}
\end{document}

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

라벨 변경을 위한 선택적 인수가 있는 버전

기본 라벨은 label=(\textit{\roman*})이전과 동일하지만 원하는 대로 변경할 수 있습니다.

\documentclass{article}
\usepackage{showframe}
\usepackage{enumitem,calc}

\newenvironment{xenumerate}[2][label=(\textit{\roman*})]
 {\begin{minipage}[t]{\linewidth-\widthof{#2}}
  \begin{enumerate}[#1]}
 {\end{enumerate}\end{minipage}}

\begin{document}
Some text, Some text, Some text, Some text, Some text, Some text,
Some text, Some text, Some text, Some text, Some text, Some text
\begin{enumerate}
\item This is a line 
  \begin{xenumerate}{This is a line}
  \item Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
  \item Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 1 Text 1 Text 1 Text 1 Text 1
  \end{xenumerate}
\item Text text text text text text
  \begin{enumerate}
  \item Text Text Text Text
    \begin{xenumerate}[label=(\arabic*)]{Text Text Text Text}
    \item Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
    \item Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 2 Text 1 Text 1 Text 1 Text 1 Text 1
    \end{xenumerate}
  \item End of the story
  \end{enumerate}  
\end{enumerate}
\end{document}

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

관련 정보