Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to place a small table of contents in the footer in ConTeXt, which only shows the sections within the current chapter, but it does not appear. This is what I tried:

\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

This results in an empty footer on all pages.

How can I place a table of contents list for the sections contained within the current chapter in the footer of my document?

share|improve this question

2 Answers 2

up vote 6 down vote accepted
+150

You have to put the table of contents in a box. Here I used the framedtext, which puts the content in a \vbox. You can also use \framed[align=normal]. Then I changed the criterium to chapter to only show the sections of the current chapter. It's not clear if you want to list everything belonging to the current chapter or only the sections. Change the first argument to \placelist accordingly.

% 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

The result:

result

share|improve this answer
    
This code breaks as soon as there are deeper structure depths (e.g. subsections). To limit the list to sections only you need to request the level explicitly: \placelist[section][alternative=d, criterium=chapter, number=2]. –  phg May 1 '12 at 16:48
1  
The code doesn't break, but it lists all content including subsections. What does number do? –  Marco May 1 '12 at 18:05
    
number is needed to bypass the test in strc-reg.lua, line 150 because the default is zero. (Code seems to be alpha anyways.) –  phg May 1 '12 at 18:34

With \placelist[listname] you can restrict the list placement. Then adjust the list content via the number and criterium keys:

\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

table of contents in footer

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.