
Considere el siguiente 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}
Tengo preguntas:
1) Me gustaría que "(i) Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1" se muestre en la misma línea que "Esta es una línea". Cómo puedo hacer eso ?
2) Me gustaría el espacio entre la última palabra de "Esto es una línea", es decir, "línea", y la primera palabra de "(i) Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1 Texto 1", es decir "Texto" sea un espacio normal. Debido a que "Esto es una línea" ya tiene sangría, intenté tener en cuenta esta sangría agregando "MMMx" como espacio adicional en \widthof
. Pero esto es sólo una medida visual. ¿Cómo puedo hacer esto preciso?
Respuesta1
No es necesario adivinar; utilizar minipage
en lugar de \parbox
y eliminar el \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}
Una mejor definición que permite anidar en todos los niveles; pero tenga en cuenta que anidar varias enumeraciones es un mal estilo.
\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}
Versión con un argumento opcional para cambiar la etiqueta.
La etiqueta predeterminada es label=(\textit{\roman*})
la misma que antes, pero puedes cambiarla como quieras.
\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}