如何(稳健地)捕获嵌套列表的内容?

如何(稳健地)捕获嵌套列表的内容?

为什么找到一种强大的方法来捕获嵌套列表的内容如此困难?

在尝试理解itemizeenumerate环境之前,我检查了的纯 TeX 定义\itemTeXbook我理解这\item是一个定义为的函数

“Plain TEX 在其 '\item宏中使用悬挂缩进,这会生成一个段落,其中每行都具有与正常 相同的缩进\indent。此外,\item还采用一个参数,该参数放置在第一行的缩进位置。另一个宏调用\itemitem执行相同的操作,但使用双缩进。”

\item[$\bullet$]没有强制参数,但有一个列表中的可选参数。

\item但是,获取列表后的文本内容似乎很困难。

TeX实际上,使用(括号内) 来检索此内容会更容易\item{bla bla bla}。这就是所做的事情这里这里为了非嵌套列表。

其他答案则指向外部语言。例如,在 Python 中,特克斯汤 旨在将 .tex 文件的所有内容组织到数据框中,从而处理这个问题。

我想留在 TeX 里面。

beamer作为一种选择的兼容性\item<i->将会很棒......

应用示例:轻松将枯燥的列表变成思维导图

注意:这个问题是在另一场讨论中提出的很棒的 TeX 社区关于如何创建一个将嵌套列表呈现到思维导图中的环境。

在此处输入图片描述 在此处输入图片描述

平均能量损失



\documentclass{beamer}
\usepackage{tikz}

\usetikzlibrary{mindmap,shadows}
\definecolor{myuniversity}{RGB}{36, 0, 132} 

