"Fossies" - the Fresh Open Source Software Archive

Member "hevea-2.35/examples/trouble.tex" (16 Jan 2021, 7979 Bytes) of package /linux/www/hevea-2.35.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TeX and LaTeX source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 \documentclass{article}
    2 
    3 \usepackage{alltt}
    4 \usepackage{hevea}
    5 \newcommand{\rbox}[2]{$^{\mbox{#2}}$}
    6 \newcommand{\lbox}[2]{$_{\mbox{#2}}$}
    7 \begin{latexonly}
    8 \gdef\myrule{\rule{10cm}{.05ex}}
    9 \gdef\htmlout{\begingroup\parskip=0pt\parindent=0pt\begin{quote}\myrule\par}
   10 \gdef\endhtmlout{\par\myrule\end{quote}\endgroup}
   11 \end{latexonly} 
   12 \begin{htmlonly}
   13 \gdef\myrule{\@print{<HR NOSHADE SIZE=1 ALIGN=leftWIDTH=75%>
   14 }}%
   15 \gdef\htmlout{\begin{quote}\myrule}
   16 \gdef\endhtmlout{\myrule\end{quote}}
   17 \end{htmlonly}
   18 \newenvironment{latexout}{\begin{htmlout}}{\end{htmlout}}
   19 \title{How to spot and correct some trouble}
   20 \begin{document}
   21 \maketitle
   22 
   23 \section{Simple corrections}
   24 Most of the problems that occur during the translation of a given
   25 \LaTeX\ file (say \verb+trouble.tex+) can be solved at
   26 the macro-level. That is, most problems can be solved by writing a few
   27 macros. The best place for these macros is an user-style file (say
   28 \verb+trouble.sty+) given as
   29 argument to \htmlgen.
   30 \begin{verbatim}
   31 # htmlgen trouble.sty trouble.tex
   32 \end{verbatim}
   33 By doing so, the macros written specially for \htmlgen\ are not
   34 seen by \LaTeX. Even better, \verb+trouble.tex+ is not changed
   35 at all.
   36 
   37 Of course, this will be easier if the \LaTeX\ source is written in a
   38 generic style, using macros.
   39 Note that this style is recommended anyway, since it eases the changing
   40 and tuning of documents.
   41 
   42 \subsection{\htmlgen\ does not know a macro}
   43 Consider the following \LaTeX\ source excerpt:
   44 \begin{verbatim}
   45 You can \raisebox{.6ex}{\em raise} text.
   46 \end{verbatim}
   47 
   48 \LaTeX\ typesets this as follows:
   49 \begin{htmlout}
   50 \begin{htmlonly}
   51 %% BEGIN IMAGE      
   52 You can \raisebox{.6ex}{\em raise} text.
   53 %% END IMAGE
   54 \imageflush
   55 \end{htmlonly}      
   56 \begin{latexonly}
   57 You can \raisebox{.6ex}{\em raise} text.
   58 \end{latexonly}
   59 \end{htmlout}
   60 
   61 Since \htmlgen\ does not know about \verb+raisebox+,
   62 it uncorrectly processes this input. More precisely,
   63 it first prints a warning message:
   64 \begin{verbatim}
   65 trouble.tex:34: Unknown macro: \raisebox
   66 \end{verbatim}
   67 Then, it goes on by translating the arguments of \verb+\raisebox+ as
   68 there were normal text. As a
   69 consequence some \verb+.6ex+ is finally found in the html output:
   70 \begin{htmlout}
   71 \begin{latexonly}
   72 You can .6ex{\em raise} text.
   73 \end{latexonly}
   74 \begin{htmlonly}
   75 You can \raisebox{.6ex}{\em raise} text.
   76 \end{htmlonly}
   77 \end{htmlout}
   78 
   79 To correct this, you should provide a macro that more or less has the effect of
   80 \verb+raisebox+. It is difficult, yet impossible, to write a generic
   81 \verb+raisebox+ macro for \htmlgen. However, in this case, the effect
   82 of \verb+\raisebox+ is to raise the box {\em a little}.
   83 Thus, the first, numerical, argument to \verb+\raisebox+  can be
   84 ignored:
   85 \begin{verbatim}
   86 \newcommand{\raisebox}[2]{$^{\mbox{#2}}$}
   87 \end{verbatim}
   88 
   89 Now, tranlating the document yields:
   90 \begin{htmlout}
   91 \renewcommand{\raisebox}[2]{$^{\mbox{#2}}$}%
   92 You can \raisebox{.6ex}{\em raise} text a little.
   93 \end{htmlout}
   94 Of course this will work only when all \verb+\raisebox+ in the document
   95 raise text a little. Consider, for instance, this example, where text
   96 is both raised a lowered a little:
   97 \begin{verbatim}
   98 You can \raisebox{.6ex}{\em raise} or \raisebox{-.6ex}{\em lower} text.
   99 \end{verbatim}
  100 Which \LaTeX, renders as follows:
  101 \begin{htmlout}
  102 \begin{htmlonly}
  103 %% BEGIN IMAGE
  104 You can \raisebox{.6ex}{\em raise} or \raisebox{-.6ex}{\em lower} text.
  105 %% END IMAGE
  106 \imageflush
  107 \end{htmlonly}
  108 \begin{latexonly}
  109 You can \raisebox{.6ex}{\em raise} or \raisebox{-.6ex}{\em lower} text.
  110 \end{latexonly}
  111 \end{htmlout}
  112 Whereas, with the above definition of \verb+\raisebox+, \htmlgen\ produces:
  113 \begin{htmlout}
  114 \renewcommand{\raisebox}[2]{$^{\mbox{#2}}$}%
  115 You can \raisebox{.6ex}{\em raise} or \raisebox{-.6ex}{\em lower} text.
  116 \end{htmlout}
  117 
  118 
  119 A solution is to add a new macro definition in the \verb+trouble.sty+ file:
  120 \begin{verbatim}
  121 \newcommand{\lowerbox}[2]{$_{\mbox{#2}}$}
  122 \end{verbatim}
  123 Then, \verb+trouble.tex+ itself has to be modified a little.
  124 \begin{verbatim}
  125 You can \raisebox{.6ex}{\em raise} or \lowerbox{-.6ex}{\em lower} text.
  126 \end{verbatim}
  127 {\htmlgen} now produces a satisfying output:
  128 \begin{htmlout}
  129 \begin{latexonly}\renewcommand{\raisebox}[2]{$^{\mbox{#2}}$}%
  130 \newcommand{\lowerbox}[2]{$_{\mbox{#2}}$}
  131 You can \raisebox{.6ex}{\em raise} or \lowerbox{-.6ex}{\em lower} text.
  132 \end{latexonly}
  133 \begin{htmlonly}\newcommand{\raisebox}[2]{$^{\mbox{#2}}$}%
  134 \newcommand{\lowerbox}[2]{$_{\mbox{#2}}$}
  135 You can \raisebox{.6ex}{\em raise} or \lowerbox{-.6ex}{\em lower} text.
  136 \end{htmlonly}
  137 \end{htmlout}
  138 
  139 \subsection{\htmlgen\ uncorrectly interprets a macro}
  140 
  141 Sometimes \htmlgen\ knows about a macro, but the produced hthml
  142 is obviously wrong.
  143 This kind of errors is a little more difficult to spot than the
  144 previous one because the translator does not issue a warning. Here you
  145 have to look a the output.
  146 Consider, for instance, this definition:
  147 \begin{verbatim}
  148 \newcommand{\blob}{\rule[.2ex]{1ex}{1ex}}
  149 \blob\ Blob \blob
  150 \end{verbatim}
  151 Which \LaTeX typesets as follows:
  152 \begin{latexout}
  153 \begin{htmlonly}
  154 \begin{toimage}\newcommand{\blob}{\rule[.2ex]{1ex}{1ex}}
  155 \blob\ Blob \blob
  156 \end{toimage}
  157 \imageflush
  158 \end{htmlonly}
  159 \end{latexout}
  160 \htmlgen\ always translate \verb+\\rule+ by \verb+<HR>+, ignoring size
  161 arguments.
  162 Hence, it here produces the following, wrong, output:
  163 \begin{htmlout}\newcommand{\blob}{\rule[.2ex]{1ex}{1ex}}
  164 \begin{htmlonly}
  165 \blob\ Blob \blob
  166 \end{htmlonly}
  167 \end{htmlout}
  168 
  169 There is not small square in the symbol font used by \htmlgen.
  170 However there are other small symbols that would perfectly do the job
  171 of \verb+\blob+, such as a small bullet (\verb+\bullet+ in \LaTeX).
  172 Thus you may choose to define \verb+\blob+ in \verb+trouble.sty+ as:
  173 \begin{verbatim}
  174 \newcommand{\blob}{\bullet}
  175 \end{verbatim}
  176 This new definition yields the following, more satisfying output:
  177 \begin{htmlout}\newcommand{\blob}{\bullet}
  178 \begin{htmlonly}
  179 \blob\ Blob \blob
  180 \end{htmlonly}
  181 \end{htmlout}
  182 
  183 \subsection{\htmlgen\ crashes with a \protect\texttt{html:} failure}
  184 
  185 Such an errors may have many causes, including a bug in \htmlgen.
  186 However, it may also steem from a wrong \LaTeX\ input.
  187 Thus this section is to be read before reporting a bug\ldots
  188 
  189 In  the following source, environments are not properly balanced:
  190 \begin{verbatim}
  191 \begin{flushright}
  192 \begin{quote}
  193 This is right-flushed quoted text.
  194 \end{flushright}
  195 \end{quote}
  196 \end{verbatim}
  197 Such a source will make both {\LaTeX} and {\htmlgen} choke.
  198 Thus, when {\htmlgen} crashes, it is a good idea to check that the
  199 input is correct by running {\LaTeX} on it.
  200 
  201 
  202 Unfortunatly, {\htmlgen} may crash on input that does not affect
  203 \LaTeX.
  204 Such errors are likely to appear when processiong {\TeX}ish input,
  205 such as found in style files.
  206 Consider for instance the following ``optimized'' version of a
  207 \verb+quoteright+  environment:
  208 \begin{verbatim}
  209 \newenvironment{quotebis}{\quote\flushright}{\endquote}
  210 
  211 \begin{quotebis}
  212 This a right-flushed quotation
  213 \end{quotebis}
  214 \end{verbatim}
  215 
  216 {\LaTeX} produces the expected output:
  217 \begin{latexout}
  218 \begin{toimage}
  219 \newenvironment{quotebis}{\quote\flushright}{\endquote}
  220 \begin{quotebis}
  221 This is a right-flushed quotation
  222 \end{quotebis}
  223 \end{toimage}\imageflush[ALIGN=right]\\
  224 \end{latexout}
  225 
  226 However, as {\htmlgen} often translates {\LaTeX} environments by html
  227 opening and  closing tags and that it refuses to generate obviously
  228 non-correct html, it crashes:
  229 \begin{verbatim}
  230 trouble.tex:8: Adios
  231 Fatal error: uncaught exception Failure("hml: BLOCKQUOTE closes DIV")
  232 \end{verbatim}
  233 
  234 In this case the solution is easy: environments must be opened and
  235 closed consistently. {\LaTeX} style being recommended, one should write:
  236 \begin{verbatim}
  237 \newenvironment{quotebis}
  238   {\begin{quote}\begin{flushright}}
  239   {\end{flushright}\end{quote}}
  240 \end{verbatim}
  241 And we get:
  242 \begin{htmlout}\newenvironment{quotebis}{\begin{quote}\begin{flushright}}{\end{flushright}\end{quote}}
  243 \begin{quotebis}
  244 This is a right-flushed quotation
  245 \end{quotebis}
  246 \end{htmlout}
  247 
  248 \end{document}