如何更改多级列表中的对齐方式和项目符号样式?

如何更改多级列表中的对齐方式和项目符号样式?

id=1我有一个文档模板,它使用带有/的项目列表id=0,并\begin{itemize}\onlyitems[none, include = 1]用作每个项目的显示/隐藏条件。现在我想在每个项目后添加项目符号(在列表中添加第二级)。

目标是获得相当于

text 1
\begin{itemize}\onlyitems
..
\end{itemize}

text 2
\begin{itemize}\onlyitems
...
\end{itemize}

...

无需创建新文档即可添加/删除新条目。

从列表的第一级中删除项目符号很容易,但我不确定如何更改对齐方式,以便第一级看起来像普通文本。我也不知道如何将第二级中的项目符号的样式从破折号更改为其他样式。

代码:

\documentclass[11pt]{article}

\usepackage[margin=1in]{geometry}

\usepackage{enumerate}

\usepackage{pgfkeys,pgffor}

% A huge list of pgfkeys to be set up.  
\pgfkeys{
    /onlyitems/.is family, /onlyitems,
    % Utility keys
    utility/store tag/.store in = \itemOptions,
    utility/store bool/.store in = \itemIf,
    utility/process true/.style = {process/#1 = \iftrue},
    utility/process false/.style = {process/#1 = \iffalse},%\fi
    utility/set store bool/.style 2 args = {#1/.style = {utility/store bool = #2}},
    utility/set select style/.style 2 args = {utility/set store bool = {select/#1}{#2}},
    utility/verdict/.style = {},
    utility/add to reset/.style = {
        reset/.prefix style = {select/#1/.style = {select/.unknown}}
    },
    utility/current key/.estore in = \itemKey,
    % Nothing in the process family is ever set, so any selection option is set to store a boolean
    process/.unknown/.style = {
        utility/current key = \pgfkeyscurrentname,
        select/\itemKey/.style = {
            utility/set store bool = {utility/verdict}{#1}
        },
        utility/add to reset/.expand once = \itemKey
    },
    % For clearing the list of selected items (to support nested {itemize})
    reset/.style = {},
    reset/reset/.style = {reset/.style = {reset/reset, default}},
    reset/reset,
    % Here are the options you can actually pass.  These go to the {itemize}...
    include/.style = {utility/process true/.list  = {#1}},
    exclude/.style = {utility/process false/.list = {#1}},
    all/.style  = {utility/set select style = {.unknown}{\iftrue}},
    none/.style = {utility/set select style = {.unknown}{\iffalse}},%\fi
    default/.style = {all},
    % ...and these to the \item's
    tag/.style = {utility/store tag = {[#1]}},
    id/.style = {select/#1},
}

% Like tikzset, it sets a default key path
\newcommand\onlyitemsset[1]{\pgfkeys{/onlyitems, #1}}

\let\itemLaTeX=\item
% Have to use a \newcount because (ugh) the LaTeX \setcounter is a global assignment
\newcount\itemsSoFar
\renewcommand\item[1][]{%
    % The \egroup closes off any \vbox'es from the previously ignored \item.
    % The conditional \bgroup cancels it out when there aren't any.
    \itemIf\bgroup\fi\egroup
    \let\itemIf=\iffalse%\fi
    \advance\itemsSoFar by 1 %
    \onlyitemsset{utility/store tag = {}, utility/verdict/.style = {}, select/\the\itemsSoFar, #1, utility/verdict}%
    \itemIf
    \def\next{\expandafter\itemLaTeX\itemOptions}%
    \else
    % The vbox is set and then discarded, effectively ignoring an entire \item.
    % This inner \itemLaTeX is necessary to avoid a glitch when we ignore the first \item of an itemize that itself contains a nested \itemize.  Don't ask, I don't know.
    \def\next{\setbox0=\vbox\bgroup\itemLaTeX}%
    \fi
    \next
}

% \let\itemizeLaTeX=\itemize
% \let\enditemizeLaTeX=\enditemize
% \renewcommand\itemize[1][]{%
%  \let\itemIf=\iftrue
%  \itemsSoFar = 0 %
%  % We have to reset here so that the selections from an outer itemize don't conflict with an inner one.
%  \onlyitemsset{reset, #1}%
%  \itemizeLaTeX
% }
% \renewcommand\enditemize{%
%  % This closes off the last \vbox
%  \itemIf\bgroup\fi\egroup\enditemizeLaTeX
% }

\newcommand\onlyitems[2][]{%
    \let\itemIf=\iftrue
    \itemsSoFar = 0 %
    % We have to reset here so that the selections from an outer itemize don't conflict with an inner one.
    \onlyitemsset{reset, #1}%
    #2%
    % This closes off the last \vbox
    \itemIf\bgroup\fi\egroup
}

\begin{document}

\newcommand{\mylist}{
    \item[id = 1] item 1 text
        \begin{itemize}\onlyitems
            \item point 1
            \item point 2
            \item point 3
        \end{itemize}
    \item[id = 0] item 2 text
        \begin{itemize}\onlyitems
            \item point 1
            \item point 2
            \item point 3
        \end{itemize}
    \item[id = 1] item 3 text
        \begin{itemize}\onlyitems
            \item point 1
            \item point 2
            \item point 3
        \end{itemize}
}

\begin{itemize}\onlyitems[none, include = 1]
    \mylist
\end{itemize}
\end{document}

相关内容