%--------------------
% GrowCycle
% Till level 5
%--------------------
\makeatletter
\newif\ifmmap@debug
\mmap@debugfalse
\newcommand{\mmap@debug@message}[1]{\ifmmap@debug
    \typeout{#1}%
    \fi}
\def\tikz@mmap@store@aux#1#2{%
\immediate\write\@mainaux{\string\expandafter\xdef\noexpand\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\string\endcsname{#2}}}%
\def\tikz@mmap@get@from@aux#1#2{%
\ifcsname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname
\edef#2{\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname}%
\else
\edef#2{0}%
\fi
}   
\pgfmathdeclarefunction{MMapNodesAtLevel}{1}{%
\tikz@mmap@get@from@aux{n-\@roman{#1}}{\pgfmathresult}}
\newcount\tikzcountchildi
\newcount\tikzcountchildii
\newcount\tikzcountchildiii
\newcount\tikzcountchildiv
\newcount\tikzcountchildv
\newcount\tikzcountchildvi
\tikzcountchildi=0
\tikzcountchildii=0
\tikzcountchildiii=0
\tikzcountchildiv=0
\tikzcountchildv=0
\tikzcountchildvi=0
\tikzset{Julien growth/.style={%
    growth function=\tikz@grow@Julien,
    mmap/initialize counts,
    /tikz/execute at end scope={%
       \tikz@mmap@store@aux{n-i}{\the\tikzcountchildi}%
       \tikz@mmap@store@aux{n-ii}{\the\tikzcountchildii}%
       \tikz@mmap@store@aux{n-iii}{\the\tikzcountchildiii}%
       \tikz@mmap@store@aux{n-iv}{\the\tikzcountchildiv}%
       \tikz@mmap@store@aux{n-v}{\the\tikzcountchildv}%
       \tikz@mmap@store@aux{n-vi}{\the\tikzcountchildvi}%
    }},
    mmap/.cd,
    initialize counts/.code={\global\tikzcountchildi=0%
        \global\tikzcountchildii=0%
        \global\tikzcountchildiii=0%
        \global\tikzcountchildiv=0%
        \global\tikzcountchildv=0%
        \global\tikzcountchildvi=0%
    }
}


\def\tikz@grow@Julien{%
    \pgftransformreset% 
    \pgftransformshift{\pgfpoint{\pgfkeysvalueof{/tikz/mmap/overall xshift}}%
        {\pgfkeysvalueof{/tikz/mmap/overall yshift}}}%
    \ifcase\tikztreelevel 
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildi}%
        \global\advance\tikzcountchildi by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildii}%
        \global\advance\tikzcountchildii by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildiii}%
        \global\advance\tikzcountchildiii by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildiv}%
        \global\advance\tikzcountchildiv by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildv}%
        \global\advance\tikzcountchildv by1\relax%
    \fi
    \mmap@debug@message{level=\the\tikztreelevel,%
        \the\tikzcountchildi,\the\tikzcountchildii,\the\tikzcountchildiii,
        rotation=\pgfutil@tempb,sibling angle=\pgfkeysvalueof{/tikz/sibling angle}}%
    \pgftransformrotate{\pgfutil@tempb}%
    \pgftransformxshift{\the\tikzleveldistance}%
}
\makeatother
                
                
\tikzset{%
mmap/.cd,
    name/.initial=undef,
    overall rotation/.initial   = 0,
    overall xshift/.initial     = 0pt,
    overall yshift/.initial     = 0pt,
    sign/.initial               = 1,                
    child weight/.initial       = 0.5,      
    rotation/.initial           = 0.5,
    shape angle/.initial        = 180,      
    distance to 1/.initial      = 4.5cm,        
    distance to 2/.initial      = 7.5cm,        
    distance to 3/.initial      = 10cm,     
    distance to 4/.initial      = 12cm,     
    distance to 5/.initial      = 14cm,     
    offset level 3/.initial     = 0,        
/tikz/.cd,
    offset angle/.initial=0, 
    Xshift/.style={xshift=#1,mmap/overall xshift=#1},
    Yshift/.style={yshift=#1,mmap/overall yshift=#1},
%    branch color/.style={
%        concept color=#1!80,
%        ball color=#1!50,
%        every child/.append style={concept color=#1!50},
%    },
}


%----------------------------------------------
% Style of the mindmap
%----------------------------------------------
\tikzset{mymmstyle/.style 2 args={
    text width=1.5cm,
    align=flush center,
    mindmap,
    Julien growth,
    mmap/overall rotation=\pgfkeysvalueof{/tikz/mmap/rotation},
    mmap/sign   = 1,
    mmap/name   = semicirc, %<- you need unique names if you want to use several mindmaps
    every node/.style={
        concept,
        circular drop shadow, 
        execute at begin node=\hskip0pt,
        text=#2,
    },  
    node font=\sffamily,
    nodes={concept},
    concept color=#1,
    root concept/.append style={
        ball color=#1, 
        line width=1.5ex,
        text=#2,
        font=\LARGE\bfseries\scshape,
        minimum size=3.25cm, 
        text width=3.25cm
    },                   
    level 1/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 1},%
        font=\large,%
        minimum size=2.5cm,%
        text width=2.0cm, 
        fill= #1!70,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(1)-1),1)}
    },
    level 2/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 2},%
        font=\normalsize,%
        minimum size=1.5cm,%
        text width=1.5cm, 
        fill= #1!50,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(2)-1),1)}
    },
    level 3/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 3},
        font=\normalsize,
        minimum size=1.5cm,
        text width=1.5cm, 
        fill= #1!30,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(3)-1),1)},
        offset angle=\pgfkeysvalueof{/tikz/mmap/offset level 3}
    },
    level 4/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 4},
        font=\normalsize,
        minimum size=1cm,
        text width=1cm, 
        fill= #1!30,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(4)-1),1)},
        offset angle=\pgfkeysvalueof{/tikz/mmap/offset level 4}
    },
}
}


