next up previous
Next: 5. Hypertext Up: A Short Beginner-User's Guide Previous: 3. Making a (simple)

    
4. Conditionality

It can be convenient to have the possibility to distinguish the behaviour of the source file when processed by LATEX or by HTML. This can be done by defining specific environments, as:


${\tt\backslash begin \left \{ latexonly \right \} ...\backslash end \left \{ latexonly \right \} }$ and

${\tt\backslash begin \left \{ htmlonly \right \} ...\backslash end \left \{ htmlonly \right \} }$.

or by commands, as:


${\tt\backslash latex \left \{ ...\right \} }$ and ${\tt\backslash html \left \{ ...\right \} }$.


Warning: This latter commands are only intended for very short arguments (e.g. some words) inside the brace pairs.

Here is an example of the syntax for conditional environments:

${\tt\backslash begin \left \{ latexonly \right \} }$

This will be printed only by LaTeX

${\tt\backslash begin \left \{ latexonly \right \} }$


${\tt\backslash begin \left \{ htmlonly \right \} }$

This will be printed only by LaTeX2HTML

${\tt\backslash begin \left \{ htmlonly \right \} }$

Here is an example of the syntax for conditional in-line commands:

${\tt\backslash latex \left \{ \right. }$ this will be printed only by LaTeX ${\tt\left. \right \} }$

${\tt\backslash html \left \{ \right. }$ this will be printed only by LaTeX2HTML ${\tt\left. \right \} }$


Warning (BUG): Even if these two types of conditional environment seem to be well-behaved for simple commands (like text input), they fail fro more complex command. For instance if you want to define a different text-size for screen and paper version, the following sequence does not work:

${\tt\backslash begin \left \{ latexonly \right \} }$

${\tt\backslash small \;\;\; \backslash sf}$

${\tt\backslash begin \left \{ latexonly \right \} }$


${\tt\backslash begin \left \{ htmlonly \right \} }$

${\tt\backslash large \;\;\; \backslash rm}$

${\tt\backslash begin \left \{ htmlonly \right \} }$

The "latexonly" part is not taken into account. In the same way, the following sequence does not work properly:

${\tt\backslash latex \left \{ \backslash small \;\;\; \backslash sf\right \} }$

${\tt\backslash html \left \{ \backslash large \;\;\; \backslash rm \right \} }$

The "html" sequence is not taken into account. However, the following sequence has been found to work:

${\tt\backslash latex \left \{ \backslash small \;\;\; \backslash sf\right \} }$

${\tt\backslash begin \left \{ htmlonly \right \} }$

${\tt\backslash large \;\;\; \backslash rm}$

${\tt\backslash begin \left \{ htmlonly \right \} }$


next up previous
Next: 5. Hypertext Up: A Short Beginner-User's Guide Previous: 3. Making a (simple)
Pierre BENARD
2002-06-19