多行文本的垂直对齐

多行文本的垂直对齐

我用

\begin{itemize}
  \item \makebox[2.5cm][l]{some text} some very long text. some very long text. some very long text. some very long text.
\end{itemize}

生产

enter image description here

问题是我希望项目的第二行与项目的第二部分对齐。因此“一些文本”在某种程度上就像项目项目符号一样。所以我还想\makebox{}在“垂直方向”上工作,这样就不会在此下方放置任何文本。

答案1

有几种解决方案可以解决此问题,下面介绍两种。首先labeling使用scrextend或任何KOMA-Script 类description,其次使用来自使用的环境enumitem

\documentclass{article}
\renewcommand{\familydefault}{\sfdefault}% you are using a sans serif font

% use package scrextend to have the labeling environment of KOMA-Script
\usepackage{scrextend}
\setkomafont{labelinglabel}{$\triangleright$\enskip}% ugly hack to have a
                                % triangle before the item

% use package enumitem to have an extended description environment
\usepackage{enumitem}
\newcommand*{\descriptionlabelwith}[2]{\hspace\labelsep
  \normalfont#1\enskip #2}
\newlist{itemdesc}{description}{1}% currently only one level is definded
\setlist*[itemdesc,1]{font=\normalfont,format=\descriptionlabelwith{$\triangleright$},leftmargin=27mm,labelwidth=*}

\begin{document}
\begin{labeling}{\hspace{2.5cm}}
\item[some text] some very long text. some very long text. some very long text. some very long text.
\end{labeling}

\begin{itemdesc}
\item[some text] some very long text. some very long text. some very long text. some very long text.
\end{itemdesc}

\end{document}

solution using labeling or enumitem

相关内容