ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Bruce Horrocks <ntg@scorecrow.com>
Subject: Re: Anyone managed a tabulated table of contents
Date: Mon, 25 May 2020 17:47:03 +0200	[thread overview]
Message-ID: <3be09efa-bea4-794c-dfd0-ff88a9e5a18d@xs4all.nl> (raw)
In-Reply-To: <3041DE68-440B-4574-9040-67E8BF2AB6FD@scorecrow.com>

On 5/25/2020 2:40 PM, Bruce Horrocks wrote:
> I can't be the first to have wanted to try something like this. Is it possible to use tabulate (or any of the table types) to customise the layout of the table of contents?
> 
> I'd like 4 columns - title, subject, author and page - where subject and author will (eventually) be additional parameters supplied to \startchapter. Bonus points if it works in interactive mode as well.
> 
> Minimum non-working example below. This generates the 4 column values per chapter heading but they run together into a single paragraph as if the table formatting was not present.
> 
> %%% Begin %%%
> \setuppapersize [A4] [A4]
> \setupinteraction [state=start]
> \setuplist [chapter]
>    [ alternative=command, %interactive
>      command=\myTOCrow,
>      before=\myTOCbefore,
>      after=\myTOCafter
>    ]
> 
> % #1 == Section number; #2 == text; #3 == page number
> \define[3]\myTOCrow{\NC #2 \NC dummy \NC John Doe \NC #3 \NC\NR }
> 
> \define\myTOCbefore{
>    \starttabulate[|pw(8.75cm)|l|lw(4.2cm)|r|]
>    \NC \underbars{Title}
>    \NC \underbars{Subject}
>    \NC \underbars{Author}
>    \NC \underbars{Page}
>    \NC\NR
> }
> 
> \define\myTOCafter{%
>    \stoptabulate }
> 
> \starttext
> \title{Tabulated Table of Contents}
> \placelist[chapter]
> 
> \startchapter[title=Tufte 1]
> \input tufte
> \stopchapter
> 
> \startchapter[title=Tufte 2]
> \input tufte
> \stopchapter
> \stoptext
> %%% End %%%
It's hard. Maybe I need to make a more low level accessor for that but 
multipass etc gets in the way. When you knwo the dimensions you can do 
this:

\usemodule[article-basic]

\definelistalternative
   [whatever]
   [renderingsetup=whatever]

\setuplist
   [chapter]
   [alternative=whatever]

\startsetups whatever
     \framed [offset=overlay,frame=off] {
         \framed [width=25mm,align=flushleft,frame=off,offset=0pt] {
             number: \currentlistentrynumber
         }
         \framed [width=4cm,align=normal,frame=off,offset=0pt] {
             title: \currentlistentrytitle
         }
         \framed [width=4cm,align=normal,frame=off,offset=0pt] {
             author: \structurelistuservariable{author}
         }
         \framed [width=2cm,align=flushright,frame=off,offset=0pt] {
             page: \currentlistentrypagenumber
         }
     }
\stopsetups

\starttext

     \starttitle[title={Tabulated Table of Contents}]
         \placelist[chapter]
     \stoptitle

     \dorecurse {3} {
         \startchapter[title=Covid 9][author=Cuomo]
             \input cuomo
         \stopchapter
     }

\stoptext


Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2020-05-25 15:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25 12:40 Bruce Horrocks
2020-05-25 15:47 ` Hans Hagen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3be09efa-bea4-794c-dfd0-ff88a9e5a18d@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    --cc=ntg@scorecrow.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).