繁体   English   中英

Latex:列表前后的垂直空间

[英]Latex: Vertical space before and behind the lists

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

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

    \item First item
    \item Second item

\end{list}

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


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

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}

评论

  • we're going to trick things into looking like an itemized bullet with multiple lines indented to match the first indented text. 我们要把事情变成看起来像一个逐条的子弹,多条线缩进以匹配第一个缩进文本。 要做到这一点,我们摆弄parindentleftskip值。 Leftskip通常为零,但我不知道parindent的设置是什么,因此我们将其保存在变量中并稍后恢复。 在尝试找到与\\setlength{\\parindent}{default}相当的东西时找到了这个技巧。[2]

  • this plays with how far the overall thing is indented. 这会影响整体事物的缩进程度。 如果您想进一步向右,只需增加值。 零意味着子弹与段落齐平。

  • this overrides the default behavior of making the subsequent lines aligned with the left edge of our bullet. 这会覆盖使后续行与子弹的左边缘对齐的默认行为。 -0.9值恰好适合于补偿子弹和空间,以便后续行看起来像是与第一行匹配。 你也可以调整一下。 例如,这样的事情可能看起来更好。

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

\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

这是Hendy答案的延续: Latex:列表前后的垂直空间

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

\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}

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

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

\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}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM