制作嵌套列表的更好方法

制作嵌套列表的更好方法

在 LaTeX 中输入设置嵌套列表的方法如下:

\begin{itemize}
    \item I have a house
    \begin{itemize}
        \item It has 4 walls
        \item a roof,
        \item two windows,
        \item and a door
        \begin{itemize}
            \item with a handle
            \item and a lock
        \end{itemize}
    \end{itemize}
    \item I also have a car
    \begin{itemize}
        \item but I will not talk of it further
    \end{itemize}
\end{itemize}

这是 Markdown 中的相同列表:

 - I have a house
    - It has 4 walls,
    - a roof,
    - two windows
    - and a door
         - with a handle
         - and a lock
 - I also have a car
    - But I will not talk of it further

Latex 的确实很冗长。我发现用 Beamer 写幻灯片时特别烦人。嵌套 3 层深度很少是一个好主意,但有一个包含每个项目的一些子项目的列表并不坏,但仍然会让人感到不舒服的冗长。

是否有一个包可以提供用于编写​​列表的替代语法?


使用一些defs可能会有帮助,但似乎有点不靠谱

\newcommand{\ol}{\begin{itemize} }
\newcommand{\ole}{\end{itemize} }
\newcommand{\li}{\item }

解析 markdown 列表语法似乎可以用 Lua 来完成,或者甚至可以用xargs,但我还不太擅长这种事情(目前)。

答案1

看一下easylist包中的示例。它通过定义一个活动字符来简化流程,该字符的出现次数定义了此特定列表项的级别。

\documentclass{article}
\usepackage{easylist}
\begin{document}

\begin{easylist}
§ First level
§§ Second level
§§§ Third level
§§§ Again third level
§§§§ Now fourth level
§ First level again
\end{easylist}
\end{document}

easylist 示例

答案2

在此处输入图片描述

\documentclass{article}

\newcommand{\ol}[1]{\begin{enumerate}#1\end{enumerate}}
\newcommand{\ul}[1]{\begin{itemize}#1\end{itemize}}
\newcommand{\li}[1]{\item{#1}}

\newlength{\shiftwidth}
\setlength{\shiftwidth}{3em}
\newcommand{\info}[1]{\par\hspace*{#1\shiftwidth}$\bullet$\quad}

\begin{document}

Simple ways to make lists less verbosely in \LaTeX:

\ol{%
  \li{Redefine the markup commands to match HTML.}
    \ul{%
       \li{This means turning the list environments into commands.}
       \li{This is actually less verbose than real HTML.}
       \li{You do have to keep track of the end braces and (I think) comment out the newlines.}
    }
   \li{Define commands to insert horizontal space and bullets manually, as shown below.}
}

\info{0} This is level 0.
    \info{1} This is level 1.
        \info{2} And this level 2.

\end{document}

相关内容