防止外部列表分離影響嵌套內部列表

防止外部列表分離影響嵌套內部列表

我增加了在d 環境\itemsep中使用的列表項之間的分離。itemize如何以最小的努力保持內部列表的項目分離不受影響?一種臨時解決方案可以是手動減少\itemsep內部清單的值。有沒有一種優雅的方式來達到同樣的效果?

\documentclass{llncs}

\begin{document}

\begin{itemize} \itemsep2em

    \item \textbf{L11}: This is level 1 item

        \begin{itemize}
            \item \textbf{L21}: This is level 2 item
            \item \textbf{L22}: This is level 2 item
            \item \textbf{L23}: This is level 2 item
            \item \textbf{L24}: This is level 2 item
        \end{itemize}

    \item \textbf{L12}: This is level 1 item
    \item \textbf{L13}: This is level 1 item
    \item \textbf{L14}: This is level 1 item

\end{itemize}

\end{document}

在此輸入影像描述

答案1

您不會在像文章這樣的標準類別中看到這種效果,因為它定義了內部列表的命令,以便它們重置 \itemsep。但是您可以在使用 llncs 時新增類似的功能:

\documentclass{llncs}

\usepackage{etoolbox}
\makeatletter
 \appto\@listii{\itemsep=0pt}
\makeatother
\begin{document}

\begin{itemize} \itemsep2em

    \item \textbf{L11}: This is level 1 item

        \begin{itemize}
            \item \textbf{L21}: This is level 2 item
            \item \textbf{L22}: This is level 2 item
            \item \textbf{L23}: This is level 2 item
            \item \textbf{L24}: This is level 2 item
        \end{itemize}

    \item \textbf{L12}: This is level 1 item
    \item \textbf{L13}: This is level 1 item
    \item \textbf{L14}: This is level 1 item

\end{itemize}

\end{document}

您也可以使用 enumitem 來設定類似的效果:

\usepackage{enumitem}
\setlist[1]{itemsep=2cm}
\setlist[2]{itemsep=0pt}

答案2

您可以另存\itemsep\myitemsep,然後將其用於內部清單。

\documentclass{llncs}
\usepackage{enumitem}
\newlength{\myitemsep}
\setlength{\myitemsep}{\itemsep}
\begin{document}

\begin{itemize}[itemsep=2em]
    \item \textbf{L11}: This is level 1 item
        \begin{itemize}[itemsep=\myitemsep]
            \item \textbf{L21}: This is level 2 item
            \item \textbf{L22}: This is level 2 item
            \item \textbf{L23}: This is level 2 item
            \item \textbf{L24}: This is level 2 item
        \end{itemize}

    \item \textbf{L12}: This is level 1 item
    \item \textbf{L13}: This is level 1 item
    \item \textbf{L14}: This is level 1 item

\end{itemize}

\end{document}

在此輸入影像描述

相關內容