4

via Tex4ht with frames, using the configuration file cc.cfg

\Preamble{xhtml,mathml,sections+,ext=htm,charset="utf-8",2,frames}

\Configure{@HEAD}{\HCode{<title>Good Morning</title>\Hnewline}}
\Configure{@HEAD}{\HCode{<link rel="profile" href="http://gmpg.org/xfn/11" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link rel="shortcut icon"  href="css/images/favicon.ico" />\Hnewline}}


\Configure{BODY}
{%
  \HorFrames{*,3*}\Frame{s1}\Frame[ name="f2"]{s2}
  \NoFrames
  \PushStack\eBody{}
  \SubConfig

  \HPage[p1]{hello}\Link{}{s1}\EndLink
  \bgroup
  \Configure{Link}{a}{target="f2" href=}{name=}{}
  \tableofcontents
  \egroup
  \EndHPage{p1} \Tg<br />

  \HPage[p2]{text2222}\Link{}{s2}\EndLink
    }
    {  \EndHPage{p2}}
    \Configure{DOCTYPE}
    {\HCode{<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
\Hnewline  "http://Hello1">\Hnewline}}

  \def\SubConfig{%
  \Configure{BODY}
   {\PushStack\eBody{x}\Tg<body>}
   {\PopStack\eBody\temp
 \ifx \temp\empty \EndFrames \else\Tg</body>\fi}

  \Configure{DOCTYPE}
   {\HCode{%
     <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     \Hnewline "http://Hello2"> \Hnewline}}

   }
    \begin{document}  


    \EndPreamble

I am trying to compile the following tex file site_test.tex

\documentclass{book}
%\usepackage[latin1]{inputenc}
\usepackage{inputenc}
\usepackage[english]{babel}
\pdfcompresslevel=9
\usepackage{minitoc}  

\begin{document}

\dominitoc

\title{This is a title}
\date{Today is today}
\author{Joe}

\maketitle
\tableofcontents

\chapter{Chapter alpha}
\section{Alpha prime}
\section{Alpha secundus}
\subsection{Hello}
\subsection{Ciao}

\chapter{Chapter beta}
\section{bye}
\section{Here you are}

\end{document}

via the command (on MikteX Windows 8)

 htlatex site_test.tex "cc.cfg"

and I obtain the following outputenter image description here

I have some problems with it I would like to adress

  1. The page should be called "Good Morning" via

    \Configure{@HEAD}{\HCode{<title>Good Morning</title>\Hnewline}}
    

    but it takes the title of the document "This is a title" (the icon works)

  2. I am trying to put title, date and author above the table of content, so far no success.

  3. In the table of content, there are 2 "contents". How to remove at least one ?

  4. (Does anyone know a way to improve the site by modifying the css file ?)

I understant the global structure of the code but not enough. I can post the HTML ouputs if necessary. Does anyone has a working example ? Any help is welcome :)

2
  • 1
    update : in order to deal with the margin, replace the corresponding line by \HorFrames{*,3*}\Frame[ marginwidth="20" name="f1"]{s1}\Frame[ marginwidth="20" name="f2"]{s2}
    – Jocelyn
    Commented Jul 3, 2016 at 14:13
  • 1
    update : you can add an horizontal frame by defining \VerFrames{*,3*}\Frame{v1} together with defining\Hpage[v1].... as explained by @jagath.
    – Jocelyn
    Commented Jul 3, 2016 at 14:17

1 Answer 1

4

I think this might be helpful. The \tableofcontents used in the TeX file is now commented as this cause the duplication of the Contents title in the frame. The modified TeX file is given below:

\documentclass{book}
%\usepackage[latin1]{inputenc}
\usepackage{inputenc}
\usepackage[english]{babel}
\pdfcompresslevel=9
\usepackage{minitoc}  

\begin{document}

\dominitoc

\title{This is a title}
\date{Today is today}
\author{Joe}

\maketitle
%\tableofcontents

\chapter{Chapter alpha}
\section{Alpha prime}
\section{Alpha secundus}
\subsection{Hello}
\subsection{Ciao}

\chapter{Chapter beta}
\section{bye}
\section{Here you are}

\end{document}

I will now try to answer your queries:

  1. The content which is provided as the argument of \title command will appear inside <title>...</title> in the HTML. If you want to get rid of the default text, there is an easy dirty way to do that:

     \Configure{TITLE}{\HCode{<title>}\special{t4ht@[}}{\special{t4ht@]}Good Morning\HCode{</title>\Hnewline}}
    

