next up previous contents index
Next: Symbolic References shown as Up: No Title Previous: Arbitrary Tags and Attributes

  
Conditional Text

         

   
\begin{latexonly} and \begin{htmlonly}

Conditional text can be specified using the environments latexonly and htmlonly. These allow writing parts of a document which are intended only for electronic delivery or only for paper-based delivery.

This would be useful for example in adding a long description of a multi-media resource in the paper version of a document. Such a description would be redundant in the electronic version, as the user can have direct access to this resource.


Here is an example of the use of the latexonly environment, used earlier in this manual: \begin{latexonly}

\begin{figure}
    \begin{center}
    \fbox{\includegraphics[width=4in]{psfiles/eform.ps}}
    \end{center}
    \caption{An electronic form. Of course in the online version of this
     document the form above would be active.}
\end{figure}
\end{latexonly}

Note the warning concerning how the environment delimiters should be used in the LATEX source code.

 

  
\htmlonly...\endhtmlonly


change_begin97.1
This is an alternative way to specify a chunk of material intended for the HTML version only, using the old AMS-style of delimiting environments. Use of this style is discouraged; the htmlonly environment is preferred.
change_end 97.1

 

  
\latexonly...\endlatexonly


change_begin97.1
This is an alternative way to specify a chunk of material intended for the LATEX typeset version only, using the old AMS-style of delimiting environments. Use of this style is discouraged; the latexonly environment or the unscoped %begin{latexonly} construction are preferred.
change_end 97.1

Note the warning concerning how the environment delimiters should be used in the LATEX source code.

       

  
\latex, \html and \latexhtml


change_begin96.1
There are also shorthand notations to accomplish the same thing as in the latexonly environment and htmlonly environment, but with less typing. Warning: Only small pieces of text work reliably in this way. With whole paragraphs or contained sub-environments, the ``conditional'' environments should be used instead.
change_end 96.1

     

  
%begin{latexonly}

Another variant of the latexonly environment is available, in which everything between %begin{latexonly} and %end{latexonly} is ignored by LATEX2HTML. The difference is that the latexonly environment puts the contents into a group, in which all definitions are local. There is no such scoping with the %begin...%end variant, since LATEX sees the initial %s simply as starting comments.


 
The following example should clarify what happens:

\newcommand{\A}{The letter A.}
\newcommand{\B}{The letter B.}
\begin{latexonly}
\renewcommand{\A}{Not the letter A.}
\end{latexonly}
%begin{latexonly}
\renewcommand{\B}{Not the letter B.}
%end{latexonly}
\begin{document}
\A \B
\end{document}
If you process this with LATEX, the result is:         The letter A. Not the letter B.

Note the warning concerning how the environment delimiters should be used in the LATEX source code.


 
Warning: Be careful when using LATEX commands which alter the values of counters (e.g. numbered figures or equations) in conditional text, because this may cause the counter values in the electronic version to lose synchronisation with the values of the corresponding counters in the LATEX version.



   

  
\begin{imagesonly}


change_begin97.1
This environment is used to put LATEX code into the images.tex file, to be used when generating images. Typically this is used to add commands to the preamble of images.tex, such as setting the text or background color. However code can be added at any other point as well; e.g. to change the background color of all images after a certain point in the document.
change_end 97.1

Note the warning concerning how the environment delimiters should be used in the LATEX source code.

   

  
\begin{makeimage}


change_begin97.1
This is a special environment which forces an image to be made of its contents. That is, one gets effectively a snapshot of a portion of a page that has been typeset using LATEX. Within the normal LATEX typeset version of the document, this environment is completely transparent, adding its contents to the page as usual.

 
One further important use of the makeimage environment is as follows. If a makeimage environment occurs as a sub-environment within a figure environment, then an image will not be made of the figure's contents. Instead, the contents are treated as normal text, each part being handled as if there were no figure at all, except that everything is placed within a single cell of a <TABLE>...</TABLE> construction in HTML 3.2. The contents of any \caption commands are placed between <CAPTION>...</CAPTION> tags for the <TABLE>.

 
Normally an image of the entire contents of the figure would be placed within the single cell of the <TABLE>. Now images are made of any subparts of those figure's contents that really need it, in particular the makeimage sub-environments. An empty makeimage sub-environment does not generate an image of itself, yet still it inhibits an image being made of the whole figure. These comments apply also to table environments.
change_end 97.1


next up previous contents index
Next: Symbolic References shown as Up: No Title Previous: Arbitrary Tags and Attributes
root
1998-02-23