简体   繁体   English

LaTeX 非常紧凑的项目

[英]LaTeX VERY compact itemize

I am trying to build a very compact itemize with LaTeX, because I want to fit it in a table without whitespace everywhere.我正在尝试使用 LaTeX 构建一个非常紧凑的项目列表,因为我想将它放入一个没有空格的表格中。

What I need:我需要的:

  • No whitespace before list列表前没有空格
  • No whitespace after list列表后没有空格
  • No whitespace between lines行与行之间没有空格
  • Less indent before the bulletpoints在要点之前减少缩进

I have tried many packages ( paralist , mdwlist , enumitem ) but non of them can fully do it.我尝试了很多包( paralistmdwlistenumitem ),但没有一个能完全做到。

I tried it myself (with the help of paralist ) and could get rid of everything except the whitespace after the list.我自己尝试过(在paralist的帮助下)并且可以去掉列表后面除了空格之外的所有内容。 This is my current solution:这是我目前的解决方案:

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

\newenvironment{ilist}%
  {
    %from parlist package, reduces indent before bulletpoints
    \setdefaultleftmargin{1em}{1em}{}{}{}{} 
    \compress %places itemize into minipage, removing whitespace before
    \begin{itemize}%
    \setlength{\itemsep}{0pt}%
    \setlength{\topsep}{0pt} 
    \setlength{\partopsep}{0pt}
    \setlength{\parsep}{0pt}
    \setlength{\parskip}{0pt}}%
  {\end{itemize}}

However, I am unable to get rid of the space after the list.但是,我无法摆脱列表后的空间。 I can do it with a negative vspace but this is:我可以用负vspace来做,但这是:

  1. Ugly丑陋
  2. Does not work for tables: The rule after the row in which the list is will still be one line below.不适用于表格:列表所在行之后的规则仍将在下面一行。

Can anyone tell me how to do it?谁能告诉我该怎么做? I have googled so much, but it somehow seems that I am the first human that ever tried to insert an itemize into a table:D我在谷歌上搜索了很多,但不知何故,我似乎是第一个尝试将 itemize 插入表格的人:D

To change these settings globally全局更改这些设置

\usepackage{enumitem}
\setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt}

(And you can use the \\setenumerate , \\setdescription or \\setlist commands for other types of lists) (并且您可以将\\setenumerate\\setdescription\\setlist命令用于其他类型的列表)

Or for just a single list或者只是一个列表

\usepackage{enumitem}
...
\begin{itemize}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
\item item 1
\item item 2
\item item 3
\end{itemize}

The accepted answer is not up to date as mentioned in the comments.如评论中所述,接受的答案不是最新的。 This is what I used to get a compact list:这是我用来获得紧凑列表的内容:

\usepackage{enumitem}
\setlist{topsep=0pt, leftmargin=*}

Then use \\begin{itemize} as usual to start a list.然后像往常一样使用\\begin{itemize}开始一个列表。

试试enumitemshortlst包。

You get the desired layout with the savetrees package (caveat: this will also compactify the rest of your document)您可以使用savetrees package 获得所需的布局(注意:这也会压缩文档的 rest)

\documentclass{article}

\usepackage{savetrees}

\begin{document}
text
\begin{itemize}
\item No whitespace before list
\item No whitespace after list
\item No whitespace between lines
\item Less indent before the bulletpoints
\end{itemize}
text
\end{document}

在此处输入图像描述

In the preamble:在序言中:

\newcommand{\bbb}[1]{\indent$\bullet$ #1\\}

In the document:在文档中:

\bbb{hello world}

This solution was provided in a comment by @damien-pollet but every time I come back here to find it again, I always have a hard time finding it because it is a comment, so I am putting it as answer for the benefit of my future-self who will be looking for this answer again.这个解决方案是在@damien-pollet 的评论中提供的,但每次我回到这里再次找到它时,我总是很难找到它,因为它是一个评论,所以我把它作为答案是为了我的利益会再次寻找这个答案的未来的自己。

The compactitem environment of the paralist package works wonders: paralist package 的compactitem环境创造奇迹:

\usepackage{paralist}
...
\begin{compactitem}
\item Item 1
\item Item 2
\end{compactitem}

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

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