### 4 Adapting to the media

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:

• The \begin{htmlonly}, \end{htmlonly}, \begin{latexonly} and \end{latexonly} statements should be on separate lines from other text or LATEX commands.
• Both text and commands may be included within the environments, but problems can arise if they contain any of the LATEX sectioning commands (see “Selecting sections”, Section 4.1).

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}
If a sectioning command appears in an htmlonly environment, you get the warning message “Cannot find \end{htmlonly}”, but the result should be satisfactory.