\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}
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
.