All the characters between \special{t4ht@[} and \special{t4ht@]} will be ignored and the real content of the title will now be stripped and your custom title Good Morning will now appear as title. Earlier in your case, the browser uses the first <title>...</title> element to display the title.

  1. It is not easy to put the values of \title, \author and \date to toc at first compilation. Hence, I have redefined the standard commands so that its arguments is written to auxiliary file on first compilation as \Title, \Author and \Date respectively. Please note that now I have not considered handling the optional arguments if available by default.

    \let\Title\@empty
    \let\Author\@empty
    \let\Date\@empty
    \def\title#1{\gdef\@title{#1}
    \immediate\write\@auxout{\string\gdef\string\Title{#1}}}
    \def\author#1{\gdef\@author{#1}
    \immediate\write\@auxout{\string\gdef\string\Author{#1}}}
    \def\date#1{\gdef\@date{#1}
    \immediate\write\@auxout{\string\gdef\string\Date{#1}}}
    

These commands were now added to the toc, before \tableofcontents command as:

\HPage[p1]{hello}\Link{}{s1}\EndLink
\bgroup
\Tg<span class="likechapterToc" >
\Tg<a target="f2" href="\jobname4.html\#s2" name="">\Title\Tg</a>
\Tg</span>\Tg<br />
\Tg<span class="likechapterToc" >
\Tg<a target="f2" href="\jobname4.html\#s2" name="">\Author\Tg</a>
\Tg</span>\Tg<br />
\Tg<span class="likechapterToc" >
\Tg<a target="f2" href="\jobname4.html\#s2" name="">\Date\Tg</a>
\Tg</span>\Tg<br />
\Configure{Link}{a}{target="f2" href=}{name=}{}
\tableofcontents
\egroup
\EndHPage{p1} \Tg<br />
  1. As we remove the \tableofcontents command from the TeX file, the duplicate entry from the toc frame now disappeared.

  2. That might be off-topic. But someone can come up with a good suggestion.

Hence, the updated cfg is as given below:

\Preamble{xhtml,mathml,sections+,ext=htm,charset="utf-8",2,frames}

\Configure{TITLE}{\HCode{<title>}\special{t4ht@[}}{\special{t4ht@]}Good Morning\HCode{</title>\Hnewline}}
\Configure{@HEAD}{\HCode{<link rel="profile" href="http://gmpg.org/xfn/11" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link rel="shortcut icon"  href="css/images/favicon.ico" />\Hnewline}}

\makeatletter
\let\Title\@empty
\let\Author\@empty
\let\Date\@empty
\def\title#1{\gdef\@title{#1}
\immediate\write\@auxout{\string\gdef\string\Title{#1}}}
\def\author#1{\gdef\@author{#1}
\immediate\write\@auxout{\string\gdef\string\Author{#1}}}
\def\date#1{\gdef\@date{#1}
\immediate\write\@auxout{\string\gdef\string\Date{#1}}}
\Configure{BODY}
{\Tg<a id="title"/>%
  \HorFrames{*,3*}\Frame{s1}\Frame[ name="f2"]{s2}
  \NoFrames
  \PushStack\eBody{}
  \SubConfig

    \HPage[p1]{hello}\Link{}{s1}\EndLink
    \bgroup
    \Tg<span class="likechapterToc" >
    \Tg<a target="f2" href="\jobname4.html\#s2" name="">\Title\Tg</a>
    \Tg</span>\Tg<br />
    \Tg<span class="likechapterToc" >
    \Tg<a target="f2" href="\jobname4.html\#s2" name="">\Author\Tg</a>
    \Tg</span>\Tg<br />
    \Tg<span class="likechapterToc" >
    \Tg<a target="f2" href="\jobname4.html\#s2" name="">\Date\Tg</a>
    \Tg</span>\Tg<br />
    \Configure{Link}{a}{target="f2" href=}{name=}{}
    \tableofcontents
    \egroup
    \EndHPage{p1} \Tg<br />

  \HPage[p2]{text2222}\Link{}{s2}\EndLink
    }
    {  \EndHPage{p2}}
    \Configure{DOCTYPE}
    {\HCode{<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
\Hnewline  "http://Hello1">\Hnewline}}

  \def\SubConfig{%
  \Configure{BODY}
   {\PushStack\eBody{x}\Tg<body>}
   {\PopStack\eBody\temp
 \ifx \temp\empty \EndFrames \else\Tg</body>\fi}

  \Configure{DOCTYPE}
   {\HCode{%
     <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     \Hnewline "http://Hello2"> \Hnewline}}

   }
\makeatother
    \begin{document}  


    \EndPreamble
2
  • I would not have been able to modify as such. Thanks a lot @Jagath , it works well !
    – Jocelyn
    Commented Jul 3, 2016 at 8:45
  • @Jocelyn Happy to hear it worked.
    – Jagath
    Commented Jul 3, 2016 at 11:13

You must log in to answer this question.

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