Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plain TeX TOC Macros

26 views
Skip to first unread message

Bob Kerstetter

unread,
Nov 3, 2023, 10:13:48 PM11/3/23
to
Hi

After using LaTeX for 20-ish years, I am attempting to learn TeX, starting with macros for document structure and table of contents. In my first try (listed below):

1. document section titles format and print as expected.
2. \jobname.toc file contains same page number for every entry.
3. toc does not show up in document.

I have searched here, the general web, stack exchange,Tugboat archives. I have also read docs for ePlain, OPmac, plus others. Of course, I have read The TeXBook.

I am a journalist by education and practice, but developed in-house software some in Basic years ago. I use the Templar static site generator for my website, so I have a tiny bit of Perl knowledge. The point being, I am not a programmer, but am somewhat tuned in to development ways and means.

The sample contains everything. Using \show did not help.

Any ideas about how to fix toc page numbers and toc not showing up in doc are appreciate.

Thanks,

Bob Kerstetter

%start macros
% open toc file
\newwrite\TOCfile
\immediate\openout\TOCfile=\jobname.toc

\def\writeTOC#1#2{%
\immediate\write\TOCfile{#2\quad\leaders\hbox{.}\hfill#1\par}%
}

% input toc
\def\toc{%
\closeout\TOCfile
\input \jobname.toc
}

% title
\def\Title#1{%
\vglue 0.30\vsize % Move down 30% of the page height
\centerline{\bf #1} % Title formatting
\vfill % Fill the remaining space on the page
\vfill\break % Page break
}

% sections
\def\Chapter#1{%
\writeTOC{\the\pageno}{#1}% write toc
\vfill\break %pagebreak before
{\centerline{\bf #1}} % Group formatting
}

\def\Section#1{%
\writeTOC{\the\pageno}{#1}% write toc
\bigskip % space before
\noindent{\bf #1\par} % Group formatting
}

\def\Subsection#1{%
\writeTOC{\the\pageno}{#1}% write toc
\smallskip % space before
\noindent{\it #1\par} % Group formatting
}
% end macros

% start doc
\Title{Title}
\toc % input toc

\Chapter{Chapter}
Chapter text.

\Section{Section}
Text for section.

\Subsection{Subsection}
Text for subsection.

\Chapter{Another Chapter}
Another chapter text.

\bye


vip SLOT

unread,
Nov 3, 2023, 10:14:55 PM11/3/23
to
SITUS SLOT REKOMENDASI
TOGEL DENGAN DISKON TERBESAR + BONUS BESAR
SLOT DENGAN BONUS YANG MELIMPAH DENGAN RTP TERBAIK

https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip
https://bandot.vip

Holger Schieferdecker

unread,
Nov 7, 2023, 11:22:04 AM11/7/23
to
Hi Bob,

unfortunately I can't help you with your question. But I want to inform
you that at least some users filter postings coming from googlegroups.
Especially in the last weeks there has been a lot of spam by Google
posters. Maybe the people who might be able to help you don't see your
posting. Therefore I just repeat it.

Holger

Julian Bradfield

unread,
Nov 7, 2023, 2:40:09 PM11/7/23
to
On 2023-11-07, Holger Schieferdecker <spam...@gmx.de> wrote:
> Hi Bob,
>
> unfortunately I can't help you with your question. But I want to inform
> you that at least some users filter postings coming from googlegroups.
> Especially in the last weeks there has been a lot of spam by Google
> posters. Maybe the people who might be able to help you don't see your
> posting. Therefore I just repeat it.

Including me, for example. I junk them all.

To the OP:

I think you need to read the chapter on Output Routines.

You have the \writeTOC before the relevant pagebreak for the chapter.
And in general it gets executed when read, which in normal
pagebreaking might be before the page is updated.

The reason toc doesn't appear is that it's always empty: you've just
opened it for writing and cleared it. You need to read and print the
toc *before* opening it.

This stuff is messy, so you *really* need to fully understand the
internals and the output routines if you're going to roll your own.

Peter Flynn

unread,
Nov 7, 2023, 5:54:07 PM11/7/23
to
On 04/11/2023 03:13, Bob Kerstetter wrote:

> After using LaTeX for 20-ish years, I am attempting to learn TeX,

Brave man :-)

> starting with macros for document structure and table of contents. In
> my first try (listed below):
>
> 1. document section titles format and print as expected.
> 2. \jobname.toc file contains same page number  for every entry.
> 3. toc does not show up in document.

The trick with a .toc file is that it's (obviously) the first time
round. After that, it gets written to by headings until the end of the
document. To typeset the ToC, you must read it *before* anything writes
to it.

> %start macros
> % open toc file
> \newwrite\TOCfile
> \immediate\openout\TOCfile=\jobname.toc

I think this will wipe out anything in it. You need to move this line to
*after* the file has been used for input.
> \def\writeTOC#1#2{%
>    \immediate\write\TOCfile{#2\quad\leaders\hbox{.}\hfill#1\par}%
> }

I don't think it has to be \immediate because you're not trying to
re-use it immediately (ie in the same run). But I may be wrong on that.
>
> % input toc
> \def\toc{%
>     \closeout\TOCfile
>     \input \jobname.toc
> }

The file won't be open at this stage, assuming you want the ToC (from
the previous run) at the start of the document, before anything new gets
written to it, so you need to remove the \closeout line. The \input
should then work, and must be followed by the \openout line from above,
so it's ready for use.

But it's been a long time since I played with this.

Peter

Bob Kerstetter

unread,
Nov 10, 2023, 10:38:32 AM11/10/23
to
On Tuesday, November 7, 2023 at 10:22:04 AM UTC-6, Holger Schieferdecker wrote:

> unfortunately I can't help you with your question. But I want to inform
> you that at least some users filter postings coming from googlegroups.
> Especially in the last weeks there has been a lot of spam by Google
> posters. Maybe the people who might be able to help you don't see your
> posting. Therefore I just repeat it.

Thanks.

Yeah, I also figured out reporting spam was useless at one-to-two messages a minute. Maybe I'll start playing the slots. ;)

Bob Kerstetter

unread,
Nov 27, 2023, 6:20:09 PM11/27/23
to
Thanks. I read some of The TeXBook and also TUGBoat articles. Found what worked.
0 new messages