2 // FEATURE: <code type="c++"/> -- syntax highlighting
3 // FEATURE: <code linenumbers="true"/> -- LaTeX moreverb package can help
4 // FIXME: nest TextNodes within each other for bold+italic
5 // FEATURE: property tree
10 import org.ibex.util.*;
12 public class Doc extends XML {
14 public static boolean slides = false;
17 Vec nodeStack = new Vec();
19 char[] buffer = new char[1024 * 1024];
24 public static void main(String[] s) throws Exception {
25 if (s.length > 0 && "slides".equals(s[0])) slides = true;
27 Reader r = new InputStreamReader(System.in);
30 int numread = r.read(d.buffer, len, d.buffer.length - len);
31 if (numread == -1) break;
33 if (len >= d.buffer.length) {
34 char[] newbuffer = new char[d.buffer.length * 2];
35 System.arraycopy(d.buffer, 0, newbuffer, 0, d.buffer.length);
39 d.parse(new CharArrayReader(d.buffer));
40 StringBuffer sb = new StringBuffer();
42 System.out.println(sb);
45 public void startElement(Element e) throws Exn {
46 if (preStart != -1) return;
48 Node target = (Node)nodeStack.lastElement();
49 if (target == null) target = (Node)victim;
51 if (pending.length() > 0) target.addText(pending);
55 String name = e.getLocalName();
57 if (name.equals("ibex-doc")) { newGuy = new Root(e);
58 } else if (name.equals("section")) { newGuy = new Section(e);
59 } else if (name.equals("heading")) { newGuy = new Heading(e);
60 } else if (name.equals("appendix")) { newGuy = new Appendix(e);
61 } else if (name.equals("list")) { newGuy = new List();
63 } else if (name.equals("pre")) { preStart = getGlobalOffset();
65 } else if (name.equals("definition")) { newGuy = new Definition(e);
66 } else if (name.equals("math")) { newGuy = new Math(e);
67 } else if (name.equals("property")) { newGuy = new Property(e);
69 } else if (name.equals("link")) { newGuy = new Link(e);
70 } else if (name.equals("image")) { newGuy = new Image(e);
73 System.err.println("warning: unknown tag " + name);
77 Node parent = (Node)nodeStack.lastElement();
78 if (parent != null) parent.addChild(newGuy);
79 nodeStack.addElement(newGuy);
83 static Object victim = null;
85 public void whitespace(char[] ch, int start, int length) throws Exn, IOException { characters(ch, start, length); }
86 public void endElement(Element e) throws Exn, IOException {
88 Node target = (Node)nodeStack.lastElement();
89 if (target == null) target = (Node)victim;
91 if (!e.getLocalName().equals("pre")) return;
92 target.addChild(new PRE(preStart, getGlobalOffset()));
94 } else if (skip > 0) {
99 if (pending.length() > 0) target.addText(pending);
102 if (nodeStack.lastElement() instanceof Section) victim = nodeStack.lastElement();
103 nodeStack.setSize(nodeStack.size() - 1);
107 public void characters(char[] ch, int start, int length) throws Exn, IOException {
108 if (preStart != -1) return;
109 pending += new String(ch, start, length);
112 abstract class Node {
113 public Node parent = null;
114 public abstract void addText(String s);
115 public abstract void addChild(Node s);
116 public abstract void dumpLatex(StringBuffer sb);
117 final String fixLatex(String s) {
118 if (s == null) return "";
119 s = s.replaceAll("\\\\", "\\$\\\\backslash\\$");
120 s = s.replaceAll("\\$", "\\\\\\$");
121 s = s.replaceAll("\\\\\\$\\\\backslash\\\\\\$", "\\$\\\\backslash\\$");
122 s = s.replaceAll("\\{", "\\\\{");
123 s = s.replaceAll("\\}", "\\\\}");
124 s = s.replaceAll("\\*\\*([^\n]+?)\\*\\*", "{\\\\it{$1}}");
125 s = s.replaceAll("__([^\n]+?)__", "{\\\\textbf{$1}}");
126 s = s.replaceAll("\\[\\[([^\n]+?)\\]\\]", "{\\\\texttt{$1}}");
127 s = s.replaceAll("LaTeX", "\\\\LaTeX");
128 s = s.replaceAll("\\%", "\\\\% ");
129 s = s.replaceAll("#", "\\\\#");
130 s = s.replaceAll("\\&", "\\\\&");
131 s = s.replaceAll("\\~", "\\\\~");
132 s = s.replaceAll("_", "\\\\_");
133 s = s.replaceAll(" \"", " ``");
134 s = s.replaceAll("\"", "''");
140 // Empty Nodes //////////////////////////////////////////////////////////////////////////////
142 class EmptyNode extends Node {
143 public EmptyNode() { }
144 public void addChild(Node o) { throw new RuntimeException(this.getClass().getName() + " cannot have children"); }
145 public void addText(String o) { throw new RuntimeException(this.getClass().getName() + " cannot have content"); }
146 public void dumpLatex(StringBuffer sb) { }
149 class Image extends EmptyNode {
151 public String caption;
154 public Image(XML.Element e) {
155 url = e.getAttrVal("url"); caption = e.getAttrVal("caption"); width = e.getAttrVal("width");
156 align = e.getAttrVal("align");
158 public void dumpLatex(StringBuffer sb) {
159 if (url.endsWith(".pdf")) {
161 sb.append("\\begin{figure}[H]\n");
162 sb.append("\\begin{center}\n");
163 sb.append("\\epsfig{file="+url.substring(0, url.length() - 4)+",width=\\textwidth}\n");
165 sb.append("\\caption{"+fixLatex(caption)+"}\n");
166 sb.append("\\end{center}\n");
167 sb.append("\\end{figure}\n");
169 if ("left".equals(align)) {
170 sb.append("\\begin{wrapfigure}{l}{"+width+"}\n");
172 sb.append("\\begin{wrapfigure}{r}{"+width+"}\n");
174 sb.append("\\epsfig{file="+url.substring(0, url.length() - 4)+",width="+width+"}%\n");
176 sb.append("\\caption{"+fixLatex(caption)+"}\n");
177 sb.append("\\end{wrapfigure}\n");
180 sb.append("\\hyperimage{" + url + "}");
185 class Heading extends EmptyNode {
187 public Heading(XML.Element e) { text = e.getAttrVal("title"); }
188 public void dumpLatex(StringBuffer sb) { sb.append("\\vspace{.6cm}\\hypertarget{" +
189 fixLatex(text) + "}{\\textbf{\\textsf{" +
190 fixLatex(text) + "}}}"); }
193 class LineBreak extends EmptyNode {
194 public LineBreak() { }
195 public void dumpLatex(StringBuffer sb) { sb.append("\\\n"); }
198 class ParagraphBreak extends EmptyNode {
199 public ParagraphBreak() { }
200 public void dumpLatex(StringBuffer sb) { sb.append("\n\n"); }
205 // Non-Paragraph Nodes //////////////////////////////////////////////////////////////////////////////
207 /** Nodes which contain only text; they split themselves if anything else is added */
208 class TextNode extends Node implements Cloneable {
209 public String mytext = "";
210 private boolean canAcceptMoreText = true;
211 public void dumpLatex(StringBuffer sb) { sb.append(fixLatex(mytext)); }
212 public void addChild(Node o) { canAcceptMoreText = false; parent.addChild(o); }
213 public void addText(String o) {
214 if (canAcceptMoreText) {
216 String[] split = mytext.split("\\n\\s*\\n");
217 if (split.length <= 1) return;
218 canAcceptMoreText = false;
220 parent.addChild(new ParagraphBreak());
222 for(int i=1; i<split.length; i++) o += split[i] + "\n\n";
225 TextNode clone = (TextNode)clone();
227 clone.canAcceptMoreText = true;
228 parent.addChild(clone);
230 } catch (CloneNotSupportedException cnse) {
231 throw new RuntimeException(cnse);
236 class Link extends TextNode {
238 public String section;
239 public String appendix;
241 public Link(XML.Element e) {
242 url = e.getAttrVal("url"); if ("".equals(url)) url = null;
243 appendix = e.getAttrVal("appendix"); if ("".equals(appendix)) appendix = null;
244 section = e.getAttrVal("section"); if ("".equals(section)) section = null;
245 text = e.getAttrVal("text"); if ("".equals(url)) text = null;
246 if (text == null) text = url;
247 if (text == null) text = section;
248 if (text == null) text = appendix;
250 public void dumpLatex(StringBuffer sb) {
251 // FIXME: dotted underline for section/appendix, solid underline for url
252 String text = fixLatex(this.text);
253 if (text == null) text = "\\tt " + (url != null ? url : section != null ? section : appendix);
254 if (url != null) { sb.append("\\href{" + url + "}{\\uline{" + text + "}} ");
255 } else if (section != null) { sb.append("\\hyperlink{" + section + "}{" + text + "} ");
256 } else if (appendix != null) { sb.append("\\hyperlink{" + appendix + "}{" + text + "} ");
261 class PRE extends TextNode {
263 public PRE(int start, int end) {
264 while(Character.isWhitespace(buffer[start])) start++;
265 while(buffer[start] != '\n') start--;
267 end -= 6; // ugly hack since </pre> is 6 chars long...
268 if (Character.isWhitespace(buffer[end])) {
269 while(Character.isWhitespace(buffer[end])) end--;
272 mytext = new String(buffer, start, end - start);
277 while(i<mytext.length() && mytext.charAt(i) == ' ') i++;
278 if (i==mytext.length()) break;
279 gobble = java.lang.Math.min(gobble, i - start2);
280 i = mytext.indexOf('\n', i);
285 public void dumpLatex(StringBuffer sb) {
286 sb.append("\n\n\\begin{Verbatim}[fontfamily=courier,fontsize=\\tiny,frame=single,rulecolor=\\color{CodeBorder},resetmargins=true,gobble="+gobble+"]\n");
288 sb.append("\\end{Verbatim}\n\n");
293 // Paragraph Nodes //////////////////////////////////////////////////////////////////////////////
295 class ParagraphNode extends Node {
296 protected Vec children = new Vec();
297 public void addChild(Node n) { children.addElement(n); n.parent = this; }
298 public void addText(String s) {
299 if (children.size() == 0 || !(children.lastElement() instanceof String))
300 children.addElement(s);
302 children.setElementAt(children.lastElement() + s, children.size() - 1);
304 public void dumpLatex(StringBuffer sb) {
305 for(int i=0; i<children.size(); i++) {
306 if (children.elementAt(i) instanceof String) sb.append(fixLatex(children.elementAt(i).toString()));
307 else ((Node)children.elementAt(i)).dumpLatex(sb);
312 class Property extends ParagraphNode {
315 String default_ = null;
316 public Property(XML.Element e) {
317 name = e.getAttrVal("name");
318 if (name == null || name.equals("")) name = "ERROR";
319 type = e.getAttrVal("type");
320 default_ = e.getAttrVal("default");
321 if (default_ != null && default_.trim().length() == 0) default_ = null;
323 public void dumpLatex(StringBuffer sb) {
324 StringBuffer sb2 = new StringBuffer();
325 super.dumpLatex(sb2);
326 String s = sb2.toString();
327 while(Character.isSpace(s.charAt(0))) s = s.substring(1);
328 String fname = fixLatex(name);
329 type = type == null || type.equals("") ? "" : "({\\it{" + fixLatex(type) + "}})";
330 if (name.trim().length() > 13 && name.trim().indexOf(' ') == -1) {
331 sb.append("\n\n{\\color{CodeBorder}\\hspace{-2cm}\\dotfill\\\\\\color{black}}");
332 sb.append("\\marginpar{\\raggedleft{\\texttt{\\textbf{\\footnotesize{"+fname+"}}}}\\\\"+type+" }");
336 sb.append("\n\n{\\color{CodeBorder}\\hspace{-2cm}\\dotfill\\\\\\color{black}}");
337 sb.append(s.substring(0, s.indexOf(' ')));
338 sb.append("\\marginpar{\\raggedleft{\\texttt{\\textbf{\\footnotesize{"+fname+"}}}}\\\\"+type+" }");
339 sb.append(s.substring(s.indexOf(' ')));
341 if (default_ != null) {
342 String fd = fixLatex(default_);
343 fd = fd.replaceAll(" ``", " \"");
344 fd = fd.replaceAll("''", "\"");
345 sb.append("\\\\{\\it default: }{\\texttt{" + fd + "}}\n\n");
352 class Definition extends ParagraphNode {
354 public Definition(XML.Element e) { name = e.getAttrVal("term"); }
355 public void dumpLatex(StringBuffer sb) {
356 StringBuffer sb2 = new StringBuffer();
357 super.dumpLatex(sb2);
358 String s = sb2.toString();
359 while(Character.isSpace(s.charAt(0))) s = s.substring(1);
360 sb.append(s.substring(0, s.indexOf(' ')));
361 sb.append("\\marginpar{\\raggedleft{\\textbf{"+fixLatex(name)+"}}}");
362 sb.append(s.substring(s.indexOf(' ')));
366 class Math extends ParagraphNode {
368 public Math(XML.Element e) { tex = e.getAttrVal("tex"); if (tex == null) tex = ""; }
369 public void addText(String s) { tex += s; }
370 public void dumpLatex(StringBuffer sb) { sb.append("\n\n$$\n" + tex.replaceAll("\n", " ") + "\n$$\n\n"); }
373 class Section extends ParagraphNode {
375 public Section(XML.Element e) {
376 name = e.getAttrVal("title");
377 if (slides) super.addChild(new List());
379 public void addText(String s) {
380 if (slides) ((List)children.elementAt(0)).addText(s);
381 else super.addText(s);
383 public void addChild(Node n) {
384 /* if (slides) ((List)children.elementAt(0)).addChild(n);
385 else*/ super.addChild(n);
387 public void dumpLatex(StringBuffer sb) {
389 String base = "section";
392 for(Node n = parent; n != null; n = n.parent)
393 if (n instanceof Section || n instanceof Appendix) {
396 for (int i=0; i<count; i++) pile += "\\hspace{1cm}";
397 pile += ((Section)n).name + "\\\\\n";
402 sb.append("\n\n\\begin{slide}\n");
403 sb.append("\\slideheading{"+fixLatex(name)+"}\n");
404 for(int i=0; i<children.size(); i++)
405 if (children.elementAt(i) instanceof String)
406 sb.append(fixLatex(children.elementAt(i).toString()));
407 sb.append("\n\n\\end{slide}\n");
408 for(int i=0; i<children.size(); i++)
409 if (children.elementAt(i) instanceof String)
410 ((Node)children.elementAt(i)).dumpLatex(sb);
412 if (secs.length() == 0)
413 sb.append("\\newpage\n\n");
414 sb.append("\n\n\\hypertarget{" + name + "}{\\" + secs + base + "{" + name + "}}\n\n");
420 static boolean hitAppendix = false;
421 class Appendix extends Section {
422 public Appendix(XML.Element e) { super(e); }
423 public void dumpLatex(StringBuffer sb) {
424 if (!hitAppendix) sb.append("\\appendix\n");
430 class List extends ParagraphNode {
431 TextNode textnode = null;
433 public void addChild(Node n) {
434 if (n != textnode) textnode = null;
437 public void addText(String s) {
438 if (!(children.lastElement() == textnode) || (textnode == null && children.lastElement() == null))
439 addChild(textnode = new TextNode());
440 s = s.replaceAll("\n( +)\\- ", "\n\n$1 ");
443 public int indentof(String s) {
444 for(int i=0; i<s.length(); i++)
445 if (!Character.isWhitespace(s.charAt(i)))
449 public void dumpLatex(StringBuffer sb0) {
450 StringBuffer sb = new StringBuffer();
451 boolean began = false;
452 boolean unusedItem = false;
454 int indentation = -1;
455 for(int i=0; i<children.size(); i++) {
456 Object kid = children.elementAt(i);
457 if (kid instanceof ParagraphBreak) { unusedItem = false; continue; }
458 if (kid instanceof List) unusedItem = true;
460 if (kid instanceof String) {
461 if (kid.toString().trim().length() == 0) continue;
462 txt = (String)children.elementAt(i);
463 } else if (kid instanceof TextNode) {
464 if (((TextNode)kid).mytext.trim().length() == 0) continue;
465 txt = ((TextNode)kid).mytext;
472 ((Node)kid).dumpLatex(sb);
475 if (txt.trim().length() == 0) continue;
476 if (indentation == -1) indentation = indentof(txt);
477 if (indentof(txt) > indentation) {
478 if (spawn == null) spawn = new List();
480 spawn.addChild(new ParagraphBreak());
488 if (!unusedItem) { unusedItem = true; sb.append("\n\n\\item\n"); }
489 sb.append(fixLatex(txt));
495 if (sb.toString().replaceAll("\\[.+\\]", "").trim().length() > 0) {
496 sb0.append("\n\\begin{itemize}\n");
497 sb0.append(sb.toString());
498 sb0.append("\n\\end{itemize}\n");
503 class Root extends ParagraphNode {
504 String title = "You forgot the title, you idiot!";
505 String author = "Your Mom";
507 String subtitle = null;
508 public Root(XML.Element e) {
510 title = e.getAttrVal("title");
511 author = e.getAttrVal("author");
512 email = e.getAttrVal("email");
513 subtitle = e.getAttrVal("subtitle");
515 public void addText(String s) {
516 if (victim != null) ((Node)victim).addText(s);
518 public void addChild(Node n) {
519 if (!(n instanceof Section))
520 ((Section)victim).addChild(n);
524 public void dumpLatex(StringBuffer sb) {
526 sb.append("\\documentclass[letter]{seminar}\n");
527 sb.append("\\usepackage{calc} % Simple computations with LaTeX variables\n");
528 sb.append("\\usepackage[hang]{caption2} % Improved captions\n");
529 sb.append("\\usepackage{fancybox} % To have several backgrounds\n");
530 sb.append(" % (must be loaded before `fancyvrb')\n");
531 sb.append("\\usepackage{fancyhdr} % Headers and footers definitions\n");
532 sb.append("\\usepackage{fancyvrb} % Fancy verbatim environments\n");
533 sb.append("\\usepackage{wrapfig}\n");
534 sb.append("\\usepackage{float}\n");
535 sb.append("\\usepackage{amsmath}\n");
536 sb.append("\\usepackage{amssymb}\n");
537 sb.append("\\usepackage{pdftricks}\n");
538 sb.append("\\begin{psinputs}\n");
539 sb.append(" \\usepackage{pstcol} % PSTricks with the standard color package\n");
540 sb.append(" % (before `graphicx' for the \\scalebox macro)\n");
541 sb.append(" \\usepackage{graphicx} % Standard graphics package\n");
542 sb.append(" \\usepackage{multido} % General loop macro\n");
543 sb.append(" \\usepackage{pifont} % Ding symbols (mainly for lists)\n");
544 sb.append(" \\usepackage{pst-fr3d} % PSTricks 3D framed boxes\n");
545 sb.append(" \\usepackage{pst-grad} % PSTricks gradient mode\n");
546 sb.append(" \\usepackage{pst-node} % PSTricks nodes\n");
547 sb.append(" \\usepackage{pst-slpe} % Improved PSTricks gradients\n");
548 sb.append("\\end{psinputs}\n");
549 sb.append("\\usepackage{color}\n");
550 sb.append("\\definecolor{CodeBorder}{rgb}{0.6,0.6,0.6}\n");
551 sb.append("\\definecolor{CodeBackground}{rgb}{0.93,0.93,0.93}\n");
552 sb.append("\\usepackage{graphicx}\n");
553 sb.append("\\usepackage{courier}\n");
554 sb.append("\\usepackage{fancyvrb}\n");
555 sb.append("\\usepackage{float}\n");
556 sb.append("\\usepackage{fvrb-ex}\n");
557 sb.append("\\usepackage{bold-extra}\n");
558 sb.append("\\usepackage{ulem}\n");
559 sb.append("\\usepackage{amssymb,amsmath,epsfig,alltt}\n");
560 sb.append("\\usepackage{semcolor} % Seminar colored slides\n");
561 sb.append("\\usepackage{semhelv} % Seminar helvetica fonts\n");
562 sb.append("\\usepackage{semlayer} % Seminar overlays\n");
563 sb.append("\\usepackage{slidesec} % Seminar sections and list of slides\n");
564 sb.append("\\usepackage{url} % Convenient URL typesetting\n");
565 sb.append("\\usepackage[pdftex,letterpaper,pdffitwindow=true,colorlinks=true,pdfpagemode=UseNone,\n");
566 sb.append(" bookmarks=true]{hyperref} % Hyperlinks for PDF versions\n");
567 sb.append("\\usepackage{hcolor}\n");
568 sb.append("\\slidepagestyle{fancy}\n");
570 sb.append("\\slidesmag{4} % Set magnification of slide\n");
571 sb.append("\\def\\SeminarPaperWidth{\\paperwidth / 2}\n");
572 sb.append("\\def\\SeminarPaperHeight{\\paperheight / 2}\n");
573 sb.append("\\slideframe{none} % No default frame\n");
577 sb.append(" % General size parameters\n");
578 sb.append("\\renewcommand{\\slideparindent}{5mm}\n");
579 sb.append("\\raggedslides[0mm]\n");
580 sb.append("% \\renewcommand{\\slidetopmargin}{15.5mm}\n");
581 sb.append("% \\renewcommand{\\slidebottommargin}{13mm}\n");
582 sb.append("% \\renewcommand{\\slideleftmargin}{4mm}\n");
583 sb.append("% \\renewcommand{\\sliderightmargin}{4mm}\n");
584 sb.append(" % To adjust the frame length to the header and footer ones\n");
585 sb.append("% \\autoslidemarginstrue\n");
586 sb.append(" % We suppress the header and footer `fancyhdr' rules\n");
587 sb.append("\\fancyhf{} % Clear all fields\n");
588 sb.append("\\renewcommand{\\headrule}{}\n");
589 sb.append("\\renewcommand{\\footrule}{}\n");
591 sb.append("% \\usepackage{nohyperref} % To deactivate the `hyperref' features\n");
592 sb.append("% \\overlaysfalse % To suppress overlays\n");
593 sb.append("% \\def\\special@paper{}% Needed to avoid `hyperref' to collapse with ``dvips''\n");
594 sb.append("\\newslideframe{IMAGE}{%\n");
595 sb.append(" \\boxput{\\rput(0,0){%\n");
596 sb.append(" \\includegraphics[width=\\SeminarPaperHeight,height=\\SeminarPaperWidth]{background.pdf}}}{#1}}\n");
597 sb.append("\\slideframe*{IMAGE}\n");
598 sb.append("%\\renewcommand{\\slideleftmargin}{3cm}\n");
599 sb.append("%\\addtolength{\\slidewidth}{-\\slideleftmargin}\n");
600 sb.append("\\RequirePackage[T1]{fontenc}\n");
601 sb.append("\\RequirePackage{textcomp}\n");
602 sb.append("\\renewcommand{\\rmdefault}{trebuchet}\n");
603 sb.append("\\renewcommand{\\slidefonts}{%\n");
604 sb.append(" \\renewcommand{\\rmdefault}{trebuchet}%\n");
605 sb.append(" \\renewcommand{\\ttdefault}{courier}}%\n");
606 sb.append(" \\newcommand{\\ParagraphTitle}[2][black]{%\n");
607 sb.append(" \\noindent\\psshadowbox[fillstyle=solid,fillcolor=#1]{\\large{#2}}}\n");
608 sb.append(" \\newcommand{\\CenteredParagraphTitle}[2][black]{%\n");
609 sb.append(" \\centerline{\\psshadowbox[fillstyle=solid,fillcolor=#1]{\\large{#2}}}}\n");
610 sb.append(" \\renewcommand{\\makeslideheading}[1]{%\n");
611 sb.append(" \\CenteredParagraphTitle[black]{%\n");
612 sb.append(" \\textcolor{black}{\\huge\\textbf{#1}}}}\n");
613 sb.append(" \\renewcommand{\\makeslidesubheading}[1]{%\n");
614 sb.append(" \\CenteredParagraphTitle{\\Large\\theslidesubsection{} -- #1}}\n");
615 sb.append(" \\renewenvironment{dinglist}[2][black]\n");
616 sb.append(" {\\begin{list}{\\ding{#2}}{}}{\\end{list}}\n");
617 sb.append(" \\newcommand{\\DingListSymbolA}{43}\n");
618 sb.append(" \\newcommand{\\DingListSymbolB}{243}\n");
619 sb.append(" \\newcommand{\\DingListSymbolC}{224}\n");
620 sb.append(" \\newcommand{\\DingListSymbolD}{219}\n");
621 sb.append(" \\newcommand{\\eqbox}[2][0.6]{%\n");
622 sb.append(" \\centerline{\\psshadowbox[fillstyle=solid,fillcolor=gray]{%\n");
623 sb.append(" \\parbox{#1\\hsize}{%\n");
625 sb.append(" \\textcolor{black} {#2}\n");
626 sb.append(" \\]}}}}\n");
627 sb.append("\\begin{document}\n");
628 sb.append("\\begin{slide}\n");
629 sb.append("\\begin{center}\n");
630 sb.append("\\ParagraphTitle{\\bf \\Large "+title+"}\n");
631 sb.append("\\vspace{5mm} \\\n");
632 sb.append("\\textit{\\large "+subtitle+"} \\\\\n");
633 sb.append("\\vspace{5mm} \\\n");
634 sb.append("\\textit{"+author+"} \\\n");
635 sb.append("\\end{center}\n");
636 sb.append("\\end{slide}\n\n");
638 sb.append("\\end{document}");
640 sb.append("\\documentclass{article}\n");
641 sb.append("\\def\\ninept{\\def\\baselinestretch{.95}\\let\\normalsize\\small\\normalsize}\n");
642 sb.append("\\ninept\n");
643 sb.append("\\usepackage{color}\n");
644 sb.append("\\definecolor{CodeBorder}{rgb}{0.6,0.6,0.6}\n");
645 sb.append("\\definecolor{CodeBackground}{rgb}{0.93,0.93,0.93}\n");
646 sb.append("\\usepackage{graphicx}\n");
647 sb.append("\\usepackage{courier}\n");
648 sb.append("\\usepackage{fancyvrb}\n");
649 sb.append("\\usepackage{float}\n");
650 sb.append("\\usepackage{wrapfig}\n");
651 sb.append("\\usepackage{fvrb-ex}\n");
652 sb.append("\\usepackage{bold-extra}\n");
653 sb.append("\\usepackage{ulem}\n");
654 sb.append("\\usepackage{amssymb,amsmath,epsfig,alltt}\n");
655 sb.append("\\sloppy\n");
656 sb.append("\\usepackage{palatino}\n");
657 sb.append("\\usepackage{sectsty}\n");
658 sb.append("\\allsectionsfont{\\sffamily}\n");
659 sb.append("\\sectionfont{\\color{black}\\leftskip=-2cm");
660 sb.append("\\hrulefill\\\\\\sffamily\\bfseries\\raggedleft\\vspace{1cm}}\n");
661 sb.append("\\subsectionfont{\\color{black}\\dotfill\\\\\\sffamily\\raggedright\\hspace{-4cm}}\n");
662 sb.append("\\newdimen\\sectskip\n");
663 sb.append("\\newdimen\\subsectskip\n");
664 sb.append("\\newdimen\\saveskip\n");
665 sb.append("\\saveskip=\\leftskip\n");
666 sb.append("\\sectskip=-2cm\n");
667 sb.append("\\subsectskip=0cm\n");
668 sb.append("\\let\\oldsection\\section\n");
669 sb.append("\\let\\oldsubsection\\subsection\n");
670 sb.append("\\def\\subsection#1{\\leftskip=\\sectskip\\oldsubsection{#1}\\leftskip=0cm}\n");
671 sb.append("\\usepackage{parskip}\n");
672 sb.append("\\usepackage{tabularx}\n");
673 sb.append("\\usepackage{alltt}\n");
674 sb.append("\\usepackage[pdftex,colorlinks=true,urlcolor=blue,linkcolor=blue,bookmarks=true]{hyperref}\n");
675 // FIXME: pdfauthor, pdftitle, pdfsubject, pdfkeywords?
677 sb.append("\\begin{document}\n");
678 sb.append("\\reversemarginpar\n");
680 sb.append("\\title{\\textbf{\\textsf{\n");
682 if (subtitle != null) sb.append("\\\\{\\large " + subtitle + "}\n");
684 if (author != null) {
685 sb.append("\\author{\n");
687 if (email != null) sb.append("\\\\{\\tt " + email + "}\n");
691 sb.append("\\maketitle\n");
692 sb.append("\\clearpage\n");
693 sb.append("\\tableofcontents\n");
694 sb.append("\\clearpage\n");
695 sb.append("\\onecolumn\n");
697 sb.append("\\end{document}");