Annotation of loncom/html/adm/help/tex/Print_Tricks.tex, revision 1.6
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:
14: General information about printing within LonCAPA is also available:
15: \ref{Print_Resource}
16:
1.5 foxr 17: \emph{The print rendition of some Perl functions looks ugly }
18:
19: In particular these functions are:
20: \begin{itemize}
21: \item \&prettyprint
22: \item \&dollarformat
23: \item \&xmlparse
24: \item \&chemparse
25: \end{itemize}
26:
1.2 foxr 27:
1.1 foxr 28: To make these two functions work correctly within the print translator, it is
1.3 felicia 29: necessary to wrap them within a <display> tag. For example:
1.1 foxr 30:
31: \begin{verbatim}
32: <p>
1.4 felicia 33: If I had <display>&prettyprint(100,'$2f')</display>
1.1 foxr 34: </p>
35: \end{verbatim}
36:
1.4 felicia 37: Note that the \texttt{<display>} tags must be tightly wrapped around the function call or
1.5 foxr 38: you will get a syntax error in web presentation mode. For additional information
39: about cases where you must use \texttt{<display>}, see ``Variables with tags don't print
40: correctly'' below.
1.1 foxr 41:
42:
1.5 foxr 43: \emph{Image placement and alignment and text wrapping is wrong}
1.2 foxr 44:
1.1 foxr 45: Unfortunately this is due to a large difference between the LaTeX and HTML page
46: layout model. In HTML images are placed exactly where you ask them to be placed.
1.5 foxr 47: In LaTeX, images are considered {\em floats}, which LaTeX will place for you.
48: Some of the common html tricks, using tables e.g. to control text wrapping around
49: figures, will not always work in print mode; especially if the text is to the
50: right side of the figure in the table.
51:
52: The alignment choice
53: affects whether or not the print rendering engine attempts to get text to wrap around the
54: image. With \texttt{align=``right''} or \texttt{align=``left''}, the print rendering engine
55: attempts to use the {\em wrapfigure}
56: environment to place text around the figure at the
57: appropriate side. If a figure is in a table, then the print engine, by default,
58: the print engine will use wrapfigure, set the alignment to ``right''
59: unless you override it. Otherwise, the default alignment is ``bottom'' as it
60: is for html, and no wrapping will occur.
61:
1.6 ! albertel 62: \verb+\parpic+ style wrapping is also available by specifying \texttt{TeXwrap=``parpic''}
1.5 foxr 63: in the <img> tag. In some limited casese this gives a better result.
64:
65:
66: Other print specific <img> tag attributes are available. \ref{Print_Options}.
67:
68:
1.1 foxr 69:
1.2 foxr 70: \emph{Variables with tags don't print correctly}
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:
92:
93:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>