%\newcommand{\MyMindMap}[2][mymmstyle={blue}{white}]{
%\begin{tikzpicture}[#1]    
%%  \begin{scope}[#1]   
%%  \input{#2}
%{#2}
%%  \end{scope}
%\end{tikzpicture}
%}


\begin{document}

\begin{frame}
    \frametitle{Audience catching mindmap}

    
    \resizebox{\linewidth}{!}{
        \begin{tikzpicture}
            \begin{scope}[mymmstyle={orange}{orange!50!black}]
                
                \node[root concept] {Root} 
                child {node {level 1}
                    child {node {level 2}
                        child {node {level 3}}
                        child {node {level 3}}
                        child {node {level 3}}              
                    }
                    child {node {level 2}
                        child {node {level 3}}
                        child {node {level 3}}
                    }
                    child {node {level 2}
                        child {node {level 3}}
                        child {node {level 3}}
                        child {node {level 3}}
                    }
                }
                child {node {level 1}
                    child {node {level 2}}
                    child {node {level 2}
                        child {node {level 3}}
                        child {node {level 3}}      
                    }
                    child {node {level 2}
                        child {node {level 3}}
                        child {node {level 3}}      
                    }               
                }
                child {node {level 1}
                    child {node {level 2}
                        child {node {level 3}}
                        child {node {level 3}}
                    }
                    child {node {level 2}
                        child {node {level 3}}
                        child {node {level 3}}
                    }
                    child {node {level 2}
                        child {node {level 3}}    
                        child {node {level 3}}    
                    }
                }
                ;                           
            \end{scope}
        \end{tikzpicture}
    }
\end{frame}

\begin{frame}[allowframebreaks]
    \frametitle{Audience killer list}
        
    \begin{itemize}
        \item level 1
              \begin{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3 
                        \item level 3 
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3 
                        \item level 3 
                        \item level 3 
                      \end{itemize}
              \end{itemize}
        \item level 1
              \begin{itemize}
                \item level 2
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
              \end{itemize}
        \item level 1
              \begin{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
              \end{itemize}
    \end{itemize}
        
\end{frame} 

\end{document}

答案1

您可以在本地重新定义列表命令,以便它们扩展到 tikz 节点树标记中。(我在这里使用 xdef,具体取决于您可能需要的实际文本内容\protected@xdef或类似内容)

在此处输入图片描述


\documentclass{beamer}
\usepackage{tikz}

\usetikzlibrary{mindmap,shadows}
\definecolor{myuniversity}{RGB}{36, 0, 132} 

%--------------------
% GrowCycle
% Till level 5
%--------------------
\makeatletter
\newif\ifmmap@debug
\mmap@debugfalse
\newcommand{\mmap@debug@message}[1]{\ifmmap@debug
    \typeout{#1}%
    \fi}
\def\tikz@mmap@store@aux#1#2{%
\immediate\write\@mainaux{\string\expandafter\xdef\noexpand\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\string\endcsname{#2}}}%
\def\tikz@mmap@get@from@aux#1#2{%
\ifcsname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname
\edef#2{\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname}%
\else
\edef#2{0}%
\fi
}   
\pgfmathdeclarefunction{MMapNodesAtLevel}{1}{%
\tikz@mmap@get@from@aux{n-\@roman{#1}}{\pgfmathresult}}
\newcount\tikzcountchildi
\newcount\tikzcountchildii
\newcount\tikzcountchildiii
\newcount\tikzcountchildiv
\newcount\tikzcountchildv
\newcount\tikzcountchildvi
\tikzcountchildi=0
\tikzcountchildii=0
\tikzcountchildiii=0
\tikzcountchildiv=0
\tikzcountchildv=0
\tikzcountchildvi=0
\tikzset{Julien growth/.style={%
    growth function=\tikz@grow@Julien,
    mmap/initialize counts,
    /tikz/execute at end scope={%
       \tikz@mmap@store@aux{n-i}{\the\tikzcountchildi}%
       \tikz@mmap@store@aux{n-ii}{\the\tikzcountchildii}%
       \tikz@mmap@store@aux{n-iii}{\the\tikzcountchildiii}%
       \tikz@mmap@store@aux{n-iv}{\the\tikzcountchildiv}%
       \tikz@mmap@store@aux{n-v}{\the\tikzcountchildv}%
       \tikz@mmap@store@aux{n-vi}{\the\tikzcountchildvi}%
    }},
    mmap/.cd,
    initialize counts/.code={\global\tikzcountchildi=0%
        \global\tikzcountchildii=0%
        \global\tikzcountchildiii=0%
        \global\tikzcountchildiv=0%
        \global\tikzcountchildv=0%
        \global\tikzcountchildvi=0%
    }
}


\def\tikz@grow@Julien{%
    \pgftransformreset% 
    \pgftransformshift{\pgfpoint{\pgfkeysvalueof{/tikz/mmap/overall xshift}}%
        {\pgfkeysvalueof{/tikz/mmap/overall yshift}}}%
    \ifcase\tikztreelevel 
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildi}%
        \global\advance\tikzcountchildi by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildii}%
        \global\advance\tikzcountchildii by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildiii}%
        \global\advance\tikzcountchildiii by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildiv}%
        \global\advance\tikzcountchildiv by1\relax%
    \or
        \pgfmathsetmacro{\pgfutil@tempb}{\pgfkeysvalueof{/tikz/mmap/overall rotation}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/offset angle}%
            +\pgfkeysvalueof{/tikz/mmap/sign}*\pgfkeysvalueof{/tikz/sibling angle}*\tikzcountchildv}%
        \global\advance\tikzcountchildv by1\relax%
    \fi
    \mmap@debug@message{level=\the\tikztreelevel,%
        \the\tikzcountchildi,\the\tikzcountchildii,\the\tikzcountchildiii,
        rotation=\pgfutil@tempb,sibling angle=\pgfkeysvalueof{/tikz/sibling angle}}%
    \pgftransformrotate{\pgfutil@tempb}%
    \pgftransformxshift{\the\tikzleveldistance}%
}
\makeatother
                
                
\tikzset{%
mmap/.cd,
    name/.initial=undef,
    overall rotation/.initial   = 0,
    overall xshift/.initial     = 0pt,
    overall yshift/.initial     = 0pt,
    sign/.initial               = 1,                
    child weight/.initial       = 0.5,      
    rotation/.initial           = 0.5,
    shape angle/.initial        = 180,      
    distance to 1/.initial      = 4.5cm,        
    distance to 2/.initial      = 7.5cm,        
    distance to 3/.initial      = 10cm,     
    distance to 4/.initial      = 12cm,     
    distance to 5/.initial      = 14cm,     
    offset level 3/.initial     = 0,        
/tikz/.cd,
    offset angle/.initial=0, 
    Xshift/.style={xshift=#1,mmap/overall xshift=#1},
    Yshift/.style={yshift=#1,mmap/overall yshift=#1},
%    branch color/.style={
%        concept color=#1!80,
%        ball color=#1!50,
%        every child/.append style={concept color=#1!50},
%    },
}


%----------------------------------------------
% Style of the mindmap
%----------------------------------------------
\tikzset{mymmstyle/.style 2 args={
    text width=1.5cm,
    align=flush center,
    mindmap,
    Julien growth,
    mmap/overall rotation=\pgfkeysvalueof{/tikz/mmap/rotation},
    mmap/sign   = 1,
    mmap/name   = semicirc, %<- you need unique names if you want to use several mindmaps
    every node/.style={
        concept,
        circular drop shadow, 
        execute at begin node=\hskip0pt,
        text=#2,
    },  
    node font=\sffamily,
    nodes={concept},
    concept color=#1,
    root concept/.append style={
        ball color=#1, 
        line width=1.5ex,
        text=#2,
        font=\LARGE\bfseries\scshape,
        minimum size=3.25cm, 
        text width=3.25cm
    },                   
    level 1/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 1},%
        font=\large,%
        minimum size=2.5cm,%
        text width=2.0cm, 
        fill= #1!70,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(1)-1),1)}
    },
    level 2/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 2},%
        font=\normalsize,%
        minimum size=1.5cm,%
        text width=1.5cm, 
        fill= #1!50,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(2)-1),1)}
    },
    level 3/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 3},
        font=\normalsize,
        minimum size=1.5cm,
        text width=1.5cm, 
        fill= #1!30,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(3)-1),1)},
        offset angle=\pgfkeysvalueof{/tikz/mmap/offset level 3}
    },
    level 4/.style={%
        level distance=\pgfkeysvalueof{/tikz/mmap/distance to 4},
        font=\normalsize,
        minimum size=1cm,
        text width=1cm, 
        fill= #1!30,
        sibling angle/.evaluated={\pgfkeysvalueof{/tikz/mmap/shape angle}/max((MMapNodesAtLevel(4)-1),1)},
        offset angle=\pgfkeysvalueof{/tikz/mmap/offset level 4}
    },
}
}


%\newcommand{\MyMindMap}[2][mymmstyle={blue}{white}]{
%\begin{tikzpicture}[#1]    
%%  \begin{scope}[#1]   
%%  \input{#2}
%{#2}
%%  \end{scope}
%\end{tikzpicture}
%}

\begingroup
\def\begin#1\item{\iffalse{\else}\fi child \iftrue{node {\else}}\fi}
\def\end#1{\iffalse{\else}\fi}
\def\item{\iffalse{{\else}}\fi  child \iftrue{\else}\fi node \iftrue{\else}\fi}
\xdef\tmp{\iftrue{\else}\fi
    \begin{itemize}
        \item level 1
              \begin{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3 
                        \item level 3 
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3 
                        \item level 3 
                        \item level 3 
                      \end{itemize}
              \end{itemize}
        \item level 1
              \begin{itemize}
                \item level 2
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
              \end{itemize}
        \item level 1
              \begin{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
                \item level 2
                      \begin{itemize}
                        \item level 3
                        \item level 3
                      \end{itemize}
              \end{itemize}
    \end{itemize}
}}
\endgroup


\def\tmpstart#1{\node[root concept] {Root}}
\begin{document}

\begin{frame}
    \frametitle{Audience catching mindmap}


    
    \resizebox{\linewidth}{!}{
        \begin{tikzpicture}
            \begin{scope}[mymmstyle={orange}{orange!50!black}]
                \expandafter\tmpstart\tmp;
            \end{scope}
        \end{tikzpicture}
    }
\end{frame}


\end{document}

答案2

几点开场白:

  1. 没有合法的电子书pdf 来截取屏幕截图,我真的希望你有你付费购买的书的正版纸质版。¹

  2. TeXbook描述纯 TeX这与乳胶,其中之一就是列表的处理,因此它并不是一个适合用来尝试理解其itemize工作原理的地方。

回到我们的问题,我们需要重新定义\itemitemize环境来捕获它们的内容。顶层itemize与嵌套的 不同itemize

我首先想到的是:

  • \item将要

    • 如果这不是第一个\item,我们关闭标记的捕获并将其保存在某个地方(比如一个宏,\@itemdata(ZZ)-XX其中XX是项目的编号,ZZ是前缀,它将是(ZZ)-XX列表封闭项目的字符串,否则为空字符串。因为我们必须使用\csname...\endcsname来创建这个名字,所以没有理由不使用阿拉伯数字和破折号来分隔。

    • 对于\item列表中的所有 s,我们开始令牌捕获。

  • \end{itemize}将关闭 itemize 中最后一个列表的 token 捕获。它还应存储列表中项目的数量,例如\@itemcount(ZZ)

  • \begin{itemize}列表内部将前缀设置ZZ为当前(ZZ)-XX字符串,然后开始一个新列表。

鉴于上述情况,编码本身应该不会太难,但我现在应该在睡觉了,所以我暂时不会尝试。


  1. 尝试texbook.tex通过 TeX 运行未修改的 会给你一个警告,告诉你不应该这样做。虽然很容易绕过,但你不应该这样做。额外的轶事:早在 90 年代初期,TeXrox(Xerox 87xx/97xx 激光打印机的 DVI 驱动程序)的作者 Tom Reid 对texbook.texTexas A&M IBM 大型机上的 副本进行了小幅编辑,将其替换cmr10cmr1O。使用后一种字体打印的文档会标记该作业,违规用户会发现自己需要支付 的全额零售价TeXbook(收益已寄给 DEK),并有一份未装订的TeXbook没有索引(如果我没记错的话,旧副本中没有索引texbook.tex)。

相关内容