3

Compiling with htlatex the following small2e.tex

\documentclass{article}        % Your input file must contain these two lines 
\begin{document}               % plus the \end{document} command at the end.

\section{Simple Text}          % This command makes a section title.

Words are separated by one or more spaces.  Paragraphs are separated by
one or more blank lines.
\end{document}

Creates a nice html file but with an empty title (it contains <title></title>). Is there a way to force tex4ht to output a title?

Using the following line in a private configuration file:

\HCode{<title>} My title \HCode{</title>}

simply adds "My title" as a title, but does not substitute the empty one, thus creating validation problems.

2 Answers 2

5

In case that you don't want a printed title: You can use in the private .cfg (needs naturally a \title command in the document):

\begin{document}
\makeatletter
\Configure{TITLE+}{\@title}      
\makeatother

In your document you can also use

\begin{document}
\makeatletter
\Tag{TITLE+}{\@title}
1
  • Thanks, @Ulrike! It looks as though one can just put \Tag{TITLE+}{My title} after the \begin{document} and dispense with \title and \makeatletter if there is no other use for \title
    – Nat Kuhn
    Sep 20, 2014 at 15:29
6

tex4ht works in the same way as ordinary LaTeX with regard to titles. You declare your title with the \title{My Amazing Document} and then use it with the command \maketitle. You can also define \author{Me} and \date{\today} (note that the use command is just a single invocation of \maketitle).

\documentclass{article}

\title{Sample Document}
\author{Me, Myself, and I}
\date{\today}
\begin{document}
\maketitle
\section{Simple Text}

Words are separated by one or more spaces.
Paragraphs are separated by one or more blank lines.
\end{document}

The above results in a correct <title>Sample Document</title> in the head of resulting HTML document.

You must log in to answer this question.

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