如何在 ConTeXt 的页脚中放置一个小的目录?

如何在 ConTeXt 的页脚中放置一个小的目录?

我想在 ConTeXt 的页脚中放置一个小目录,它只显示当前章节中的部分,但它没有出现。这是我尝试过的:

\setupfootertexts[\setups{text c}][\setups{text c}][\setups{text c}][\setups{text c}]
\startsetups[text c]
    \midaligned{\placecontent[alternative=d, criterium=local]}
\stopsetups
\starttext
    \chapter{This is a chapter title}
        This is some text.
        \section{This is a section title}
            This is some more text.
        \section{This is another section title}
            This is yet some more text.
        \chapter{This is another chapter title}
            This is still some more text.
\stoptext

这会导致所有页面的页脚都为空。

如何在文档页脚中放置当前章节所含部分的目录列表?

答案1

您必须将目录放在一个框中。这里我使用了framedtext,它将内容放在 中\vbox。您也可以使用\framed[align=normal]。然后我将 更改criteriumchapter以仅显示当前章节的章节。不清楚您是想列出属于当前章节的所有内容还是仅列出章节。\placelist相应地将第一个参数更改为。

% Provides the fake words
\usemodule [visual]

\setupbodyfont [18pt]

\setupfootertexts [\setups{footertoc}] [\setups{footertoc}]

\startsetups [footertoc]
  \startframedtext [width=\textwidth, align=middle, frame=off]
    % remove subsection to only list the sections
    \placelist [section,subsection]
      [
        alternative=d,
          criterium=chapter,
             number=2,
      ]
  \stopframedtext
\stopsetups

\starttext

\startchapter [title=First Chapter]
  \startsection [title=Foo]
    \fakewords{30}{30}
  \stopsection
  \startsection [title=Bar]
    \fakewords{30}{30}
  \stopsection
  \startsection [title=Lorem]
    \fakewords{30}{30}
  \stopsection
\stopchapter

\startchapter [title=Second Chapter]
  \startsection [title=Ipsum]
    \fakewords{30}{30}
  \stopsection
  \startsection [title=Dolor]
    \fakewords{30}{30}
  \stopsection
  \startsection [title=Sit]
    \fakewords{30}{30}
  \stopsection
\stopchapter

\stoptext

结果:

结果

答案2

使用\placelist[listname]可以限制列表位置。然后通过numbercriterium键调整列表内容:

\setupfootertexts [\setups{text c}] [\setups{text c}] 

\defineframed [footerframed] [
  align=middle,
  frame=off,
  height=\footerheight,
  width=\textwidth,
]

\startsetups [text c]
  \footerframed{%
    \placelist[section][  %% limit depth to section
      alternative=d,
      criterium=chapter,  %% local to chapter
      number=2,           %% request a structure depth
    ]
  }
\stopsetups
\starttext
\dorecurse{5}{
  \chapter{This is a chapter title}
    This is some text.
    \section{This is a section title}
      This is some more text.
    \section{This is another section title}
      This is yet some more text.
      \subsection{Deep Nesting}
        This is yet some more text.
      \subsection{doesn’t break}
        This is yet some more text.
      \subsection{the list!}
        This is yet some more text.
    \section{Yet another section title}
      This is yet some more text.
}
\stoptext

页脚中的目录

相关内容