Latex:列表前后的垂直空间

时间:2010-11-18 01:15:49

标签: list latex

我无法摆脱列表前后的垂直空间。我有如下代码:

\begin{list}{-}{}
    \setlength{\itemsep}{0pt}
    \setlength{\parskip}{0pt}
    \setlength{\parsep}{0pt}

    \item First item
    \item Second item

\end{list}

3 个答案:

答案 0 :(得分:2)

更新的答案:现在考虑单行和多行列表项。


一行(简单) 没有逐项列出项目......

Some text that is here and I want to see what it does. \\
  \indent$\bullet$\,first item \\
  \indent$\bullet$\,second item \\
Some text that is here and I want to see what it does.

$\bullet$替换为您想要的任何内容。

\indent- first item\\
\indent$\cdot$\,first item\\
\indent$\circ$\,first item\\
\indent$\ast$\,first item\\

“ - ”似乎与所示的空白一样正常,但其余部分需要trailin \,,它在数学符号和下一个单词之间插入一个空格。没有它,“子弹”和随后的文本之间就没有空格。


多行项目(稍微复杂一点) 好吧,不是很复杂。刚刚找到了一个关于做“悬挂缩进”的参考资料,这似乎使这种灵活性足以做任何你想做的事情。 [1]

\documentclass{article}

\begin{document}

\newlength{\originalParindent} %see comments below
\setlength{\originalParindent}{\parindent} 

Some text that is here and I want to see what it does and to show the current
indentation behavior of a blob of text. Some text that is here and I want to
see what it does. Some text that is here and I want to see what it does. \par

\leftskip .3in % see comments below
\parindent -0.09in % see comments below

\indent$\bullet$\,first item that spills onto a second line to demonstrate the
function of leftskip and it's ability to make hanging indents. Might as well
make sure we hit three lines with this first item to be sure it works.\\

\indent$\bullet$\,second item can run onto a second line as well; hopefully
this solves the problem\par

\leftskip 0in %reset the defaults
\setlength{\parindent}{\originalParindent} %resent the defaults

Some text that is here and I want to see what it does. Just want to make sure
the defaults are restored and paragraphs indent with their proper functionality.

\end{document}

评论

  • Parindent stuff:我们要把事情看作是一个逐条子弹,多条线缩进以匹配第一个缩进文本。为此,我们使用parindentleftskip值。 Leftskip通常为零,但我不知道parindent的设置是什么,因此我们将其保存在变量中并稍后恢复。在尝试找到与\setlength{\parindent}{default}相当的东西时找到了这个技巧。[2]

  • leftskip:这会影响整体事物的缩进程度。如果您想进一步向右,只需增加值。零意味着子弹与段落齐平。

  • parindent:这会覆盖使后续行与子弹的左边缘对齐的默认行为。 -0.9值恰好适合于补偿子弹和空间,以便后续行看起来像是与第一行匹配。你也可以调整一下。例如,这样的事情可能看起来更好。

子弹和文字之间的空间更大; parindent相应调整:

\leftskip .3in % see comments below
\parindent -0.215in % see comments below

\indent$\bullet$\quad first item that spills onto a second line to demonstrate
the function of leftskip and it's ability to make hanging indents. Might as
well make sure we hit three lines with this first item to be sure it works.\\

希望有所帮助! parindent和leftskip手柄应该可以让你完善你想要的东西。


[1] http://www.wkiri.com/today/?p=76

[2] http://www.cs.cmu.edu/afs/cs/usr/bovik/database/tsf-bboard/Tex/enumerate

答案 1 :(得分:1)

这是Hendy回答的延续:Latex: Vertical space before and behind the lists

我记下了他的笔记,并准备了以下内容:

\newlength{\originalParindent}                                            
\newenvironment{my_itemize}
{
    \setlength{\originalParindent}{\parindent}                            
    \leftskip .3in                                                        
    \parindent -0.11in

    \newcommand{\originalItem}{\item}                                     
    \renewcommand{\item}{\indent - }                                      
}
{                                                                         
    \par

    \leftskip 0in
    \setlength{\parindent}{\originalParindent}                            
    \renewcommand{\item}{\originalParindent}                              
}   

之后我只能写:

\begin{my_itemize}

     \item Something very short

     \item Somethnig very long. Somethnig very long. Somethnig very long. Somethnig very long. Somethnig very long. Somethnig very long.

\end{my_itemize}

在我的文档中的任何位置获取正确的列表。

答案 2 :(得分:1)

扩展前面的答案,一个没有子弹点的变体,而是第一行没有缩进,而其他行(从第二行开始)有缩进:

\newenvironment{table_itemize}
{
    \begingroup                 % Start of formatting properties

    \leftskip 0.1in             % indentation for lines except first line
    \parindent -0.1in           % first line: no indentation

    \renewcommand{\item}{}      % no bullets
}{
    % restore all formatting that we changed since begingroup
    % (e.g. leftskip, parindent)
    \endgroup
}

然后,按照Kogut在帖子中指出的相同方式使用:

\begin{table_itemize}

    \item Something very short

    \item Something very long. Something very long. Something very long. Something very long. Something very long. Something very long.

\end{table_itemize}