6

I'm trying to create a slideshow in TeX using Opmac.

I need a page layout like that: enter image description here

And I try 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

% set font
\letfont\titfont=\tenbf at18pt 
\letfont\subfont=\tenbf at16pt 

% set header
\headline={\ifnum\folio=1\hfill\else{\hbox to\hsize{\hfil \subfont \firstmark \hfil}}\fi}

% set footer
\newtoks\leftfoot \leftfoot={\hfill Footer text}
\newtoks\rightfoot \rightfoot={\hfill \subfont\folio} 
\footline={\ifnum\folio=1\hfill\else\the\leftfoot\the\rightfoot\fi}

\def\tocline#1#2#3#4#5{{\leftskip=#1\iindent \rightskip=2\iindent
   \ifischap\advance\leftskip by\iindent\fi
   \ifnum#1>1 \advance\leftskip by\iindent\fi
   \toclinehook \noindent\llap{#2\toclink{#3}\enspace}%
         {#2#4\unskip}\nobreak\nobreak\hskip-2\iindent\null\par}}

% 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}

\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}



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

\tit Slideshow in \TeX

\pg

\hbox{\hbox to0cm{\vtop{\hsize=6cm \subfont \noindent TOC:

\maketoc}} \hskip6cm \hbox to0cm{\vtop{\hsize=10cm {\nonum\sec First slide

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

\pg\kuk

\nonum\sec Second slide

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

\pg\kuk

\nonum\sec Third slide

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

\enditems
\end
\kuk

But the result is:

enter image description here

There is no header (\firstmark does not work) and the macro \kuk also does not work. There are also ugly black strikes after \hbox. How can I fix it?

Please only a plain-tex solution.

Thank you very much!

  • you can get rid of the "black strikes" either by setting \overfullrule=0pt or seeing how overfull those \hboxes are by looking in the log, and setting \hfuzz= a value just slightly larger than the reported overage. (the other problems are more complicated, and i don't have easy solutions.) – barbara beeton Jun 15 '15 at 16:10
  • 2
    @barbarabeeton The overfull boxes are caused by \hbox to 0cm{\vtop{\hsize=6cm ...}}. This can be fixed by \hbox to 0cm{...\hss} or putting the following \hskip 6cm into the first \hbox specification: \hbox to 6cm{\vtop{\hsize=6cm ...}}. The second overfull box is fixed in a similar way. – Heiko Oberdiek Jun 15 '15 at 16:33
  • @HeikoOberdiek -- thanks. i just took the easy, "brute force" approach. your approach is much better, as it attacks the problem, not just the symptom. – barbara beeton Jun 15 '15 at 16:36
  • You can be inspired by the ctuslides code, which uses opmac and implements more features to \kuk macro (dealing with verbatim text, renamed to \pg here). See petr.olsak.net/ftp/olsak/ctustyle/slides.pdf – wipet Jun 16 '15 at 14:43
8

Overfull \hbox messages

The overfull boxes are caused by

\hbox to 0cm{\vtop{\hsize=6cm ...}}

Material with width 6 cm is larger than 0 cm. This can be fixed by adding \hss at the end of the \hbox:

\hbox to 0cm{...\hss}

In this particular case, the 6 cm reappear after the box in \hskip6cm.

Thus the \hskip can be removed and added to the first \hbox specification:

\hbox to 6cm{\vtop{\hsize=6cm ...}}

The second overfull box by the next \hbox to 0cm{...} can be fixed in the same ways.

\firstmark not working for slide "First slide".

The \sec command calls \insertmark, which sets the \mark. But the section "First slide" is inside a vertical box \vtop. The mark moves from paragraphs or from inside \hbox to the enclosing vertical box. But this \vtop is not the main vertical list, the \mark remains captured and is therefore lost.

As workaround, the mark can be set manually:

\pg
\mark{First slide}
\hbox{\hbox ...\vtop{...\sec First slide ...

\kuk not working

\tracingmacros=1 reveals:

\kukstart #1\kuk ->\addto \kukdata {#1} [...]
#1<-\par \tit Slideshow in \TeX \par \pg \par \hbox {\hbox to0cm{\vtop {\hsize =6cm \subfont \noindent TOC: \par \maketoc }\hss
 } \hskip 6cm \hbox to0cm{\vtop {\hsize =10cm {\nonum \sec First slide \par \kuk * First item \kuk * Second item \kuk * Third item }}\hss }} \par \pg 

When TeX looks for delimited arguments, then it reads anything until the delimiter. But the argument before must comply with the rule, that curly argument braces must be properly nested. Until the a closing brace is not found, it does not look for the delimiter. Thus the \kuk on the first slide are hidden inside several brace pairs of \hbox and \vtop. (Here the curly braces could be relaced by \bgroup and \egroup, but the trouble comes then later, when the chunks are executed without the missing \egroup tokens.

As workaround, LaTeX package atbegshi can also be used in plain TeX. Then the table of contents could be set by overlaying the output page and the normal slide contents is set normally without surrounding box commands.

Example:

\input opmac
%\chyph

\input atbegshi.sty
\AtBeginShipoutInit
\def\abshook{}
\AtBeginShipout{\abshook{}}

\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

% set font
\letfont\titfont=\tenbf at18pt 
\letfont\subfont=\tenbf at16pt 

% set header
\headline={\ifnum\folio=1\hfill\else{\hbox to\hsize{\hfil \subfont \firstmark \hfil}}\fi}

% set footer
\newtoks\leftfoot \leftfoot={\hfill Footer text}
\newtoks\rightfoot \rightfoot={\hfill \subfont\folio} 
\footline={\ifnum\folio=1\hfill\else\the\leftfoot\the\rightfoot\fi}

\def\tocline#1#2#3#4#5{{\leftskip=#1\iindent \rightskip=2\iindent
   \ifischap\advance\leftskip by\iindent\fi
   \ifnum#1>1 \advance\leftskip by\iindent\fi
   \toclinehook \noindent\llap{#2\toclink{#3}\enspace}%
         {#2#4\unskip}\nobreak\nobreak\hskip-2\iindent\null\par}}

% 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}

\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}


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

\tit Slideshow in \TeX

\pg
\kuk

\def\abshook{%
  \immediate\write16{* ABS, page: \the\count0}%
  \setbox\AtBeginShipoutBox=\hbox{%
    \setbox0=\hbox to 0pt{%
      \dimen0=\vsize
      \advance\dimen0 by 1.2cm
      \raise\dimen0\vtop to 0pt{%
        \kern0pt
        \bigskip
        \hsize=6cm
        \leftskip=\iindent
        \subfont
        \noindent TOC:

        \maketoc
        \par
        \vss
      }%
      \hss
    }%
    \ht0=0pt
    \dp0=0pt
    \wd0=0pt
    \copy0
    \copy\AtBeginShipoutBox
  }%
}

\leftskip=6cm

\nonum\sec First slide

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

\pg\kuk

\leftskip=0pt
\def\abshook{}

\nonum\sec Second slide

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

\pg\kuk

\nonum\sec Third slide

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

\enditems
\end
\kuk

Variant with \prepghook

\input opmac
%\chyph

\def\prepghook{%
  \vbox to0pt{%
    \kern-\voffset
    \kern-1in
    \hbox to0pt{%
      \kern-\hoffset
      \kern-1in
      \background
      \hss
    }%
    \vss
  }%
  \nointerlineskip
  \vbox to 0pt{%
    \kern 0pt
    \hbox to 0pt{%
      \kern-\iindent
      \tochook
      \hss
    }%
    \vss
  }%
  \nointerlineskip
}
\pdfximage width\pdfpagewidth height\pdfpageheight {tiger.pdf}
\mathchardef\picbackground=\pdflastximage
\def\background{\pdfrefximage\picbackground}
\let\pgfhook\prepghook
\def\tochook{}

\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

% set font
\letfont\titfont=\tenbf at18pt
\letfont\subfont=\tenbf at16pt

% set header
\headline={\ifnum\folio=1\hfill\else{\hbox to\hsize{\hfil \subfont \firstmark \hfil}}\fi}

% set footer
\newtoks\leftfoot \leftfoot={\hfill Footer text}
\newtoks\rightfoot \rightfoot={\hfill \subfont\folio}
\footline={\ifnum\folio=1\hfill\else\the\leftfoot\the\rightfoot\fi}

\def\tocline#1#2#3#4#5{{\leftskip=#1\iindent \rightskip=2\iindent
   \ifischap\advance\leftskip by\iindent\fi
   \ifnum#1>1 \advance\leftskip by\iindent\fi
   \toclinehook \noindent\llap{#2\toclink{#3}\enspace}%
         {#2#4\unskip}\nobreak\nobreak\hskip-2\iindent\null\par}}

% 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}

\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}


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

\tit Slideshow in \TeX

\pg
\kuk

\def\tochook{%
  \immediate\write16{* ABS, page: \the\count0}%
  \setbox0=\vtop to 0pt{%
    \kern0pt
    \bigskip
    \hsize=6cm
    \leftskip=\iindent
    \subfont
    \noindent TOC:

    \maketoc
    \par
    \vss
  }%
  \ht0=0pt
  \dp0=0pt
  \wd0=0pt
  \copy0
}

\leftskip=6cm

\nonum\sec First slide

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

\pg\kuk

\leftskip=0pt
\def\tochook{}

\nonum\sec Second slide

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

\pg\kuk

\nonum\sec Third slide

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

\enditems
\end
\kuk
  • Thanks a lot, your answer help me. I have tried use atbegshi package but I find only some LaTeX examples. Could you explain me, how can I use it in TeX in my case...? Or do you know any web with the examples, please? – Maurever Jun 15 '15 at 19:41
  • I used your example, but if I set a background \def\prepghook{\vbox to0pt{\kern-\voffset\kern-1in \hbox to0pt{\kern-\hoffset\kern-1in\background\hss}\vss} \nointerlineskip } \pdfximage width\pdfpagewidth height\pdfpageheight {background_1.pdf} \mathchardef\picbackground=\pdflastximage \def\background{\pdfrefximage\picbackground}, the text is under this background. How can I set the box above the background..? Thank you – Maurever Jun 16 '15 at 12:50
  • @Mori The code in the comment define some macros, but they are unused and do not add anything. – Heiko Oberdiek Jun 16 '15 at 13:24
  • The macro sets the file "background_1.pdf" as the background... There is a result: postimg.org/image/x6ucbks4r. – Maurever Jun 16 '15 at 13:33
  • @Mori The code in the comment only defines \prepghook, \picbackground and \background. Neither of them are used in my version of opmac (April 2015) nor in the code of the question. Thus I do not know, how the background image is added. If this works for you, then you could add the table of contents on top of the background image in the hook \prepghook. That should not be too difficult for a plain TeX user. – Heiko Oberdiek Jun 16 '15 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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