File:  [LON-CAPA] / loncom / html / adm / help / tex / Print_Tricks.tex
Revision 1.10: download - view: text, annotated - select for diffs
Mon Dec 28 04:10:45 2015 UTC (8 years, 7 months ago) by lira
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, HEAD
fixing LATEX quotes and angle brackets.

    1: \label{Print_Tricks}
    2: 
    3: When you print a LON-CAPA resource, the XML of your resource is translated into
    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: 
   14: General information about printing within LonCAPA is also available in section 
   15: \ref{Print_Resource}. Some types of problems that may occur include:
   16: 
   17: \null
   18: \noindent\textbf{The print rendition  of some Perl functions looks ugly }
   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: 
   28: 
   29: To make these two functions work correctly within the print translator, it is
   30: necessary to wrap them within a \texttt{$<$display$>$} tag.  For example:
   31: 
   32: \begin{verbatim}
   33: <p>
   34: If I had <display>&prettyprint(100,'$2f')</display>
   35: </p>
   36: \end{verbatim}
   37: 
   38: Note that the \texttt{<display>} tags must be tightly wrapped around the function call or
   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.
   42: 
   43: \null
   44: \noindent\textbf{Image placement and alignment and text wrapping is wrong}
   45: 
   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.  
   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 
   55: image.  With \texttt{align="right"} or \texttt{align="left"}, the print rendering engine
   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: 
   63: \verb+\parpic+ style wrapping is also available by specifying \texttt{TeXwrap="parpic"}
   64:  in the \texttt{$<$img$>$} tag.  In some limited casese this gives a better result.
   65: 
   66: 
   67: Other print specific \texttt{$<$img$>$} tag attributes are available (see section \ref{Print_Options}).
   68: 
   69: \null
   70: \noindent\textbf{Variables with tags don't print correctly}
   71: 
   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
   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:
   77: 
   78: \begin{verbatim}
   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}
   88: 
   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.
   91: 

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