4 Adapting to the media

 4.1 Selecting sections

You may wish the hypertext version of your document to differ from the paper version. To restrict text to the paper version, use the environment:

\begin{latexonly}
This text will only appear in the LATEX version.
\end{latexonly}

To restrict text to the hypertext version, use the environment:

\begin{htmlonly}
This text will only appear in the hypertext version.
\end{htmlonly}

Note:

Single lines of HTML-only and LATEX-only text can be controlled using the commands:

\html{text for the hypertext version}

and

\latex{text for the paper version}

Or you could use the conditional statement:

text for the \latexhtml{paper}{hypertext} version.

4.1 Selecting sections

If you want to have a section that only appears in the paper version of your document, then your document preamble must define new commands to replace the LATEX sectioning commands, for example:

  % Latex only sections, subsections etc.
  % Use these in a latexonly environment.
  \providecommand{\latexonlysection}[1]{\section{#1}}
  \providecommand{\latexonlysubsection}[1]{\subsection{#1}}
  \providecommand{\latexonlysubsubsection}[1]{\subsubsection{#1}}
  

You must then use these new commands instead of the normal sectioning commands, for example:

\begin{latexonly}
\latexonlysection{LaTeX readers beware...}
LaTeX readers are missing out by not reading the HTML version of this document.
\end{latexonly}

If a sectioning command appears in an htmlonly environment, you get the warning message “Cannot find \end{htmlonly}”, but the result should be satisfactory.