4

I'm trying to create a slideshow in TeX using Opmac. But when I use macros \kuk and \maketoc, there are duplicities in table of content.

Is any possibility to generate the line in the toc only for a new section? Or read the toc without duplicities..?

I need just get a list of sections and use it on a slide as a progress bar.

For example I have this code:

\input opmac
\chyph

\margins/1 a5l (1,1,1,1.2)cm        % page format
\input ctimes  \typosize[17/22]      % font

\def\pg{\vfil\break}                % new page
\begitems                           % start items

% slideshow with \kuk     
\let\kuk=\relax 
\def\kukdata{}
\long\def\kukstart#1\kuk{\addto\kukdata{#1}%
   \tmpnum=0 \def\endkukdata{}\expandafter\sumkuk \kukdata\sumkuk
   \kukdata\endkukdata \vfil\break \kukstart
}
\long\def\sumkuk#1{\ifx#1\sumkuk
   \loop \ifnum\tmpnum>0 \addto\endkukdata{\enditems}\advance\tmpnum by-1 \repeat
   \else 
     \ifx#1\begitems \global\advance\tmpnum by1 \fi 
     \ifx#1\enditems \global\advance\tmpnum by-1 \fi
     \expandafter\sumkuk \fi
}
\count1=1  
\def\advancepageno{\ifx\kukdata\empty \global\advance\pageno by1 \global\count1=1
                   \else \global\advance\count1 by1 \fi}
\def\pg{\def\kukdata{}\vfil\break}

\kukstart                           % if \kukstart in comment, it prints document normal

\tit Slideshow in \TeX

\pg

\notoc\nonum\sec Table of content

\maketoc

\pg\kuk

\nonum\sec First section

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\pg\kuk

\nonum\sec Second section

\kuk
* First item 
\kuk
* Second item 
\kuk
* Third item

\enditems
\end
\kuk

This is the result (I have been using pdfcslplain):

result

But I need this:

wanted result

Please only plain TeX solution.

Thank you.

2 Answers 2

3

I redefine \sec to compare the argument to the previous one and write the note in the .ref file only if they differ.

Of course this will fail if you have two consecutive sections with the same title.

\input opmac
\chyph

\margins/1 a5l (1,1,1,1.2)cm        % page format
\input ctimes  \typosize[17/22]      % font

\def\pg{\vfil\break}                % new page
\begitems                           % start items

% slideshow with \kuk     
\let\kuk=\relax 
\def\kukdata{}
\long\def\kukstart#1\kuk{\addto\kukdata{#1}%
   \tmpnum=0 \def\endkukdata{}\expandafter\sumkuk \kukdata\sumkuk
   \kukdata\endkukdata \vfil\break \kukstart
}
\long\def\sumkuk#1{\ifx#1\sumkuk
   \loop \ifnum\tmpnum>0 \addto\endkukdata{\enditems}\advance\tmpnum by-1 \repeat
   \else 
     \ifx#1\begitems \global\advance\tmpnum by1 \fi 
     \ifx#1\enditems \global\advance\tmpnum by-1 \fi
     \expandafter\sumkuk \fi
}
\count1=1  
\def\advancepageno{\ifx\kukdata\empty \global\advance\pageno by1 \global\count1=1
                   \else \global\advance\count1 by1 \fi}
\def\pg{\def\kukdata{}\vfil\break}

\def\sec#1\par{\ifnonum\else \global\advance\secnum by1 \fi
  \sechook {\globaldefs=1 \seccnum=0 \tnum=0 \fnum=0 \dnum=0}\relax
  \edef\thesecnum{\othe\chapnum.\the\secnum}\let\thetocnum=\thesecnum 
  \def\dotocnumafter{%
    \def\current{#1}%
    \ifx\current\old\else\wcontents\Xsec{#1}\gdef\old{#1}\fi}%
  \printsec{#1\unskip}\resetnonumnotoc
}



\kukstart                           % if \kukstart in comment, it prints document normal

\tit Slideshow in \TeX

\pg

\notoc\nonum\sec Table of content

\maketoc

\pg\kuk

\nonum\sec First section

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\pg\kuk

\nonum\sec Second section

\kuk
* First item 
\kuk
* Second item 
\kuk
* Third item

\enditems
\end
\kuk

enter image description here

I left Table of content, but beware it should be “contents”.

1
  • Thank you very much, this is great solution. And of course it should be "contents", my mistake.
    – Maurever
    Commented Jun 9, 2015 at 12:13
2

I would tackle the problem by making the behaviour of \sec variable: you only want to write to the TOC on the first use per page. That can be done a few ways, perhaps the easiest is with a switch. Just showing the code added to your example (before the first page):

\newif\iffirstslide

\def\sec#1\par{\ifnonum\else \global\advance\secnum by1 \fi
  \sechook {\globaldefs=1 \seccnum=0 \tnum=0 \fnum=0 \dnum=0}\relax
  \edef\thesecnum{\othe\chapnum.\the\secnum}\let\thetocnum=\thesecnum
  \iffirstslide
    \def\dotocnumafter{\wtotoc1\rm{#1}}%
  \else
    \def\dotocnumafter{}%
  \fi
  \firstslidefalse 
  \printsec{#1\unskip}\resetnonumnotoc
}

\def\pg{\def\kukdata{}\firstslidetrue\vfil\break}

Depending on the real use case, you might need one switch per section level, detection of the first slide per page or similar to cover subsections and so on.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .