我的问题是,项目不是太小(因此不是项目符号),以至于超出了左边距。请参见下面的示例。
\documentclass[a4paper,12pt]{report}
\begin{document}
\begin{itemize}
\item[ABCD] in the first item, ....
\item[KLMN] in some items like this one, there is so much text that it does not fit in a single line (but this is fine!!!)
\item[WXYZ] ...
\end{itemize}
\end{document}
我尝试了类似的东西\setlength{\itemindent}{15pt}
,但效果不太好,因为我得到的行(项目之后)没有对齐。我也尝试了description
而不是itemize
,但再次得到未对齐的文本。
谢谢。
答案1
使用KOMA-Script
类scrreprt
\documentclass[a4paper,12pt]{scrreprt}
\begin{document}
\noindent\rule{\linewidth}{1pt}% only demo
\begin{labeling}{WXYZZ}
\item[ABCD] in the first item, ....
\item[KLMN] in some items like this one, there is so much text that it does not fit in a single line (but this is fine!!!)
\item[WXYZ] ...
\end{labeling}
\end{document}
或者不使用其他类来重新定义环境或者定义一个新的环境:
\documentclass[a4paper,12pt]{report}
\newenvironment{Description}
{\list{}{\labelwidth=0pt \leftmargin=4em \itemindent-\leftmargin
\let\makelabel\descriptionlabel}}
{\endlist}
\begin{document}
\noindent\rule{\linewidth}{1pt}
\begin{Description}
\item[ABCD] in the first item, ....
\item[KLMN] in some items like this one, there is so much text that it does not fit in a single line (but this is fine!!!)
\item[WXYZ] ...
\end{Description}
\end{document}
答案2
一旦我添加了usepackage[showframe]{geometry}
,问题就更加明显了。由于您不想使用该enumitem
包(这将是一个更好的选择),您可以求助于DESCRIPTION
提供的环境更改描述列表中的悬挂缩进来修复此问题(或针对同一问题的其他解决方案之一)。
\documentclass[a4paper,12pt]{report}
\usepackage[showframe]{geometry}
% https://tex.stackexchange.com/questions/7008/change-hanging-indent-in-description-list
\usepackage{calc}
\makeatletter
\newcommand{\DESCRIPTION@original@item}{}
\let\DESCRIPTION@original@item\item
\newcommand*{\DESCRIPTION@envir}{DESCRIPTION}
\newlength{\DESCRIPTION@totalleftmargin}
\newlength{\DESCRIPTION@linewidth}
\newcommand{\DESCRIPTION@makelabel}[1]{\llap{#1}}%
\newcommand{\DESCRIPTION@item}[1][]{%
\setlength{\@totalleftmargin}%
{\DESCRIPTION@totalleftmargin+\widthof{\textbf{#1 }}-\leftmargin}%
\setlength{\linewidth}
{\DESCRIPTION@linewidth-\widthof{\textbf{#1 }}+\leftmargin}%
\par\parshape \@ne \@totalleftmargin \linewidth
\DESCRIPTION@original@item[\textbf{#1}]%
}
\newenvironment{DESCRIPTION}
{\list{}{\setlength{\labelwidth}{0cm}%
\let\makelabel\DESCRIPTION@makelabel}%
\setlength{\DESCRIPTION@totalleftmargin}{\@totalleftmargin}%
\setlength{\DESCRIPTION@linewidth}{\linewidth}%
\renewcommand{\item}{\ifx\@currenvir\DESCRIPTION@envir
\expandafter\DESCRIPTION@item
\else
\expandafter\DESCRIPTION@original@item
\fi}}
{\endlist}
\makeatother
\begin{document}
\begin{DESCRIPTION}
\item[ABCD] in the first item, ....
\item[KLMN] in some items like this one, there is so much text that it does not fit in a single line (but this is fine!!!).
\item[WXYZ] ...
\end{DESCRIPTION}
\end{document}