
Estoy intentando implementar un comando para usar en lugar de itemize
/ enumerate
entornos. La idea es que quiero tener un comando ( \detail
), que pueda usarse para construir una lista detallada sin estar contenido en un entorno. El problema que tengo es que cuando una línea es más larga que el ancho de la página y, en consecuencia, pasa a la siguiente línea, parece que no tengo ningún control sobre la sangría del texto ajustado. Probé el hanging
paquete y \hangindent
, pero no tuve mucha suerte.
He incluido un ejemplo mínimo a continuación y el resultado que obtengo cuando lo compilo. Idealmente, me gustaría que el texto ajustado tenga una sangría de modo que la primera palabra de la segunda línea se alinee con la primera palabra de la primera línea.
\documentclass{article}
\newcommand{\detail}[1]{-- {#1}}
\begin{document}
\noindent\textbf{This is a header}\\
\detail{This is a detail.}\\
\detail{This is a detail that has too many words in it and consequently runs onto the next line of the page, and I want it to have a hanging indent.}
\end{document}
Respuesta1
Una simplificación de lo ya respondido:
\documentclass{article}
\def\D{\par\noindent\makebox[1em][l]{-- }\hangindent1em}
\begin{document}
\subsubsection*{This is a header}
\D This is a detail
\D This is a detail that has too many words in it and consequently runs onto The next line of the page, and I want it to have a hanging indent.
\end{document}
Respuesta2
\documentclass{article}
\newcommand{\detail}[1]{\par\noindent\hangindent=\mylen\hangafter1-- #1}
\newlength{\mylen}
\settowidth{\mylen}{-- }
\begin{document}
\noindent\textbf{This is a header}
\detail{This is a detail.}
\detail{This is a detail that has too many words in it and consequently runs onto the next line of the page, and I want it to have a hanging indent.}
\end{document}
Respuesta3
\documentclass{article}
\newcommand{\detail}[1]{\par\noindent\hangindent=\mylen\hangafter1--\,\,#1}
\newlength{\mylen}
\settowidth{\mylen}{--\,\,}
\begin{document}
\noindent\textbf{This is a header}
\detail{This is a detail.}
\detail{This is a detail that has too many words in it and consequently runs onto the next line of the page, and I want it to have a hanging indent.}
\end{document}
Quería poner esto como comentario a la respuesta de Harish Kumar pero no tengo suficiente reputación para eso. De todos modos, dado que el espacio es de goma, es mejor usar una longitud fija. Como \, parece un poco estrecho, lo usé dos veces, puedes ajustarlo al gusto.