Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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}
share|improve this answer
    
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 at 15:29

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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