LaTeX 非常紧凑的逐项列出

发布于 2024-10-17 08:08:49 字数 1015 浏览 12 评论 0原文

我正在尝试使用 LaTeX 构建一个非常紧凑的 itemize,因为我想将其放入表格中,而各处都没有空格。

我需要什么:

  • 列表之前没有空格
  • 列表之后没有空格
  • 行之间没有空格
  • 项目符号之前减少缩进

我尝试过很多包(paralistmdwlistenumitem< /code>) 但他们中没有人能完全做到这一点。

我自己尝试过(在 paralist 的帮助下),并且可以删除除列表后的空白之外的所有内容。这是我当前的解决方案:

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

但是,我无法删除列表后面的空格。我可以使用负 vspace 来完成此操作,但这是:

  1. 丑陋
  2. 不适用于表:列表所在行之后的规则仍将是下面一行。

谁能告诉我该怎么做?我已经用谷歌搜索了很多,但不知何故,我似乎是第一个尝试将逐项插入表中的人:D

I am trying to build a very compact itemize with LaTeX, because I want to fit it in a table without whitespace everywhere.

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.

I tried it myself (with the help of paralist) and could get rid of everything except the whitespace after the list. 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:

  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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

傲影 2024-10-24 08:08:49

要全局更改这些设置

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

(您可以对其他类型的列表使用 \setenumerate\setdescription\setlist 命令)

或者仅用于单个列表

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

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)

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}
晨曦慕雪 2024-10-24 08:08:49

正如评论中所述,接受的答案不是最新的。这就是我用来获取紧凑列表的方法:

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

然后像往常一样使用 \begin{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.

走野 2024-10-24 08:08:49

尝试 enumitemshortlst 软件包。

Try the enumitem and shortlst packages.

雨后咖啡店 2024-10-24 08:08:49

这个解决方案是在 @damien-pollet 的评论中提供的,但每次我回到这里再次找到它时,我总是很难找到它,因为它是一条评论,所以我将其作为答案,以利于我的利益未来的自己将再次寻找这个答案。

paralist 包的 compactitem 环境创造了奇迹:

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

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.

The compactitem environment of the paralist package works wonders:

\usepackage{paralist}
...
\begin{compactitem}
\item Item 1
\item Item 2
\end{compactitem}
爱格式化 2024-10-24 08:08:49

您可以使用 savetrees 包获得所需的布局(注意:这也会压缩文档的其余部分)

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

在此处输入图像描述

You get the desired layout with the savetrees package (caveat: this will also compactify the rest of your document)

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

enter image description here

自此以后,行同陌路 2024-10-24 08:08:49

在序言中:

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

在文件中:

\bbb{hello world}

In the preamble:

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

In the document:

\bbb{hello world}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文