
Considere o seguinte 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}
Eu tenho que fazer perguntas:
1) Gostaria que "(i) Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1" fosse exibido na mesma linha que "Esta é uma linha". Como eu posso fazer isso ?
2) Gostaria do espaçamento entre a última palavra de "Isto é uma linha", ou seja, "linha", e a primeira palavra de "(i) Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1", ou seja "Texto" seja um espaço normal. Como "Esta é uma linha" já está recuado, tentei explicar esse recuo adicionando "MMMx" como espaçamento adicional em \widthof
. Mas isso é apenas uma medida ocular. Como posso tornar isso preciso?
Responder1
Não há necessidade de adivinhar; use minipage
em vez de \parbox
e remova o \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}
Uma melhor definição que permite o aninhamento em todos os níveis; mas tenha em mente que aninhar várias enumerações é um estilo ruim.
\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}
Versão com argumento opcional para alteração do rótulo
O rótulo padrão é label=(\textit{\roman*})
o mesmo de antes, mas você pode alterá-lo como desejar.
\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}