![]() | ![]() | ![]() | LaTeX versus Html mode | Contents | Index |
LaTeX versus Html mode
The easiest way to put a command or text in your document that is only
included in one of the two output modes it by using a \texonly
or \htmlonly command. They ignore their argument, if in the
wrong mode, and otherwise simply expand it:
We are now in \texonly{\LaTeX}\htmlonly{HTML}-mode.
In cases such as this you can simplify the notation by using the
\texorhtml command, which has two arguments:
We are now in \texorhtml{\LaTeX}{HTML}-mode.
Another possibility is by prefixing a line with \T or
\W. \T acts like a comment in HTML-mode, and as a noop
in LaTeX-mode, and for \W it is the other way round:
We are now in \T \LaTeX-mode. \W HTML-mode.
The last way of achieving this effect is useful when there are large
chunks of text that you want to skip in one mode--a HTML-document
might skip a section with a detailed mathematical analysis, a
LaTeX-document will not contain a node with lots of hyperlinks to
other documents. This can be done using the iftex and
ifhtml environments:
We are now in
\begin{iftex}
\LaTeX-mode.
\end{iftex}
\begin{ifhtml}
HTML-mode.
\end{ifhtml}
In LaTeX, commands that are defined inside an enviroment are
"forgotten" at the end of the environment. So LaTeX commands
defined inside a iftex environment are defined, but then
immediately forgotten by LaTeX.
A simple trick to avoid this problem is to use the following idiom:
\W\begin{iftex}
... command definitions
\W\end{iftex}
Now the command definitions are correctly made in the Latex, but not in the Html version.
Instead of the iftex environment, you can
also use the tex environment. It is different from iftex only if
you have used \NotSpecial in the preamble.
The environment latexonly has been provided as a service to
latex2html users. Its effect is the same as iftex.
![]() | ![]() | ![]() | LaTeX versus Html mode | Contents | Index |