Annotation of loncom/html/adm/help/tex/Print_Tricks.tex, revision 1.10

1.1       foxr        1: \label{Print_Tricks}
                      2: 
1.3       felicia     3: When you print a LON-CAPA resource, the XML of your resource is translated into
1.1       foxr        4: LaTeX.  The LaTeX is then processed and turned into a PDF document which can 
                      5: be displayed with your browser's Acrobat plugin and subsequently printed.
                      6: 
                      7: There are several problems that crop up both due to limitations in the XML to LaTeX
                      8: translation and due to differences in the model used by web browsers to render
                      9: HTML and LaTeX to compose print pages.  This document provides information
                     10: about some of these problems and, where possible, solutions, and tricks to work 
                     11: around them.  If you have a printing trick or a problem and would like to report 
                     12: it, please go to  http://bugs.lon-capa.org and register a bug report.
                     13: 
1.7       lira       14: General information about printing within LonCAPA is also available in section 
                     15: \ref{Print_Resource}. Some types of problems that may occur include:
1.1       foxr       16: 
1.7       lira       17: \null
                     18: \noindent\textbf{The print rendition  of some Perl functions looks ugly }
1.5       foxr       19: 
                     20: In particular these functions are:
                     21: \begin{itemize}
                     22:    \item \&prettyprint
                     23:    \item \&dollarformat
                     24:    \item \&xmlparse
                     25:    \item \&chemparse
                     26: \end{itemize}
                     27: 
1.2       foxr       28: 
1.1       foxr       29: To make these two functions work correctly within the print translator, it is
1.9       raeburn    30: necessary to wrap them within a \texttt{$<$display$>$} tag.  For example:
1.1       foxr       31: 
                     32: \begin{verbatim}
                     33: <p>
1.4       felicia    34: If I had <display>&prettyprint(100,'$2f')</display>
1.1       foxr       35: </p>
                     36: \end{verbatim}
                     37: 
1.4       felicia    38: Note that the \texttt{<display>} tags must be tightly wrapped around the function call or
1.5       foxr       39: you will get a syntax error in web presentation mode.  For additional information
                     40: about cases where you must use \texttt{<display>}, see ``Variables with tags don't print
                     41: correctly'' below.
1.1       foxr       42: 
1.7       lira       43: \null
                     44: \noindent\textbf{Image placement and alignment and text wrapping is wrong}
1.2       foxr       45: 
1.1       foxr       46: Unfortunately this is due to a large difference between the LaTeX and HTML page
                     47: layout model.  In HTML images are placed exactly where you ask them to be placed.  
1.5       foxr       48: In LaTeX, images are considered {\em floats}, which LaTeX will place for you.  
                     49: Some of the common html tricks, using tables e.g. to control text wrapping around
                     50: figures, will not always work in print mode; especially if the text is to the
                     51: right side of the figure in the table.
                     52: 
                     53: The alignment choice 
                     54: affects whether or not the print rendering engine attempts to get text to wrap around the 
1.8       lira       55: image.  With \texttt{align="right"} or \texttt{align="left"}, the print rendering engine
1.5       foxr       56: attempts to use the {\em wrapfigure} 
                     57: environment to place text around the figure at the
                     58: appropriate side.  If a figure is in a table, then the print engine, by default, 
                     59: the print engine will use wrapfigure, set the alignment to ``right'' 
                     60: unless you override it.  Otherwise, the default alignment is ``bottom'' as it 
                     61: is for html, and no wrapping will occur.  
                     62: 
1.8       lira       63: \verb+\parpic+ style wrapping is also available by specifying \texttt{TeXwrap="parpic"}
1.10    ! lira       64:  in the \texttt{$<$img$>$} tag.  In some limited casese this gives a better result.
1.5       foxr       65: 
                     66: 
1.10    ! lira       67: Other print specific \texttt{$<$img$>$} tag attributes are available (see section \ref{Print_Options}).
1.1       foxr       68: 
1.7       lira       69: \null
                     70: \noindent\textbf{Variables with tags don't print correctly}
1.2       foxr       71: 
1.1       foxr       72: If a variable contains XML, in general it is necessary to force the XML parser
                     73: to make a pass over the contents of the contents of the variable prior to rendering
1.5       foxr       74: the section of the resource that contains that substitution. When output,
                     75: those variables must be bracketed inside of \texttt{<display> </display>} tags.
                     76:  For example:
1.1       foxr       77: 
                     78: \begin{verbatim}
1.2       foxr       79: <problem>
                     80: <script type="loncapa/perl">
                     81: $a = &xmlparse('<br />');
                     82: </script>
                     83: <startouttext />
                     84: <p>This is a break <display>$a</display> and then some more text</p>
                     85: <endouttext />
                     86: </problem>
                     87: \end{verbatim}
1.1       foxr       88: 
1.2       foxr       89: Without the xmlparse call and the display tag bracketing the variable, this
                     90: problem will display on the web just fine, but print incorrectly.
1.1       foxr       91: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>