<!DOCTYPE book  PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
 [ <!entity index SYSTEM "index.sgml">
<!entity bibliography SYSTEM "mySGML.bib.sgml">
<!entity appendix SYSTEM "appendix.sgml">
<!ENTITY % output.print.png "IGNORE">
<!ENTITY % output.print.pdf "IGNORE">
<!ENTITY % output.print.eps "IGNORE">
<!ENTITY % output.print.bmp "IGNORE">
<!ENTITY file2000 "inlinegraphic-example">
<!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN">
<!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN">
%ISOnum;
%ISOamso;
<!ENTITY file1001 "inlinemediaobject">
<!ENTITY file1002 "citation-short">
<!ENTITY file1003 "citation-full">
<!ENTITY file1004 "informaltable-wrong">
<!ENTITY file1005 "entry-right">
<!ENTITY file1006 "entry-wrong">
<!ENTITY file1007 "informaltable-right">
<!ENTITY file1008 "figure">
<!ENTITY file1009 "mediaobject">
<!ENTITY file1010 "programlisting">
<!ENTITY file1011 "sedscr_tidy">
<!ENTITY file1012 "sedscr_tidy2">
<!ENTITY file1013 "keycombos">
<!ENTITY file1014 "keycombos2">
<!ENTITY file1015 "acronyms">
<!ENTITY file1016 "productnames">
<!ENTITY file1017 "applications">
<!ENTITY file1018 "acronyms2">
<!ENTITY file1019 "productnames2">
<!ENTITY file1020 "applications2">
<!ENTITY file1021 "citation">
<!ENTITY file1022 "citation-short">
<!ENTITY file1023 "citation-full">
<!ENTITY file1024 "mediaobject">
<!ENTITY file1025 "equation">
<!ENTITY file1026 "parapara">
<!ENTITY file1027 "equationequation">
<!ENTITY file1028 "informalequationequation">
<!ENTITY file1029 "altalt">
<!ENTITY file1030 "graphic">
<!ENTITY file1031 "alt-inequalities">
<!ENTITY file1032 "unescape-tex">
<!ENTITY file1033 "mathmath">
<!ENTITY file1034 "print-math">
<!ENTITY file1035 "print-tex">
<!ENTITY file1036 "unescape">
<!ENTITY file1037 "unescape-algo">
<!ENTITY file1038 "print-tex-literal">
<!ENTITY graph1001 "general-info">
<!ENTITY graph1002 "paper-sizes">
<!ENTITY graph1003 "insert-url">
<!ENTITY graph1004 "page-area-model">
<!ENTITY graph1005 "fonts"><!ENTITY lyxarrow "-&gt;">
 ]>
<book lang="en"><!-- DocBook file was created by LyX 1.2
  See http://www.lyx.org/ for more information -->
<bookinfo><title>Document processing with LyX and SGML</title><subtitle>
A quest for the Holy Grail of technical documentation
</subtitle>
<authorgroup>
<author>   
<firstname>Chris</firstname>     <surname>Karakas</surname> 
<affiliation> 
  <orgname>www.karakas&mdash;online.de</orgname>   
 </affiliation>  
</author>
</authorgroup>
<keywordset>
<keyword>LyX</keyword>
<keyword>SGML</keyword>
<keyword>sgmltools</keyword>
<keyword>docbook</keyword>
<keyword>dsssl</keyword>
<keyword>stylesheet</keyword>
<keyword>formatting</keyword>
<keyword>linux</keyword>
<keyword>jade</keyword>
<keyword>openjade</keyword>
<keyword>latex</keyword>
<keyword>unix</keyword>
<keyword>pdfjadetex</keyword>
<keyword>jadetex</keyword>
<keyword>jadetex.cfg</keyword>
<keyword>sed</keyword>
<keyword>runsed</keyword>
<keyword>sedscr</keyword>
<keyword>density</keyword>
<keyword>pdf</keyword>
<keyword>ps</keyword>
<keyword>rtf</keyword>
<keyword>txt</keyword>
<keyword>html</keyword>
<keyword>dvitops</keyword>
<keyword>Computer Modern</keyword>
<keyword>sgml</keyword>
<keyword>pdfjadetex</keyword>
<keyword>accessibility</keyword>
<keyword>bibliography</keyword>
<keyword>validation</keyword>
<keyword>dbtextmath</keyword>
<keyword>refdb</keyword>
<keyword>index generation</keyword>
<keyword>htmltidy</keyword>
<keyword>coolthumbs</keyword>
<keyword>document processing</keyword>
<keyword>localization</keyword>
<keyword>internationalization</keyword>
</keywordset>
<abstract><para>A method for single-source publishing using LyX and SGML is presented: LyX is used as a comfortable graphical SGML editor. Once the document is exported to SGML from LyX, it undergoes a series of transformations through sed and awk scripts that correct and enhance the SGML markup, compute the Index, insert the Bibliography and the Appendix and take care of the correct invocation of openjade, pdftex, pdfjadetex and all the other necessary programs for the generation of HTML (chunked or not), PDF (with images, bookmarks, thumbnails and hyperlinks), PS, RTF and TXT versions. All aspects of document processing are handled, including automatic Index generation, display of Mathematics in <application>TeX</application> quality both online and in print formats, as well as the use of bibliographic databases with RefDB. Special care is taken so that the document processing is as transparent to the user as possible - the aim being that the user writes in LyX, then presses a button, and the <ulink url="lyxtox">lyxtox</ulink> script does the rest.</para></abstract><REVHISTORY>
<REVISION>
<REVNUMBER>1.4
</REVNUMBER>
<DATE>20.09.2007
</DATE>
<AUTHORINITIALS>
CK
</AUTHORINITIALS>
<REVREMARK>
Added sections on start and end files, HTML headers and footers. Changed chapters resp. sections: Shortcomings and bugs, Main part, <application>LaTeX</application> errors. New files: example.start, example.end, part1, part2, part3, keycombos, keycombos2, acronyms, acronyms2, productnames, productnames2, applications, applications2. Changed files: lyxtox.
</REVREMARK>
</REVISION>
<REVISION>
<REVNUMBER>1.3
</REVNUMBER>
<DATE>12.03.2006
</DATE>
<AUTHORINITIALS>
CK
</AUTHORINITIALS>
<REVREMARK>
Files changed: sedscr, lyxtox, lyxtox-print-pdf.dsl, lyxtox-print.dsl, awkscr_insert_index_items, ck-style.css, jadetex.cfg, addd. New sed scripts, sedscr_apa and sedscr_ima, take care of alt and title attributes in the HTML format, so that the resulting files remain W3C compliant. Previous versions might not be, because a phrase element inside a textobject was not used for the alt attribute, due probably to a bug in the DSSSL stylesheets. sgmltools is not needed anymore. Corrected a bug in awkscr_insert_index_items that would break index entry insertion after the first entry. Added code in sedscr that will take care of keycombos, acronyms, productnames and index entries of key combinations. Use of a new script, coolthumbs, for the creation of antialiased thumbnails in PDF. Further changes in: The final step, Unprintable characters, SP_ENCODING in "Set environment vars", Using Type 1 fonts, Choosing the right font encoding, Using True Type fonts, Optimal PDF&mdash;Figures, <productname>Acrobat</productname> <application>Reader</application> 5 does not display thumbnails. Added a whole chapter on Localization (work in progress). Simplified addd script. Generated new Index (almost 2000 entries!).
</REVREMARK>
</REVISION>
<REVISION>
<REVNUMBER>1.2
</REVNUMBER>
<DATE>25.06.2004
</DATE>
<AUTHORINITIALS>
CK
</AUTHORINITIALS>
<REVREMARK>
The tidy scripts have been deactivated in lyxtox. They mess up other areas like callouts or displayed code &mdash; but they are still in the package. Corrections to sedscr and awkscr_math scripts to handle inequalities correctly: now writing a &lt; b &gt; c in Math Mode will not result in an Openjade  parser error about an &quot;undefined element b&quot;. The jadetex.cfg file now contains examples of how to get customized headers and footers in PDF  through the fancyhdr package (works only partly &mdash; ideas welcome) and also an example of using the underscore package to get underscores correctly in links &mdash; but this messes up the smiley names which also contain underscores.
</REVREMARK>
</REVISION>
<REVISION>
<REVNUMBER>1.1
</REVNUMBER>
<DATE>13.06.2004
</DATE>
<AUTHORINITIALS>
CK
</AUTHORINITIALS>
<REVREMARK>
Discussion of newer LyX versions (newer than 1.2.0), as well as new errors and warnings. 
Inclusion of sedscr_tidy and sedscr_tidy2 sed scripts that tidy up the SGML code. 
The lyxtox script contains calls to those two scripts, otherwise no changes have been made to the scripts.
</REVREMARK>
</REVISION>
<REVISION>
<REVNUMBER>1.0
</REVNUMBER>
<DATE>19.02.2004
</DATE>
<AUTHORINITIALS>
CK
</AUTHORINITIALS>
<REVREMARK>
Initial public release.
</REVREMARK>
</REVISION>
</REVHISTORY>
</bookinfo>
<chapter id="terms-of-distribution"><title>Terms of distribution</title><sect1 id="disclaimer"><title>Disclaimer</title><para>No liability <indexterm><primary>liability</primary></indexterm>for the contents of this documents can be accepted. Use the concepts, examples and other content at your own risk. As this is a new edition of this document,<indexterm><primary>document</primary></indexterm> there may be errors and inaccuracies, that may of course be damaging to your system. Proceed with caution, and although this is highly unlikely, the author does not take any responsibility for that.</para><para>All copyrights are held by their respective owners, unless specifically noted otherwise. Use of a term in this document <indexterm><primary>document</primary></indexterm>should not be regarded as affecting the validity <indexterm><primary>validity</primary></indexterm>of any trademark <indexterm><primary>trademark</primary></indexterm>or service mark.<indexterm><primary>mark</primary></indexterm></para><para>Naming of particular products or brands should not be seen as endorsements.<indexterm><primary>endorsements</primary></indexterm></para></sect1>
<sect1 id="formats"><title>Formats</title><important>
<title>IMPORTANT: Script and Stylesheet Downloads!</title>
<para>
If you want to download only the scripts and stylesheets of this project, without any documentation, get the following archive:
</para>
<itemizedlist><listitem><para><ulink url="./mySGML-scripts.tar.gz"> TAR.GZ (Compressed TAR Archive), scripts and stylesheets only (no documentation)</ulink></para></listitem></itemizedlist>
</important>
<para>This document <indexterm><primary>document</primary></indexterm>is available in the following formats:</para><itemizedlist><listitem><para><ulink url="./book1.html">HTML (HyperText Markup Language)</ulink>, many HTML <indexterm><primary>HTML</primary></indexterm>files (one for every section), for viewing with <ulink url="http://www.anybrowser.org/campaign/">any browser</ulink>
<citation role="REFDB"><xref linkend="IDAnyBrowser0X"></citation>
</para></listitem><listitem><para><ulink url="./mySGML.html">HTML (HyperText Markup Language)</ulink>, one big HTML <indexterm><primary>HTML</primary></indexterm>file</para></listitem><listitem><para><ulink url="./mySGML.txt">TXT (ASCII Text)</ulink></para></listitem><listitem><para><ulink url="./mySGML.rtf">RTF (Rich Text Format)</ulink></para></listitem><listitem><para><ulink url="./mySGML.pdf">PDF (Portable Document Format)</ulink></para></listitem><listitem><para><ulink url="./mySGML.ps.gz">PS.GZ (Compressed Postscript)</ulink></para></listitem><listitem><para><ulink url="./mySGML.sgml">SGML (Standard Generalized Markup Language)</ulink> (with the <ulink url="appendix.sgml">Appendix</ulink> and the <ulink url="mySGML.bib.sgml">Bibliography</ulink>)</para></listitem><listitem><para><ulink url="./mySGML.lyx">LYX (LaTeX frontend LyX)</ulink> (with the <ulink url="appendix.lyx">Appendix</ulink><footnote><para>The bibliography of this document is generated through <ulink url="http://refdb.sourceforge.net">RefDB</ulink> directly in SGML, so that there is no LyX file for it available.</para></footnote>)</para></listitem></itemizedlist><note>
<title>RTF: Page numbers</title>
<para>In order to get correct page numbers in Microsoft Word, type the following after opening the document:</para>
<procedure>
<step>
<para>
<keycombo>
<keycap>CTRL</keycap>
<keycap>END</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>CTRL</keycap>
<keycap>A</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>F9</keycap>
</keycombo>
</para>
</step>
</procedure>
<para>In Word Viewer 97, you must instead do:</para>
<procedure>
<step>
<para>
<keycombo>
<keycap>CTRL</keycap>
<keycap>END</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>ALT</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>V</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>N</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>ALT</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>V</keycap>
</keycombo>
</para>
</step>
<step>
<para>
<keycombo>
<keycap>P</keycap>
</keycombo>
</para>
</step>
</procedure>
<para>See <ulink url="http://openjade.sourceforge.net/jadedoc-1.3/rtf.htm">The OpenJade RTF backend</ulink> for more details.</para>
</note>
<important>
<title>IMPORTANT: Downloads for offline reading!</title>
<para>
If you want to download the HTML or RTF formats for offline reading, you will need to download the images as well - PNG for HTML and BMP for RTF, including the callouts! To save you the hassle, I have compiled the following zipped tar archives for offline reading (these contain the scripts and stylesheets too):
</para>
</important>
<itemizedlist><listitem><para><ulink url="./mySGML-html.tar.gz"> TAR.GZ (Compressed TAR Archive), many HTML files with images and scripts</ulink></para></listitem><listitem><para><ulink url="./mySGML-onehtml.tar.gz"> TAR.GZ (Compressed TAR Archive), one big  HTML file with images and scripts</ulink></para></listitem><listitem><para><ulink url="./mySGML-sgml.tar.gz"> TAR.GZ (Compressed TAR Archive), SGML file with images and scripts</ulink></para></listitem><listitem><para><ulink url="./mySGML-rtf.tar.gz"> TAR.GZ (Compressed TAR Archive), RTF file with images and scripts</ulink></para></listitem></itemizedlist><para>A tarball <indexterm><primary>tarball</primary></indexterm>containing all the above formats, including images and scripts, is also available:</para><itemizedlist><listitem><para><ulink url="./mySGML.tar.gz"> TAR.GZ (Compressed TAR Archive), All files</ulink></para></listitem></itemizedlist></sect1>
<sect1 id="license"><title>License</title><para>Copyright <indexterm><primary>Copyright</primary></indexterm>&copy; 2004-2006 <ulink url="http://www.karakas-online.de">Chris Karakas</ulink>. Permission is granted to copy, distribute and/or modify this document <indexterm><primary>document</primary></indexterm>under the terms <indexterm><primary>terms</primary></indexterm>of the <acronym>GNU</acronym> <indexterm><primary>GNU</primary></indexterm>Free Documentation License<indexterm><primary>License</primary></indexterm><indexterm><primary>GNU Free Documentation License</primary></indexterm>, Version 1.2 or any later version published by the Free Software Foundation<indexterm><primary>Foundation</primary></indexterm><indexterm><primary>Free Software Foundation</primary></indexterm>; with no Invariant <indexterm><primary>Invariant</primary></indexterm>Sections, with no Front-Cover <indexterm><primary>Front-Cover</primary></indexterm>Texts, and with no Back-Cover Texts. A copy of the license can be found in <xref linkend="GNU-Free-Documenation-Licence">, as well as at the <ulink url="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</ulink>
<citation role="REFDB"><xref linkend="IDGNU0X"></citation>
 .</para></sect1>
<sect1 id="availability-of-sources"><title>Availability of sources and support</title><para>See <xref linkend="formats"> for the modifiable <indexterm><primary>modifiable</primary></indexterm>sources <indexterm><primary>sources</primary></indexterm>of this document.<indexterm><primary>document</primary></indexterm></para><important>
<title>Pose your questions in my <productname>Linux</productname> Forum!</title>
<para>
I've been working on this project since 2000. It is still work in progress. I don't have an "installation script" or similar - you will have to read this document carefully and try the solutions offered. If you have questions, patches, suggestions,  problems or (better) solutions, come to <ulink url="http://www.karakas-online.de/forum/linux.html">my <productname>Linux</productname> Forum</ulink> and post them there. I look forward to your feedback!
</para>
</important>
</sect1>
<sect1 id="credits"><title>Credits</title><para>The DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets (<xref linkend="DSSSL-stylesheets">, <xref linkend="explain-DSSSL-stylesheets">) owe a lot to the <ulink url="http://newbiedoc.sourceforge.net/tutorials/docbook-guide/index-docbook-guide.html">DocBook Guide</ulink> of the <ulink url="http://newbiedoc.sourceforge.net">Debian Newbiedoc Project</ulink>, Mandrake's manual-print.dsl <indexterm><primary>manual-print.dsl</primary></indexterm>file (see <ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/fixingproblems.html">Customizing Document Production</ulink> for a detailed description) and the <ulink url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath">DBTeXMath</ulink> method. Also, the <ulink url="http://www.karakas-online.de/myLinuxTips/css-for-docbook.html">CSS file for DocBook</ulink>, <ulink url="ck-style.css">ck-style.css</ulink>, got important elements from the <ulink url="http://newbiedoc.sourceforge.net/nd-style.css">Newbiedoc CSS file for DocBook</ulink> and Mark Pilgrim's influential <ulink url="http://diveintoaccessibility.org">dive into Accessibility</ulink>.</para><para><ulink url="http://refdb.sourceforge.net">RefDB</ulink> gave me a real solution to my bibliography <indexterm><primary>bibliography</primary></indexterm>problem (see <xref linkend="LyX-Bibliography">, <xref linkend="explain-bibliography">).</para><para>Part of <xref linkend="LyX-environments"> is taken from the LyX <indexterm><primary>LyX</primary></indexterm>Tutorial, section 2.2 (&ldquo;Environments&rdquo;).</para><para>Part of <xref linkend="lynx"> is taken from the lynx <indexterm><primary>lynx</primary></indexterm>manpage.</para><para>The introduction text to <xref linkend="tex-errors"> is taken from the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>FAQ <indexterm><primary>FAQ</primary></indexterm>item on <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=erroradvice">How to approach errors</ulink>. The material in <xref linkend="structure-of-TeX-errors"> is taken from the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>FAQ <indexterm><primary>FAQ</primary></indexterm>item on <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=errstruct">the structure of <application>TeX</application> errors</ulink>. <xref linkend="fatal-format-file-error"> contains material from the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>FAQ <indexterm><primary>FAQ</primary></indexterm>item on the <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=formatstymy">fatal format file error</ulink>. </para><para>The description of the common <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>error messages and warnings in <xref linkend="LaTeX-errors"> uses material from the chapter on &ldquo; LyX <indexterm><primary>LyX</primary></indexterm>and <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>errors&rdquo; of the Extended Features manual <indexterm><primary>manual</primary></indexterm>for LyX,<indexterm><primary>LyX</primary></indexterm> available from LyX' Help menu.</para><para>Many other sources <indexterm><primary>sources</primary></indexterm>have been used for this work. See <xref linkend="bibliography"> for some of them. Although not all of them are present in <xref linkend="bibliography">, they are all quoted at the aproppriate place inside the document.<indexterm><primary>document</primary></indexterm> Please follow the links given there.</para><para><xref linkend="fig-page-area-model"> is taken from W3C's working draft <ulink url="http://www.w3.org/TR/2003/WD-css3-page-20031218/">CSS3 Paged Media Module</ulink>, version of Dec. 18th 2003 and is Copyright <indexterm><primary>Copyright</primary></indexterm>&copy; 2003 <ulink url="http://www.w3.org">W3C</ulink> (<ulink url="http://www.lcs.mit.edu">MIT</ulink>, <ulink url="http://www.ercim.org">ERCIM</ulink>, <ulink url="http://www.keio.ac.jp">Keio</ulink>), All Rights Reserved. Used with permission according to <ulink url="http://www.w3.org/Consortium/Legal/copyright-documents">W3C document licence</ulink>.</para><para>The <ulink url="http://www.karakas-online.de/myLinuxTips/css-for-docbook.html">CSS file for DocBook</ulink> that is used in this document <indexterm><primary>document</primary></indexterm>, <ulink url="ck-style.css">ck-style.css</ulink>, uses <ulink url="http://www.matterform.com/qbullets/index.php">QBullets</ulink> in links. See <xref linkend="explain-CSS"> on how to do this. Thanks to Matterform <indexterm><primary>Matterform</primary></indexterm>Media for providing QBullets <indexterm><primary>QBullets</primary></indexterm>for free. If you plan to use them on your website, please observe the <ulink url="http://www.matterform.com/qbullets/usage.html">QBullets usage terms</ulink>.</para><para>The examples for admonition <indexterm><primary>admonition</primary></indexterm>in the Conventions Section (<xref linkend="conventions">) were taken from the <ulink url="http://newbiedoc.sourceforge.net/tutorials/docbook-guide/admon-docbook-guide.html.en">Section on admonitions of the DocBook Guide</ulink> of the <ulink url="http://newbiedoc.sourceforge.net">Debian Newbiedoc Project</ulink>.</para><para>The method I present is an original work of mine, that arouse out of the desire to &ldquo;write once, create many&rdquo; (see how it all started in my <ulink url="http://www.karakas-online.de/myJade/">Jade installation notes</ulink> and how it ended in <xref linkend="lyxtox">). I wanted to have a document <indexterm><primary>document</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>chain with all the bells <indexterm><primary>bells</primary></indexterm>and whistles, including the ability to process Mathematics <indexterm><primary>Mathematics</primary></indexterm>(<xref linkend="mathematics">), bibliography <indexterm><primary>bibliography</primary></indexterm>(see <xref linkend="LyX-Bibliography">) and Index (see <xref linkend="LyX-Index">), controlled from <emphasis>one</emphasis> source and <emphasis>one</emphasis> click of a button. My solution uses many well-known methods and packages,<indexterm><primary>packages</primary></indexterm> but the &ldquo;glue&rdquo; is original.</para></sect1>
<sect1 id="aknowledgements"><title>Aknowledgements</title><para>Thanks to all authors, whose software is used in this work. Their example is a continuous source of inspiration <indexterm><primary>inspiration</primary></indexterm>to me:</para><itemizedlist><listitem><para>All software developers, whose software is used in the preparation of this document:<indexterm><primary>document</primary></indexterm> </para><itemizedlist><listitem><para><ulink url="http://www.lyx.org">LyX</ulink>,</para></listitem><listitem><para><ulink url="http://www.ctan.org">TeX</ulink>,</para></listitem><listitem><para><ulink url="http://www.latex-project.org">LaTeX</ulink>,</para></listitem><listitem><para><ulink url="http://www.tug.org/applications/pdftex/">pdfTeX</ulink>,</para></listitem><listitem><para><ulink url="http://www.tug.org/applications/hyperref/">hyperref</ulink>,</para></listitem><listitem><para><ulink url="http://openjade.sourceforge.net">openjade</ulink>,</para></listitem><listitem><para><ulink url="http://www.fifi.org/cgi-bin/man2html/usr/share/man/man1/pdfjadetex.1.gz">pdfjadetex</ulink>,</para></listitem><listitem><para><ulink url="http://www.ctan.org/tex-archive/help/Catalogue/entries/thumbpdf.html">thumbpdf</ulink>,</para></listitem><listitem><para><ulink url="http://docbook.sourceforge.net/projects/dsssl/">DocBook DSSSL stylesheets</ulink>,</para></listitem><listitem><para><ulink url="http://refdb.sourceforge.net">RefDB</ulink>,</para></listitem><listitem><para><ulink url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath/">DBTeXMath</ulink>,</para></listitem><listitem><para><ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/indexing.html">collateindex</ulink>,</para></listitem><listitem><para><ulink url="http://www.sgmltools.org">sgmltools</ulink>,</para></listitem><listitem><para><ulink url="http://tidy.sourceforge.net">HTML tidy</ulink>,</para></listitem><listitem><para><ulink url="http://hvdkooij.xs4all.nl/docs-docbook.en.cms">HTML split</ulink>,</para></listitem><listitem><para><ulink url="http://www.gnu.org/software/sed/manual/sed.html">sed</ulink>,</para></listitem><listitem><para><ulink url="runsed">runsed</ulink>,</para></listitem><listitem><para><ulink url="http://www.gnu.org/software/gawk/manual/gawk.html">awk</ulink>,</para></listitem><listitem><para><ulink url="http://www.radicaleye.com/dvips.html">dvips</ulink>,</para></listitem><listitem><para><ulink url="http://www.ringlord.com/publications/latex-pdf-howto">coolthumbs</ulink></para></listitem><listitem><para>and all the standard software used in a <ulink url="http://www.gnu.org">GNU/Linux</ulink> system.</para></listitem></itemizedlist></listitem></itemizedlist><para>Many thanks to Gareth Anderson and Jeremy Malcolm for their comments, suggestions and bug reports. Jeremy Malcolm pointed to missing .start and .end files in the online 1.3 version - many thanks! Thanks also to Gloomy,<indexterm><primary>Gloomy</primary></indexterm> for the moral support during the hard times.</para></sect1>
<sect1 id="conventions"><title>Conventions</title><variablelist><varlistentry><term>admonitions
</term><listitem><para>Admonitions <indexterm><primary>Admonitions</primary></indexterm>are little pictures used to emphasize <indexterm><primary>emphasize</primary></indexterm>something of importance to the reader. The four types used are:</para><note> 
<title>Note</title> 
<para> 
Using a hammer to put together your computer is bad.
</para> 
</note>
<tip> 
<title>Tip</title> 
<para> 
Do not hit your thumb with the hammer, it hurts!
</para> 
</tip> 
<important>
<title>Important</title> 
<para>
Watch where you're swinging that hammer!
</para>
</important>
<caution> 
<title>Caution</title> 
<para> 
Hitting your thumb with a hammer may lead to an unwanted trip to the hospital!
</para> 
</caution>
<warning> 
<title>Warning</title> 
<para> 
Do not, under any circumstances, admit that you hit your own thumb with a hammer. The ridicule you will face is astounding!
</para> 
</warning>
</listitem></varlistentry><varlistentry><term>access&nbsp;
</term><listitem><para>keys Access keys enable navigation through the document,<indexterm><primary>document</primary></indexterm> without relying on a mouse. The following keys have been given special meaning in this document:<indexterm><primary>document</primary></indexterm></para><variablelist><varlistentry><term>P
</term><listitem><para>Previous page.</para></listitem></varlistentry><varlistentry><term>N
</term><listitem><para>Next page.</para></listitem></varlistentry><varlistentry><term>H
</term><listitem><para>Home of the document <indexterm><primary>document</primary></indexterm>(Table of Contents).</para></listitem></varlistentry><varlistentry><term>U
</term><listitem><para>Up (takes you one level up the section hierarchy).</para></listitem></varlistentry></variablelist><para>If you also happen to be reading the document <indexterm><primary>document</primary></indexterm>from its original location, then the following access keys can also be used:</para><variablelist><varlistentry><term>S
</term><listitem><para>Start (takes you to the author's start page).</para></listitem></varlistentry><varlistentry><term>T
</term><listitem><para>The current (&ldquo;This&rdquo;) page, without the Sitemenu on the left.</para></listitem></varlistentry><varlistentry><term>M
</term><listitem><para>The current page in a frameset, where the left frame contains a Menu.</para></listitem></varlistentry></variablelist></listitem></varlistentry></variablelist><para>
To use the access keys, you have to simultaneously press a modifier key, which may vary from browser to browser. For example in NN6+/Mozilla, the modifier key is <keycap>ALT</keycap>, so you have to use 
<keycombo>
<keycap>ALT</keycap>
<keycap>N</keycap>
</keycombo>
to go to the next page, and 
<keycombo>
<keycap>ALT</keycap>
<keycap>P</keycap>
</keycombo>
to come back. In other browsers such as IE6, the access keys just give focus to the associated link, so the sequence becomes 
<keycombo action='seq'>
<keycombo>
<keycap>ALT</keycap>
<keycap>N</keycap>
</keycombo>
<keycap>Enter</keycap>
</keycombo>
. Try it, you'll like it! <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
</sect1>
<sect1 id="abbreviations"><title>Abbreviations</title><variablelist><varlistentry><term>SGML
</term><listitem><para><indexterm><primary>SGML</primary></indexterm>(Standard Generalized Markup <indexterm><primary>Markup</primary></indexterm>Language) The superset <indexterm><primary>superset</primary></indexterm>of all the markup<indexterm><primary>markup</primary></indexterm> languages, SGML <indexterm><primary>SGML</primary></indexterm>is a generalized schema for tagging structure data in an application-independent <indexterm><primary>application-independent</primary></indexterm>way.</para></listitem></varlistentry><varlistentry><term>XML
</term><listitem><para><indexterm><primary>XML</primary></indexterm>(eXtensible Markup <indexterm><primary>Markup</primary></indexterm>Language) XML is an SGML <indexterm><primary>SGML</primary></indexterm>for tagging structured data according to an accompanying DTD <indexterm><primary>DTD</primary></indexterm>which defines the collection of tags and the rules <indexterm><primary>rules</primary></indexterm>for ordering and nesting <indexterm><primary>nesting</primary></indexterm>them. This allows for labelling domain-specific <indexterm><primary>domain-specific</primary></indexterm>data in a consistent <indexterm><primary>consistent</primary></indexterm>way which allow s new applications to match the input file with the DTD <indexterm><primary>DTD</primary></indexterm>to parse, validate <indexterm><primary>validate</primary></indexterm>and manipulate the data stream.<indexterm><primary>stream</primary></indexterm></para></listitem></varlistentry><varlistentry><term>DSSSL
</term><listitem><para><indexterm><primary>DSSSL</primary></indexterm>(Document Style Specifications <indexterm><primary>Specifications</primary></indexterm>and Semantics <indexterm><primary>Semantics</primary></indexterm>Language) A scheme-based<indexterm><primary>scheme-based</primary></indexterm> language for rendering <indexterm><primary>rendering</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>documents, DSSSL <indexterm><primary>DSSSL</primary></indexterm>code will specify the placements and font manipulations for each tag in the specified DTD.<indexterm><primary>DTD</primary></indexterm> While many shops prefer the XSL <indexterm><primary>XSL</primary></indexterm>method of doing the same formatting <indexterm><primary>formatting</primary></indexterm>function, DSSSL <indexterm><primary>DSSSL</primary></indexterm>is the most common method in the DocBook <indexterm><primary>DocBook</primary></indexterm>and OpenJade <indexterm><primary>OpenJade</primary></indexterm>world.</para></listitem></varlistentry><varlistentry><term>XSL
</term><listitem><para><indexterm><primary>XSL</primary></indexterm>(eXtensible Style Language) A text format specification <indexterm><primary>specification</primary></indexterm>language which is itself an XML; many sites prefer XSL <indexterm><primary>XSL</primary></indexterm>to DSSSL <indexterm><primary>DSSSL</primary></indexterm>because the same editing tools <indexterm><primary>tools</primary></indexterm>used for the document <indexterm><primary>document</primary></indexterm>can also be used on the stylesheet.<indexterm><primary>stylesheet</primary></indexterm></para></listitem></varlistentry><varlistentry><term>DocBook
</term><listitem><para><indexterm><primary>DocBook</primary></indexterm>A document <indexterm><primary>document</primary></indexterm>definition markup <indexterm><primary>markup</primary></indexterm>language which defines a set of SGML<indexterm><primary>SGML</primary></indexterm> tags for the specific purpose of producing technical documentation. DocBook <indexterm><primary>DocBook</primary></indexterm>is used with a DSSSL <indexterm><primary>DSSSL</primary></indexterm>or XSL <indexterm><primary>XSL</primary></indexterm>to create document <indexterm><primary>document</primary></indexterm>source files which will be portable across different display methods, for example, one document<indexterm><primary>document</primary></indexterm> which renders in Postscript, <productname>Windows</productname> <indexterm><primary>Windows</primary></indexterm>and <application>Java</application> <indexterm><primary>Java</primary></indexterm>Help, PDF,<indexterm><primary>PDF</primary></indexterm> RTF,<indexterm><primary>RTF</primary></indexterm> <acronym>ASCII</acronym> <indexterm><primary>ASCII</primary></indexterm>and HTML.<indexterm><primary>HTML</primary></indexterm> </para></listitem></varlistentry></variablelist></sect1>
</chapter>
<chapter id="introduction"><title>Introduction</title><para>Do you want to create professionally formatted documents? Tired of always having to change the font settings, to insert or delete pagebreaks,<indexterm><primary>pagebreaks</primary></indexterm> to format your text for printing, monitor, or web view? Do you find yourself spending hours of your life into formatting <indexterm><primary>formatting</primary></indexterm>issues that you wish you never had to be conftonted with? Did you, during your editing efforts, ever get the uncomforting feeling that you are inventing the wheel <indexterm><primary>wheel</primary></indexterm>for th 39th time? </para><para>Well, in fact you are! This document <indexterm><primary>document</primary></indexterm>will show you how to use the power of Open Source tools <indexterm><primary>tools</primary></indexterm>like <ulink url="http://www.lyx.org">LyX</ulink>
<citation role="REFDB"><xref linkend="IDLyX0X"></citation>
 and <ulink url="http://www.sgmltools.org">sgmltools</ulink>
<citation role="REFDB"><xref linkend="IDde_Groot0X"></citation>
 to create the documents you've dreamed of, while, as a nice side effect, concentrating on what deserves most of your attention: Content, not Formatting! I will describe a method by which all you have to do is to write your document<indexterm><primary>document</primary></indexterm> in LyX, then run the . lyx <indexterm><primary>lyx</primary></indexterm>file through a script that will produce the SGML<indexterm><primary>SGML</primary></indexterm> source and, from it, the HTML,<indexterm><primary>HTML</primary></indexterm> TXT,<indexterm><primary>TXT</primary></indexterm> RTF,<indexterm><primary>RTF</primary></indexterm> PDF <indexterm><primary>PDF</primary></indexterm>and PS <indexterm><primary>PS</primary></indexterm>formatted documents, complete with table of contents, embedded<indexterm><primary>embedded</primary></indexterm> pictures, fonts,<indexterm><primary>fonts</primary></indexterm> thumbnails <indexterm><primary>thumbnails</primary></indexterm>(for PDF) and other goodies.</para><sect1 id="general-idea"><title>The general idea </title><para>When writing LyX <indexterm><primary>LyX</primary></indexterm>documents, formatting <indexterm><primary>formatting</primary></indexterm>should be the last thing on your mind. Concentrate on writing a clear and concise document.<indexterm><primary>document</primary></indexterm> The sgml parser <indexterm><primary>parser</primary></indexterm>will take care of the formatting.<indexterm><primary>formatting</primary></indexterm>We've all heard of WYSIWYG.<indexterm><primary>WYSIWYG</primary></indexterm> <ulink url="http://www.lyx.org">LyX</ulink> is WYGIWYM.<indexterm><primary>WYGIWYM</primary></indexterm> WYGIWYM <indexterm><primary>WYGIWYM</primary></indexterm>stands for &quot;What You Get Is What You Mean&quot;. This means if you mean for text to represent source code you assign it a source code environment <indexterm><primary>environment</primary></indexterm>(Lyxese for style), and it formats the way you meant it to. You needn't worry about formatting <indexterm><primary>formatting</primary></indexterm>during the writing of your document.<indexterm><primary>document</primary></indexterm> If you don't like the way it looks upon finishing and printing it out, you can change the way styles map to formatting,<indexterm><primary>formatting</primary></indexterm> and those styles will consistently change throughout the document.<indexterm><primary>document</primary></indexterm></para></sect1>
<sect1 id="line-of-attack"><title>Line of attack </title><para>The method described here follows a line of attack defined by the following:</para><itemizedlist><listitem><para>We will put everything in a shell script. We don't want to bother about anything else. We want to ponder comfortably upon the meaning of life while drinking <indexterm><primary>drinking</primary></indexterm>some coffee <indexterm><primary>coffee</primary></indexterm>or tea,<indexterm><primary>tea</primary></indexterm> watching our computer do the work for us - personally, a very rewarding experience :-)</para></listitem><listitem><para>We will use <ulink url="http://www.gnu.org/software/sed/manual/sed.html">sed</ulink> to correct LyX' SGML <indexterm><primary>SGML</primary></indexterm>output. The more we are able to correct, the more SGML <indexterm><primary>SGML</primary></indexterm>features we get out of our plain vanilla <indexterm><primary>vanilla</primary></indexterm>LyX.<indexterm><primary>LyX</primary></indexterm></para></listitem><listitem><para>We use the <ulink url="http://www.sgmltools.org">sgmltools</ulink> package which hides a lot of details from the end user, giving nonetheless all the power of the involved tools.<indexterm><primary>tools</primary></indexterm><footnote><para>The current version of the <ulink url="lyxtox">lyxtox</ulink> script does not make use of sgmltools, due to the need of processing intermediate results for the integration of Mathematics, Bibliography etc., as well as problems in the processing that turned out to be very difficult to debug, see <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=3053">runbib not working from lyxtox</ulink>.</para></footnote></para></listitem><listitem><para>We will adapt the <ulink url="http://docbook.sourceforge.net/projects/dsssl/">DocBook DSSSL stylesheets</ulink> to our personal needs and taste.</para></listitem><listitem><para>The end product shall be a directory ready to upload to our web server with all files, links, images and formats necessary.</para></listitem></itemizedlist></sect1>
</chapter>
<chapter id="required-software"><title>Required software </title><para>The method described in this document <indexterm><primary>document</primary></indexterm>requires a well-configured <indexterm><primary>well-configured</primary></indexterm>Linux system, armed with a heavy machinery <indexterm><primary>machinery</primary></indexterm>of various software packages:<indexterm><primary>packages</primary></indexterm> </para><itemizedlist><listitem><para>LyX <indexterm><primary>LyX</primary></indexterm>
<citation role="REFDB"><xref linkend="IDLyX0S"></citation>
(of course!), see <xref linkend="LyX">. You MUST use the 1.2.0 version of LyX, offered in <xref linkend="LyX">! Newer versions will NOT work, unless you tweak the sed scripts of this package.</para></listitem><listitem><para>DocBook
<citation role="REFDB"><xref linkend="IDWalsh2002X"></citation>
, see <xref linkend="DocBook">.</para></listitem><listitem><para>sgmltools
<citation role="REFDB"><xref linkend="IDde_Groot0S"></citation>
, see <xref linkend="sgmltools"> (currently not needed).</para></listitem><listitem><para>Openjade, pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>and jadetex <indexterm><primary>jadetex</primary></indexterm>see <xref linkend="openjade-pdftex-jadetex">.</para></listitem><listitem><para>TeX <indexterm><primary>TeX</primary></indexterm>and LaTeX<indexterm><primary>LaTeX</primary></indexterm>
<citation role="REFDB"><xref linkend="IDCTAN0X"></citation>
, see <xref linkend="TeX-LaTeX">.</para></listitem><listitem><para><ulink url="http://www.gnu.org/software/sed/manual/sed.html">sed</ulink>, <ulink url="runsed">runsed</ulink> and <ulink url="http://www.gnu.org/software/gawk/manual/gawk.html">awk</ulink>, see <xref linkend="sed-and-awk">.</para></listitem><listitem><para>thumbpdf, see <xref linkend="thumbpdf">.</para></listitem><listitem><para>dvips, ghostscript <indexterm><primary>ghostscript</primary></indexterm>and ImageMagik,<indexterm><primary>ImageMagik</primary></indexterm> see <xref linkend="dvips-Ghostscript-Imagemagik">.</para></listitem><listitem><para>Lynx, the text browser,<indexterm><primary>browser</primary></indexterm> see <xref linkend="lynx">. Lynx <indexterm><primary>Lynx</primary></indexterm>will be used to convert <indexterm><primary>convert</primary></indexterm>the HTML <indexterm><primary>HTML</primary></indexterm>output in plain text, thus giving us the TXT <indexterm><primary>TXT</primary></indexterm>version of our document.<indexterm><primary>document</primary></indexterm></para></listitem><listitem><para>HTMLtidy, see <xref linkend="HTML-tidy"></para></listitem><listitem><para><ulink url="http://refdb.sourceforge.net">RefDB</ulink>, if you want to use bibliographies <indexterm><primary>bibliographies</primary></indexterm>with entries taken from a bibliography<indexterm><primary>bibliography</primary></indexterm> server and formatted automatically <indexterm><primary>automatically</primary></indexterm>according to the author guidelines of the Journal you are submitting your paper,<indexterm><primary>paper</primary></indexterm> see <xref linkend="Refdb">. </para></listitem><listitem><para>Perl, for the Index generation through the collateindex.<indexterm><primary>collateindex</primary></indexterm>pl script (see <xref linkend="explain-index">).</para></listitem><listitem><para><ulink url="http://www.ringlord.com/publications/latex-pdf-howto">coolthumbs</ulink>, if you want antialiased thumbnails in PDF.</para></listitem></itemizedlist><para>In the following, I will describe the required software in more detail. Of course, I cannot cover all details. See the documentation that comes with each tool and, for an alternative description, the <ulink url="http://docbook.org/tdg/en/html/appa.html">Apendix</ulink>
<citation role="REFDB"><xref linkend="IDWalsh2002S"></citation>
 of <ulink url="http://docbook.org/tdg/en/html/">DocBook: The definitive Guide</ulink>.</para><important>
<title>Version-specific tweaks!</title> 
<para> 
The method I will describe (more precisely, the <ulink url="sedscr">sed script that corrects LyX' SGML output</ulink>) is tailored to LyX 1.2.0-91, a rather dated version I use from a <productname>SuSE</productname> <acronym>RPM</acronym>. If you have a newer version of LyX, you will almost certainly have to tweak <ulink url="sedscr">sedscr</ulink>, since SGML output has been corrected in the newer 1.3.x versions. But the important thing is the method, not the version-specific tweaks, which you should be able to figure out yourself with a firm knowledge of sed, regular expressions and the help of this guide!<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject>
</para> 
</important>
<para>Currently, you should stick to the rather dated 1.2.0 version from one of the RPMs in <xref linkend="LyX">, for reasons discussed in <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=860">LyX 1.3.4 not suitable for Mathematics work in DocBook</ulink>.</para><para>I have not investigated the portability <indexterm><primary>portability</primary></indexterm>of the method across operating <indexterm><primary>operating</primary></indexterm>systems. I have developed and tested it on a (rather dated) <productname>SuSE</productname> <productname>Linux</productname> 7.3 system and, more recently, on a <productname>SuSE</productname> <productname>Linux</productname> 9.0 system. Portability <indexterm><primary>Portability</primary></indexterm>to other operating <indexterm><primary>operating</primary></indexterm>systems is dependent on the availability<indexterm><primary>availability</primary></indexterm> of the software needed and the scripting <indexterm><primary>scripting</primary></indexterm>facilities offered. Any porting <indexterm><primary>porting</primary></indexterm>efforts are welcome.</para><sect1 id="LyX"><title>LyX </title><para>In case you are wondering what LyX <indexterm><primary>LyX</primary></indexterm>is, here is what <ulink url="http://www.lyx.org">http://www.lyx.org</ulink> says on the subject:</para><blockquote><para>LyX <indexterm><primary>LyX</primary></indexterm>is an advanced open source document <indexterm><primary>document</primary></indexterm>processor that encourages an approach<indexterm><primary>approach</primary></indexterm> to writing based on the structure of your documents, not their appearance. LyX <indexterm><primary>LyX</primary></indexterm>lets you concentrate on writing, leaving details of visual layout <indexterm><primary>layout</primary></indexterm>to the software.</para><para>LyX <indexterm><primary>LyX</primary></indexterm>runs on many Unix <indexterm><primary>Unix</primary></indexterm>platforms,<indexterm><primary>platforms</primary></indexterm> OS/2, and under Windows/Cygwin (this port requires an X server). It can also run natively <indexterm><primary>natively</primary></indexterm>on Mac OS X, thanks to the Qt/Mac library.</para><para>LyX <indexterm><primary>LyX</primary></indexterm>produces high quality, professional <indexterm><primary>professional</primary></indexterm>output -- using LaTeX,<indexterm><primary>LaTeX</primary></indexterm> an industrial<indexterm><primary>industrial</primary></indexterm> strength typesetting engine, in the background;<indexterm><primary>background</primary></indexterm> LyX <indexterm><primary>LyX</primary></indexterm>is far more than a front-end to LaTeX,<indexterm><primary>LaTeX</primary></indexterm> however. No knowledge of <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>is necessary to use LyX,<indexterm><primary>LyX</primary></indexterm> although it will give a user more power.</para><para>LyX <indexterm><primary>LyX</primary></indexterm>is stable and fully featured. It has been used for documents as large as a thesis,<indexterm><primary>thesis</primary></indexterm> or as small as a business letter. Despite its simple <acronym>GUI</acronym> <indexterm><primary>GUI</primary></indexterm>interface (available in many languages), it supports tables, figures,<indexterm><primary>figures</primary></indexterm> and hyperlinked <indexterm><primary>hyperlinked</primary></indexterm>cross-references, and has a best-of-breed<indexterm><primary>best-of-breed</primary></indexterm> math <indexterm><primary>math</primary></indexterm>editor.</para></blockquote><para>Get a suitable version of LyX <indexterm><primary>LyX</primary></indexterm>available fo your distribution.<indexterm><primary>distribution</primary></indexterm> I prefer to get the source RPM,<indexterm><primary>RPM</primary></indexterm> like lyx-1.2.0-91.<indexterm><primary>lyx-1.2.0-91</primary></indexterm>src.rpm and then compile it with </para><screen><![CDATA[rpm --rebuild /usr/src/lyx-1.2.0-91.src.rpm
]]></screen><para><emphasis>Update</emphasis>: Versions 1.3.2 and 1.3.4 of LyX <indexterm><primary>LyX</primary></indexterm>do NOT work for our purposes! Version 1.3.2 brings the error <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=734">Counter does not exist: sect1</ulink> and version 1.3.4 does not contain the &ldquo;begin{equation}&rdquo; commands in the alt part of the equation element <indexterm><primary>element</primary></indexterm>(see <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=860">LyX 1.3.4 not suitable for DocBook and Mathematics work</ulink>), thus making all our efforts to use the DBTeXMath<indexterm><primary>DBTeXMath</primary></indexterm> method (see <xref linkend="DBTeXMath">) fail in vain. I am currently in contact with the LyX <indexterm><primary>LyX</primary></indexterm>development team to iron these problems out. In the meantime, if you are having difficulties with your own LyX <indexterm><primary>LyX</primary></indexterm>version, you can use the following RPMs to install version 1.2.0-91 which is guaranteed to work:</para><itemizedlist><listitem><para><ulink url="http://www.karakas-online.de/downloads/lyx-1.2.0-91.i386.SuSE-7.3.rpm">LyX v. 1.2.0-91 i386 for <productname>SuSE</productname> 7.3 binary RPM</ulink></para></listitem><listitem><para><ulink url="http://www.karakas-online.de/downloads/lyx-1.2.0-91.i586.SuSE-9.0.rpm">LyX v. 1.2.0-91 i586 for <productname>SuSE</productname> 9.0 binary RPM</ulink></para></listitem></itemizedlist><para>If you want to compile version 1.2.0-91 for your own <productname>Linux</productname> system, here are the source RPMs:</para><itemizedlist><listitem><para><ulink url="http://www.karakas-online.de/downloads/lyx-1.2.0-91.src.rpm">LyX v. 1.2.0-91 i386 for <productname>SuSE</productname> 7.3 source RPM</ulink></para></listitem><listitem><para><ulink url="http://www.karakas-online.de/downloads/lyx-1.2.0-91-SuSE-9.0.src.rpm">LyX v. 1.2.0-91 i586 for <productname>SuSE</productname> 9.0 source RPM</ulink></para></listitem></itemizedlist><para>Note that the two source RPMs are practically identical, up to the lyx.<indexterm><primary>lyx</primary></indexterm>spec file and an extra dif file for src/frontends/xforms/GUIRunTime.C. This is due to the renaming of some packages <indexterm><primary>packages</primary></indexterm>under <productname>SuSE</productname> 9.0, which makes changes in the &ldquo;# usedforbuild&rdquo; part of the spec file necessary, as well as to the check for the xforms package version that accepts only versions 0.88 and 0.89 - while in <productname>SuSE</productname> 9.0 we have already arrived at xforms 1.0-137! See <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=861">How to compile an older version for a newer system in RPM</ulink> for the details.</para><para>You might have to install doxygen <indexterm><primary>doxygen</primary></indexterm>(SuSE: Series d, install with YaST). The rebuild process of rpm creates a new <acronym>RPM</acronym> <indexterm><primary>RPM</primary></indexterm>packet of LyX,<indexterm><primary>LyX</primary></indexterm> as one can see from the last lines of the long output:</para><screen><![CDATA[Processing files: lyx-1.2.0-91 
]]><![CDATA[Finding Provides: (using /usr/lib/rpm/find-provides)... 
]]><![CDATA[Finding Requires: (using /usr/lib/rpm/find-requires)... 
]]><![CDATA[Requires: tetex te_latex /bin/bash /bin/sh /usr/bin/perl
]]><![CDATA[/usr/bin/python ld-linux.so.2 libICE.so.6 libSM.so.6 libX11.so.6
]]><![CDATA[libXpm.so.4 libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1)
]]><![CDATA[libc.so.6(GLIBC_2.1.3) libforms.so.0.89 libjpeg.so.62 libm.so.6
]]><![CDATA[libm.so.6(GLIBC_2.0) libstdc++-libc6.2-2.so.3 
]]><![CDATA[Wrote: /usr/src/packages/RPMS/i386/lyx-1.2.0-91.i386.rpm
]]></screen><para>Install the newly created <acronym>RPM</acronym> <indexterm><primary>RPM</primary></indexterm>package as usual, either with YaST,<indexterm><primary>YaST</primary></indexterm> or with</para><screen><![CDATA[rpm -Uvh /usr/src/packages/RPMS/i386/lyx-1.2.0-91.i386.rpm
]]></screen><note>
<title>Please note:</title> 
<para> 
As you can see from the above output of the rebuild command, LyX requires the following packages and libraries to be already installed on your system:
<screen>
Requires: tetex te_latex /bin/bash /bin/sh /usr/bin/perl
/usr/bin/python ld-linux.so.2 libICE.so.6 libSM.so.6 libX11.so.6
libXpm.so.4 libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.1.3) libforms.so.0.89 libjpeg.so.62 libm.so.6
libm.so.6(GLIBC_2.0) libstdc++-libc6.2-2.so.3
</screen>
</para> 
</note>
<para>On <productname>SuSE</productname> systems, if you install Lyx with the above rpm command, it is a good idea to either run SuSEconfig,<indexterm><primary>SuSEconfig</primary></indexterm> or just the part of SuSEconfig <indexterm><primary>SuSEconfig</primary></indexterm>that is relevant to LyX,<indexterm><primary>LyX</primary></indexterm> /sbin/conf.d/SuSEconfig.lyx:</para><screen><![CDATA[/sbin/conf.d/SuSEconfig.lyx  Running LyX configure script ...
]]></screen><para>On other systems, you may have to reconfigure <indexterm><primary>reconfigure</primary></indexterm>LyX by hand: This is done from the menu Edit--&gt;Reconfigure. See <xref linkend="reconfigure-LyX">.</para><para>Now your LyX <indexterm><primary>LyX</primary></indexterm>is up-to-date. You just have to write your document <indexterm><primary>document</primary></indexterm>with it. Since LyX <indexterm><primary>LyX</primary></indexterm>comes with a well written Tutorial (written itself in LyX), as well as User Guide (both easily acessed from the Help menue), I will not delve into the details of writing with LyX <indexterm><primary>LyX</primary></indexterm>here.</para></sect1>
<sect1 id="DocBook"><title>DocBook </title><para>Here is what the <ulink url="http://www.tldp.org/">LDP-Author-Guide</ulink> says about DocBook:<indexterm><primary>DocBook</primary></indexterm></para><blockquote><para>To explain what DocBook <indexterm><primary>DocBook</primary></indexterm>is, we must first take a look at what SGML <indexterm><primary>SGML</primary></indexterm>and XML are, and their relationship to DocBook.<indexterm><primary>DocBook</primary></indexterm></para><para>The Standard Generalized Markup <indexterm><primary>Markup</primary></indexterm>Language (SGML) is a language that is based on embedding <indexterm><primary>embedding</primary></indexterm>codes within a document.<indexterm><primary>document</primary></indexterm> In this way, it is similar to HTML,<indexterm><primary>HTML</primary></indexterm> but there is where any similarities end. The power of SGML <indexterm><primary>SGML</primary></indexterm>is that unlike WYSIWYG <indexterm><primary>WYSIWYG</primary></indexterm>(What You See Is What You Get), you don't define things like colors, or font sizes, or even some kinds of formatting.<indexterm><primary>formatting</primary></indexterm> Instead, you define elements (paragraph, section, numbered list) and let the SGML <indexterm><primary>SGML</primary></indexterm>processor and the end program worry about placement, colors, fonts,<indexterm><primary>fonts</primary></indexterm> and so on. HTML <indexterm><primary>HTML</primary></indexterm>does the same thing, and is actually a subset of SGML.<indexterm><primary>SGML</primary></indexterm> SGML <indexterm><primary>SGML</primary></indexterm>has really three parts that make it up. First is the Structure, which is what is commonly called the DTD,<indexterm><primary>DTD</primary></indexterm> or Document Type Definition. The DTD <indexterm><primary>DTD</primary></indexterm>defines the relationship between each of the elements (or tags). The DocBook <indexterm><primary>DocBook</primary></indexterm>DTD,<indexterm><primary>DTD</primary></indexterm> used to create this document,<indexterm><primary>document</primary></indexterm> is an example of this. The DTD <indexterm><primary>DTD</primary></indexterm>lists the rules <indexterm><primary>rules</primary></indexterm>that the content must follow. Second is the DSSSL <indexterm><primary>DSSSL</primary></indexterm>or Document Style Semantics <indexterm><primary>Semantics</primary></indexterm>and Specification <indexterm><primary>Specification</primary></indexterm>Language. The DSSSL <indexterm><primary>DSSSL</primary></indexterm>tells the program doing the rendering <indexterm><primary>rendering</primary></indexterm>how to convert <indexterm><primary>convert</primary></indexterm>the SGML<indexterm><primary>SGML</primary></indexterm> into something that a human can read. It tells the renderer to convert <indexterm><primary>convert</primary></indexterm>a title tag into 14 point bold if it is going to RTF <indexterm><primary>RTF</primary></indexterm>format, or to turn it into a &lt;h1&gt; tag if it is going to HTML.<indexterm><primary>HTML</primary></indexterm> Finally there is the Content, which is what gets rendered by the SGML <indexterm><primary>SGML</primary></indexterm>processor and is eventually seen by the user. This paragraph <indexterm><primary>paragraph</primary></indexterm>is content, but so is a graphic image, a table, a numbered list, and so on. Content is surrounded by tags to separate each element.<indexterm><primary>element</primary></indexterm></para></blockquote><para>The following features must be installed to make DocBook <indexterm><primary>DocBook</primary></indexterm>usable (the RPM<indexterm><primary>RPM</primary></indexterm> names and versions I mention refer to the ones I have installed on my <ulink url="http://www.suse.com">SuSE Linux</ulink>  7.3 system): </para><itemizedlist><listitem><para>The DocBook <indexterm><primary>DocBook</primary></indexterm>DTD <indexterm><primary>DTD</primary></indexterm><ulink url="http://www.oasis-open.org/docbook/sgml/4.1/docbk41.zip">version 4.1</ulink> or <ulink url="http://www.oasis-open.org/docbook/sgml/3.1/docbk31.zip">version 3.1</ulink>. LyX, starting from version 1.2.0, uses version 4.1 while older versions use version 3.1. (RPM: docbook_4-4.1-97 <indexterm><primary>docbook_4-4.1-97</primary></indexterm>and docbook_3-3.1-98 <indexterm><primary>docbook_3-3.1-98</primary></indexterm>respectively. I have also html-dtd-2001.11.7-0 installed, ). More recent versions, like docbook_3-3.1-468 and docbook_4-4.2-362 also seem to work O.K.</para></listitem><listitem><para>The ISO <indexterm><primary>ISO</primary></indexterm>entities,<indexterm><primary>entities</primary></indexterm> that define some standard SGML <indexterm><primary>SGML</primary></indexterm>entities (e.g. &amp;gt;, &amp;lt;, etc.) (RPM: iso_ent-2000.11.03-122. The newer iso_ent-2000.11.03-531 also seems O.K.)</para></listitem><listitem><para>The <ulink url="http://nwalsh.com/docbook/dsssl/">Norman Walsh's DocBook DSSSL modular stylesheets</ulink>(RPM: docbook-dsssl-stylesheets-1.78-78).<indexterm><primary>docbook-dsssl-stylesheets-1.72-34</primary></indexterm>. The 1.72 and 1.78 versions are known to work. The 1.79 version has some problems (for example, it does not display the information in &lt;othercredit&gt; elements, see <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=4295">Trouble with new version of lyxtox scripts</ulink>), so it is not recommended. You can get the 1.78 version from <ulink url="http://www.karakas-online.de/downloads/docbook-dsssl-stylesheets-1.78-78.noarch.rpm">docbook-dsssl-stylesheets-1.78-78</ulink>.</para></listitem><listitem><para>Jade/jadetex/openjade (version 3.0) (RPM: openjade-1.3-289,<indexterm><primary>openjade-1.3-289</primary></indexterm> jade_dsl-1.2.1-369, <indexterm><primary>jade_dsl-1.2.1-369,</primary></indexterm>jadetex-3.11-65). See also <xref linkend="openjade-pdftex-jadetex"></para></listitem><listitem><para>SGMLtools-lite <indexterm><primary>SGMLtools-lite</primary></indexterm>(RPM: sgmltools-lite-3.0.2-164). Currently not needed, see also <xref linkend="sgmltools">.</para></listitem><listitem><para>Of course, you have to satisfy all the dependencies of the above packages.<indexterm><primary>packages</primary></indexterm> This can be quite a nightmare if you choose to do it &ldquo;by hand&rdquo;, as you can read in my <ulink url="http://www.karakas-online.de/myJade/">Jade installation notes</ulink>.</para></listitem></itemizedlist></sect1>
<sect1 id="sgmltools"><title>sgmltools </title><para>sgmltools-lite <indexterm><primary>sgmltools-lite</primary></indexterm>is a package whose purpose is to simplify the document <indexterm><primary>document</primary></indexterm>creation process from SGML <indexterm><primary>SGML</primary></indexterm>to some other format. It takes the complexity <indexterm><primary>complexity</primary></indexterm>of the various commands involved and takes care of all the invocations <indexterm><primary>invocations</primary></indexterm>and the options required. I used sgmltools-lite-3.0.2-164.<indexterm><primary>sgmltools-lite-3.0.2-164</primary></indexterm> However, the current version of the scripts does not use sgmltools <indexterm><primary>sgmltools</primary></indexterm>anymore, so you don't need it. Some code of the print.dsl <indexterm><primary>print.dsl</primary></indexterm>file of this package was used in the lyxtox <indexterm><primary>lyxtox</primary></indexterm>stylesheets, but again, no changes are needed on your part.</para></sect1>
<sect1 id="openjade-pdftex-jadetex"><title>Openjade, pdfTeX and JadeTeX</title><para>Openjade <indexterm><primary>Openjade</primary></indexterm>renders the SGML <indexterm><primary>SGML</primary></indexterm>documents (that we will export from LyX) to the various other formats, like HTML,<indexterm><primary>HTML</primary></indexterm> RTF,<indexterm><primary>RTF</primary></indexterm> <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>etc. I use:</para><itemizedlist><listitem><para>openjade-1.3-289: renders and validates the SGML <indexterm><primary>SGML</primary></indexterm>code based on the DTD <indexterm><primary>DTD</primary></indexterm>and DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet. </para></listitem><listitem><para>pdfTeX-0.13d. I had to upgrade <indexterm><primary>upgrade</primary></indexterm>to for the same reason I had to upgrade <indexterm><primary>upgrade</primary></indexterm>openjade.</para></listitem><listitem><para>JadeTeX-3.11-65 <indexterm><primary>JadeTeX-3.11-65</primary></indexterm>(needed to process the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>format created by openjade <indexterm><primary>openjade</primary></indexterm>when called with the &ldquo;-b tex&rdquo; option). </para></listitem></itemizedlist><para>Due to an error in a rather exotic situation (see <xref linkend="fatal-format-file-error">), I recently had to upgrade <indexterm><primary>upgrade</primary></indexterm>pdfTeX <indexterm><primary>pdfTeX</primary></indexterm>to version 1.11b, or more precisely (Web2C 7.5.2) 3.141592-1.11b, and JadeTeX <indexterm><primary>JadeTeX</primary></indexterm>to version 3.13 - definitely recommended.</para><para>See the <acronym>LDP</acronym> <indexterm><primary>LDP</primary></indexterm>Author's Guide 
<citation role="REFDB"><xref linkend="IDKomarinski0X"></citation>
 for more details on these programs.</para></sect1>
<sect1 id="TeX-LaTeX"><title>TeX and <application>LaTeX</application> </title><para>LyX <indexterm><primary>LyX</primary></indexterm>is a <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>front end. It was primarily designed with <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>and <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>in mind. It provides a more or less WYSIWYG <indexterm><primary>WYSIWYG</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>for TeX/LaTeX. Further, since we will use the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>format to create PDF <indexterm><primary>PDF</primary></indexterm>documents through pdfjadetex,<indexterm><primary>pdfjadetex</primary></indexterm> we will need as much <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>related machinery <indexterm><primary>machinery</primary></indexterm>as we can get. This practically means that you should install all the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>and <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>packages that come with your didtribution.<indexterm><primary>didtribution</primary></indexterm> For example:</para><itemizedlist><listitem><para>te_etex-1.0.7-319</para></listitem><listitem><para>texinfo-4.0-268</para></listitem><listitem><para>tetex-1.0.7-319</para></listitem><listitem><para>te_latex-1.0.7-319</para></listitem><listitem><para>te_pdf-1.0.7-476</para></listitem><listitem><para>db2latex-0.5.1-15</para></listitem></itemizedlist></sect1>
<sect1 id="dvips-Ghostscript-Imagemagik"><title>Dvips, Ghostscript and ImageMagik</title><para>You'll need dvips <indexterm><primary>dvips</primary></indexterm>for the creation of the PostScript®<indexterm><primary>PostScript®</primary></indexterm><footnote><para>PostScript® is a registered trademark of Adobe Systems Incorporated, and is the main page description language in the UN*X world. </para></footnote> format. You will need Ghostscript <indexterm><primary>Ghostscript</primary></indexterm>for the creation of thumbnails <indexterm><primary>thumbnails</primary></indexterm>for PDF <indexterm><primary>PDF</primary></indexterm>(see <xref linkend="thumbpdf">), as well as for various conversions of your images (see <xref linkend="add-density">), where ImageMagik <indexterm><primary>ImageMagik</primary></indexterm>will also play a central role:</para><itemizedlist><listitem><para><indexterm><primary>typewriter</primary></indexterm>dvips<footnote><para>part of the tetex package on my <productname>SuSE</productname> system, see <xref linkend="TeX-LaTeX">.</para></footnote></para></listitem><listitem><para><indexterm><primary>typewriter</primary></indexterm>ghostscript</para></listitem><listitem><para><indexterm><primary>typewriter</primary></indexterm>xdvi<footnote><para>part of the tetex package on my <productname>SuSE</productname> system, see <xref linkend="TeX-LaTeX">.</para></footnote></para></listitem><listitem><para><indexterm><primary>typewriter</primary></indexterm> ghostview <indexterm><primary>ghostview</primary></indexterm>(package gv-3.5.8-718)</para></listitem></itemizedlist><para>The latter two programs are previewer for files in Dvi and PostScript® <indexterm><primary>PostScript®</primary></indexterm>format. If you don't know what a dvi-file <indexterm><primary>dvi-file</primary></indexterm>is, you've probably also never worked with <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>and should read the <emphasis>Tutorial</emphasis> document <indexterm><primary>document</primary></indexterm>before proceeding further.</para></sect1>
<sect1 id="thumbpdf"><title>thumbpdf</title><para>The thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>package by Heiko Oberdiek<indexterm><primary>Oberdiek</primary></indexterm> installs the <application>Perl</application> program thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>on your system. With the help of thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>and Ghostscript <indexterm><primary>Ghostscript</primary></indexterm>(which should also be installed), you can create thumbnails <indexterm><primary>thumbnails</primary></indexterm>for the PDF <indexterm><primary>PDF</primary></indexterm>document (to be seen when you click on the &ldquo;thumbnails&rdquo; register card in Acrobat® <indexterm><primary>Acrobat®</primary></indexterm>Reader<footnote><para>Acrobat® is a registered trademark of Adobe Systems Incorporated. </para></footnote>). Thumbnails are embedded <indexterm><primary>embedded</primary></indexterm>images of the document's pages, drawn in small size and resolution.<indexterm><primary>resolution</primary></indexterm> Their purpose is to facilitate navigation through the document <indexterm><primary>document</primary></indexterm>(of course only if the PDF <indexterm><primary>PDF</primary></indexterm>viewer supports them). </para><para>Thumbnails will be created automatically <indexterm><primary>automatically</primary></indexterm>by the <ulink url="lyxtox">lyxtox</ulink> script and will be embedded <indexterm><primary>embedded</primary></indexterm>in the PDF <indexterm><primary>PDF</primary></indexterm>document whithout any user intervention (see <xref linkend="explain-document-creation-PDF"> for a detailed description). You just have to take care that the thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>package is installed. </para><para>You can download thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>from <ulink url="http://www.ctan.org/tex-archive/help/Catalogue/entries/thumbpdf.html">CTAN: thumbpdf</ulink>. After download and extraction of the package, the files</para><itemizedlist><listitem><para>readme.txt (documentation)</para></listitem><listitem><para>thumbpdf.tex (pdftex)</para></listitem><listitem><para>thumbpdf.sty (pdf(e)tex, pdf(e)latex, (e)tex, (e)latex)</para></listitem></itemizedlist><para>should be moved to</para><itemizedlist><listitem><para>texmf/doc/generic/thumbpdf/readme.txt</para></listitem><listitem><para>texmf/tex/generic/thumbpdf/thumbpdf.tex</para></listitem><listitem><para>texmf/tex/generic/thumbpdf/thumbpdf.sty</para></listitem></itemizedlist><para>respectively. The <application>Perl</application> script itself, thumbpdf.pl,<indexterm><primary>thumbpdf.pl</primary></indexterm> may be renamed to thumbpdf:<indexterm><primary>thumbpdf</primary></indexterm></para><screen><![CDATA[mv thumbpdf.pl thumbpdf
]]></screen><para>Ensure that the execute permission is set:</para><screen><![CDATA[chmod +x thumbpdf
]]></screen><para>then move the file to a directory where the shell can find it (according to the PATH <indexterm><primary>PATH</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>variable, e.g. /usr/local/bin/):</para><screen><![CDATA[mv thumbpdf /usr/local/bin/thumbpdf
]]></screen><para>Requires:</para><itemizedlist><listitem><para>Perl5 <indexterm><primary>Perl5</primary></indexterm>(version 5 of the perl <indexterm><primary>perl</primary></indexterm>interpreter).</para></listitem><listitem><para>Ghostscript:</para><itemizedlist><listitem><para>Thumbnail generation: version 5.50 or better 6.0.</para></listitem><listitem><para>Thumbnail inclusion with ps2pdf:<indexterm><primary>ps2pdf</primary></indexterm> version 6.0.</para></listitem></itemizedlist></listitem><listitem><para>pdfTeX.</para></listitem></itemizedlist></sect1>
<sect1 id="sed-and-awk"><title>Sed and awk</title><para><ulink url="http://www.gnu.org/software/sed/manual/sed.html">sed</ulink> is a stream <indexterm><primary>stream</primary></indexterm>editor. A stream <indexterm><primary>stream</primary></indexterm>editor is used to perform basic text transformations on an input stream <indexterm><primary>stream</primary></indexterm>(a file or inpu t from a pipeline). We will use sed extensively through scripts like <ulink url="runsed">runsed</ulink>, that is a wrapper <indexterm><primary>wrapper</primary></indexterm>around sed that takes a &ldquo;sed script&rdquo;, like <ulink url="sedscr">sedscr</ulink>, containing sed commands, as a first argument and the file to be transformed as a second. </para><para><ulink url="http://www.gnu.org/manual/gawk-3.0.3/gawk.html">awk</ulink> searches files for lines (or other units of text) that contain certain patterns.<indexterm><primary>patterns</primary></indexterm> When a line matches one of the patterns,<indexterm><primary>patterns</primary></indexterm> awk <indexterm><primary>awk</primary></indexterm>performs specified actions on that line. awk <indexterm><primary>awk</primary></indexterm>keeps processing <indexterm><primary>processing</primary></indexterm>input lines in this way until it reaches the end of the input files. We will use awk <indexterm><primary>awk</primary></indexterm>to split the sed processed files into header, body <indexterm><primary>body</primary></indexterm>and footer, in order to be able to manipulate these parts separately, before reassemblying them into a final document <indexterm><primary>document</primary></indexterm>for further processing.<indexterm><primary>processing</primary></indexterm></para><para>Most probably, your <productname>Linux</productname> distribution <indexterm><primary>distribution</primary></indexterm>has already installed sed and awk<indexterm><primary>awk</primary></indexterm> for you. In case it hasn't, use the package management <indexterm><primary>management</primary></indexterm>tool of the distribution<indexterm><primary>distribution</primary></indexterm> to install them, or compile them from the source, if you feel like.</para></sect1>
<sect1 id="lynx"><title>Lynx</title><para><ulink url="http://lynx.isc.org">Lynx</ulink> is a fully-featured <indexterm><primary>fully-featured</primary></indexterm>World Wide Web <indexterm><primary>Web</primary></indexterm>(WWW) client for users running cursor-addres<indexterm><primary>cursor-addres</primary></indexterm>sable, character-cell <indexterm><primary>character-cell</primary></indexterm>display devices (e.g., vt100 terminals,<indexterm><primary>terminals</primary></indexterm> vt100 emulators <indexterm><primary>emulators</primary></indexterm>running on <productname>Windows</productname> <indexterm><primary>Windows</primary></indexterm>95/NT or Macintoshes,<indexterm><primary>Macintoshes</primary></indexterm> or any other &quot;curses-oriented&quot; display). It will display hypertext <indexterm><primary>hypertext</primary></indexterm>markup <indexterm><primary>markup</primary></indexterm>language (HTML) documents containing links to files residing on the local system, as well as files residing on remote<indexterm><primary>remote</primary></indexterm> systems running Gopher, HTTP,<indexterm><primary>HTTP</primary></indexterm> FTP, WAIS, and NNTP <indexterm><primary>NNTP</primary></indexterm>servers. Current versions of Lynx <indexterm><primary>Lynx</primary></indexterm>run on Unix,<indexterm><primary>Unix</primary></indexterm> VMS, <productname>Windows</productname> <indexterm><primary>Windows</primary></indexterm>95/NT, 386DOS and OS/2 EMX.</para><para>We will use Lynx <indexterm><primary>Lynx</primary></indexterm>to transform the generated HTML <indexterm><primary>HTML</primary></indexterm>version of our document<indexterm><primary>document</primary></indexterm> to the plain text version, so you should have Lynx <indexterm><primary>Lynx</primary></indexterm>installed on your system.</para></sect1>
<sect1 id="HTML-tidy"><title>HTML tidy</title><para>When editing HTML <indexterm><primary>HTML</primary></indexterm>it's easy to make mistakes. Wouldn't it be nice if there was a simple way to fix these mistakes automatically and tidy <indexterm><primary>tidy</primary></indexterm>up sloppy <indexterm><primary>sloppy</primary></indexterm>editing into nicely layed out markup?<indexterm><primary>markup</primary></indexterm> Well now there is! Dave Raggett's HTML <indexterm><primary>HTML</primary></indexterm>TIDY <indexterm><primary>TIDY</primary></indexterm>is a free utility <indexterm><primary>utility</primary></indexterm>for doing just that. It also works great on the atrociously hard to read markup <indexterm><primary>markup</primary></indexterm>generated by specialized HTML <indexterm><primary>HTML</primary></indexterm>editors and conversion tools <indexterm><primary>tools</primary></indexterm>(like the ones we will be using), and can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities <indexterm><primary>disabilities</primary></indexterm>(see <xref linkend="accessibility">).</para><para>Tidy <indexterm><primary>Tidy</primary></indexterm>is able to fix up a wide range of problems (which is very good if you are trying to produce <emphasis>valid</emphasis> HTML,<indexterm><primary>HTML</primary></indexterm> as described in <xref linkend="HTML-validation">) and to bring to your attention things that you need to work on yourself. Each item found is listed with the line number and column so that you can see where the problem lies in your markup.<indexterm><primary>markup</primary></indexterm> Tidy <indexterm><primary>Tidy</primary></indexterm>won't generate a cleaned up version when there are problems that it can't be sure of how to handle. These are logged as &quot;errors&quot; rather than &quot;warnings&quot;. </para><para>See <ulink url="http://tidy.sourceforge.net">htmltidy</ulink> for more details. We call htmltidy <indexterm><primary>htmltidy</primary></indexterm>from within the <ulink url="lyxtox">lyxtox</ulink> script (see <xref linkend="explain-document-creation-HTML"> for the details). Download it and install it somewhere in your path.<indexterm><primary>path</primary></indexterm></para></sect1>
<sect1 id="Refdb"><title>Refdb</title><note>
<title>Alternative way for Bibliography</title>
<para>
You are not confined to using <ulink url="http://refdb.sourceforge.net">RefDB</ulink> whith my <ulink url="lyxtox">lyxtox</ulink> script. If you don't feel like building your own bibliographic database, you can skip this section and just supply a bibliography.lyx  file together with your LyX document. Set the process_RefDB variable in <ulink url="lyxtox">lyxtox</ulink> to "0" and it will use your own bibliography.lyx to produce a  bibliography.sgml file, instead of trying to create one automatically through RefDB.  The bibliography.lyx file should then contain the SGML code for the references list, in the SGML environment of LyX. The <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/">GNU/Linux Command-Line Tools Summary HOWTO</ulink> uses this approach, for example. See the <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/bibliography.lyx">bibliography.lyx</ulink> and <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/bibliography.sgml">bibliography.sgml</ulink> files in the  <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/introduction.html#FORMATS">Formats section of GNU/Linux Command-Line Tools Summary HOWTO</ulink>.
</para>
<para>
Be warned however, that writing a bibliography file with all your references in SGML is not fun and does not solve the problem of formatting those references to the style of the journal (or medium) you are submitting your work (for this you would need an extra DSSSL  stylesheet). In the long run, these two disadvantages will work against you to the point of being a real pain, especially if you submit the same work to more than one journals with conflicting formatting style guidelines regarding references. 
</para>
<para>
Read <ulink url="http://refdb.sourceforge.net/manual-0.9.4/x107.html">Who should use refdb?</ulink> - it will help you decide whether you need RefDB or not.
</para>
</note>
<important>
<title>RefDB problems</title>
<para>
Currently, version 0.9.4-pre5 of RefDB worked fine for some time, then, after adding a few citations and a few pages more to this document, refdbxp started to segfault. I tried 0.9.4, just released, but got installation problems and a "could not read from refdbd" message each time I tried anything. However, this does not mean that the following is untested or that RefDB does not work - during the short time I got it to work, it worked fine, as did all the scripts and stylesheets I present here.  It also does not mean that refdbxp will segfault on your system - as always, YMMV.
</para>
</important>
<para>RefDB <indexterm><primary>RefDB</primary></indexterm>is a reference database <indexterm><primary>database</primary></indexterm>and bibliography <indexterm><primary>bibliography</primary></indexterm>tool for SGML,<indexterm><primary>SGML</primary></indexterm> XML, and LaTeX/BibTeX documents. It allows users to share databases over a network. It is lightweight <indexterm><primary>lightweight</primary></indexterm>and portable to basically all platforms <indexterm><primary>platforms</primary></indexterm>with a decent C compiler. And it's released under the <acronym>GNU</acronym> <indexterm><primary>GNU</primary></indexterm>General Public License <indexterm><primary>License</primary></indexterm>
<citation role="REFDB"><xref linkend="IDGNU0S"></citation>
.</para><para>RefDB <indexterm><primary>RefDB</primary></indexterm>is currently known to build and run out of the tarball <indexterm><primary>tarball</primary></indexterm>on at least these platforms:<indexterm><primary>platforms</primary></indexterm></para><itemizedlist><listitem><para>Linux</para></listitem><listitem><para>FreeBSD</para></listitem><listitem><para>NetBSD</para></listitem><listitem><para>Solaris <indexterm><primary>Solaris</primary></indexterm>(using gcc)</para></listitem><listitem><para>OSX/Darwin</para></listitem><listitem><para>Windows+Cygwin</para></listitem></itemizedlist><para>RefDB <indexterm><primary>RefDB</primary></indexterm>appears to be the only available tool to create HTML,<indexterm><primary>HTML</primary></indexterm> PostScript,<indexterm><primary>PostScript</primary></indexterm> PDF,<indexterm><primary>PDF</primary></indexterm> DVI,<indexterm><primary>DVI</primary></indexterm> MIF, or RTF <indexterm><primary>RTF</primary></indexterm>output from DocBook <indexterm><primary>DocBook</primary></indexterm>or TEI <indexterm><primary>TEI</primary></indexterm>sources <indexterm><primary>sources</primary></indexterm>with fully formatted citations <indexterm><primary>citations</primary></indexterm>and bibliographies <indexterm><primary>bibliographies</primary></indexterm>according to publisher's specifications. If you want to include bibliographies <indexterm><primary>bibliographies</primary></indexterm>in LyX <indexterm><primary>LyX</primary></indexterm>, RefDB <indexterm><primary>RefDB</primary></indexterm>is the way to go. The standard way, using BibTeX,<indexterm><primary>BibTeX</primary></indexterm> will NOT work in our SGML <indexterm><primary>SGML</primary></indexterm>context.</para><para>To install RefDB,<indexterm><primary>RefDB</primary></indexterm> it is highly recommended to get the newest version currently available. Due to various bugs,<indexterm><primary>bugs</primary></indexterm> versions older than 0.9.4-pre5 <indexterm><primary>0.9.4-pre5</primary></indexterm>will not work. By the time you read this, version 0.9.4 should be out and you should use that one - here I will describe the installation procedure <indexterm><primary>procedure</primary></indexterm>for the 0.9.4-pre5<indexterm><primary>0.9.4-pre5</primary></indexterm> version:</para><para>Download RefDB <indexterm><primary>RefDB</primary></indexterm>from the <ulink url="http://refdb.sourceforge.net/download.html">RefDB downloads page</ulink>, along with the Perlmod <indexterm><primary>Perlmod</primary></indexterm>package, currently RefDB-perlmod-0.3.tar.gz <indexterm><primary>RefDB-perlmod-0.3.tar.gz</primary></indexterm>(you can skip the latter if you don't require the MARC and Pubmed <indexterm><primary>Pubmed</primary></indexterm>import filters). First, install any <application>Perl</application> modules you need, such as RefDB-perlmod,<indexterm><primary>RefDB-perlmod</primary></indexterm> MARC::Record <indexterm><primary>MARC::Record</primary></indexterm>and MARC::Charset:<indexterm><primary>MARC::Charset</primary></indexterm></para><para>For RefDB-perlmod:<indexterm><primary>RefDB-perlmod:</primary></indexterm><indexterm><primary>RefDB-perlmod</primary></indexterm></para><screen><![CDATA[tar -xzvf RefDB-perlmod-0.2.tar.gz
]]><![CDATA[cd RefDB-perlmod-0.2/
]]><![CDATA[perl Makefile.PL
]]></screen><para>You get an output like:</para><screen><![CDATA[Checking if your kit is complete...
]]><![CDATA[Looks good
]]><![CDATA[Writing Makefile for RefDB::perlmod
]]></screen><para>After that, install perlmod with</para><screen><![CDATA[make install
]]></screen><para>For the other two modules, MARC::Record <indexterm><primary>MARC::Record</primary></indexterm>and MARC::Charset,<indexterm><primary>MARC::Charset</primary></indexterm> the installation can be done in the usual manner for CPAN <indexterm><primary>CPAN</primary></indexterm>modules:</para><screen><![CDATA[perl -MCPAN -eshell
]]><![CDATA[install MARC::Record
]]><![CDATA[install MARC::Charset
]]></screen><para>I could not install MARC::Charset <indexterm><primary>MARC::Charset</primary></indexterm>because it needs <application>Perl</application> 5.8.0 - however, this does not interfere with my method here, so you can safely skip it.</para><para>After the <application>Perl</application> modules, you must install the libdbi <indexterm><primary>libdbi</primary></indexterm>package: Go to the <ulink url="http://libdbi.sourceforge.net">libdbi homepage</ulink> and download the latest libdbi <indexterm><primary>libdbi</primary></indexterm>version libdbi-0.7.2.tar.gz.<indexterm><primary>libdbi-0.7.2.tar.gz.</primary></indexterm> Then go to the <ulink url="http://libdbi-drivers.sourceforge.net">libdbi-drivers homepage</ulink> and download the latest libdbi-drivers <indexterm><primary>libdbi-drivers</primary></indexterm>package libdbi-drivers-0.7.1.tar.gz.<indexterm><primary>libdbi-drivers-0.7.1.tar.gz</primary></indexterm> Then, uninstall <indexterm><primary>uninstall</primary></indexterm>any previous libdbi <indexterm><primary>libdbi</primary></indexterm>or RefDB <indexterm><primary>RefDB</primary></indexterm>package with </para><screen><![CDATA[make uninstall
]]></screen><para>from their source directory and you are ready for the installation of libdbi:<indexterm><primary>libdbi</primary></indexterm></para><screen><![CDATA[cd /usr/src/libdbi-0.7.2
]]><![CDATA[./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --infodir=/usr/share/info 
]]><![CDATA[--mandir=/usr/share/man --with-gnu-ld
]]><![CDATA[make
]]><![CDATA[make install
]]></screen><para>Adapt the configure options to your situation, those above are the ones I use in my old <productname>SuSE</productname> system. The installation of libdbi-drivers <indexterm><primary>libdbi-drivers</primary></indexterm>is accomplished similarly:</para><screen><![CDATA[cd /usr/src/libdbi-drivers-0.7.1
]]><![CDATA[./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --infodir=/usr/share/info 
]]><![CDATA[--mandir=/usr/share/man --with-gnu-ld --with-mysql --with-pgsql
]]><![CDATA[make
]]><![CDATA[make install
]]><![CDATA[make check
]]></screen><para>Note the &ldquo;--with-mysql&rdquo; and &ldquo;--with-pgsql&rdquo; options in the configure command above: for every libdbi <indexterm><primary>libdbi</primary></indexterm>database driver you plan to use, you have to insert the aproppriate &ldquo;--with-&rdquo; option. Type &ldquo;./configure --help&rdquo; to see all options. However, it makes no sense to say you want libdbi-drivers <indexterm><primary>libdbi-drivers</primary></indexterm>to be compiled with the pgsql <indexterm><primary>pgsql</primary></indexterm>driver, for example, if you don't have PostgreSQL <indexterm><primary>PostgreSQL</primary></indexterm>installed and running. </para><para>In the &quot;make check&quot;, you must give the database <indexterm><primary>database</primary></indexterm><emphasis>administrator's</emphasis> name and password <indexterm><primary>password</primary></indexterm>(not that of a user, as in the 0.6.x version). Just accept the other values offered:</para><screen><![CDATA[database hostname? [(blank for local socket if possible)]
]]><![CDATA[database name? [libdbitest]
]]></screen><para>The output of &ldquo;make check&rdquo; starts with:</para><screen><![CDATA[Plugin information:
]]><![CDATA[-------------------
]]><![CDATA[        Name:       mysql
]]><![CDATA[        Filename:   /usr/lib/dbd/libmysql.so
]]><![CDATA[        Desc:       MySQL database support (using libmysqlclient)
]]><![CDATA[        Maintainer: Mark M. Tobenkin <mark@brentwoodradio.com>
]]><![CDATA[        URL:        http://libdbi-drivers.sourceforge.net
]]><![CDATA[        Version:    dbd_mysql v0.7.1
]]><![CDATA[        Compiled:   Jan 30 2004
]]><![CDATA[Successfully connected!
]]></screen><para>and continues with the outcome of various tests (create a database,<indexterm><primary>database</primary></indexterm> select a database,<indexterm><primary>database</primary></indexterm> list tables etc.). After all tests are completed successfully, you will (hopefully) see</para><screen><![CDATA[SUCCESS! All done, disconnecting and shutting down libdbi. Have a nice day.
]]><![CDATA[PASS: test_dbi
]]><![CDATA[==================
]]><![CDATA[All 1 tests passed
]]><![CDATA[==================
]]></screen><para>Finally, you are ready for the installation of RefDB <indexterm><primary>RefDB</primary></indexterm>(instructions pertain to version 0.9.4-pre5:<indexterm><primary>0.9.4-pre5</primary></indexterm></para><screen><![CDATA[cd /usr/src/refdb-0.9.4-pre5
]]><![CDATA[./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --infodir=/usr/share/info
]]><![CDATA[--mandir=/usr/share/man --with-sgml-declaration=/usr/share/sgml/docbook_4/docbook.dcl
]]><![CDATA[--with-xml-declaration=/usr/share/sgml/openjade/xml.dcl
]]><![CDATA[--with-docbook-xsl=/usr/share/sgml/docbook/docbook-xsl-stylesheets
]]><![CDATA[--with-refdb-url=http://midas/refdb --with-libdbi-lib=/usr/lib
]]><![CDATA[make
]]><![CDATA[make install
]]></screen><para>You must adapt the options of the configure command to your situation. Read the excellent <ulink url="http://refdb.sourceforge.net/doc.html">RefDB documentation</ulink> for more details.</para><para>This completes the RefDB <indexterm><primary>RefDB</primary></indexterm>installation - but you are not done yet! You must create the refdb <indexterm><primary>refdb</primary></indexterm>database and grant <indexterm><primary>grant</primary></indexterm>yourself all privileges on it. In MySQL,<indexterm><primary>MySQL</primary></indexterm> on the mysql <indexterm><primary>mysql</primary></indexterm>promt, you type:</para><screen><![CDATA[CREATE DATABASE refdb;
]]><![CDATA[grant all privileges on refdb1.* to chris@localhost identified by 'password';
]]></screen><para>On the shell prompt, type:</para><screen><![CDATA[mysql -u root -p refdb < /usr/share/refdb/sql/refdb.dump
]]></screen><para>to populate the refdb <indexterm><primary>refdb</primary></indexterm>database. Note that the refdb <indexterm><primary>refdb</primary></indexterm>database is NOT the database <indexterm><primary>database</primary></indexterm>you will use for your bibliography <indexterm><primary>bibliography</primary></indexterm>entries, but a central repository <indexterm><primary>repository</primary></indexterm>of information necessary for RefDB's internal functions.</para><caution>
<title>The refdb name has changed between versions!</title>
<para>
For version 0.9.4-pre5, the database is called refdb, NOT refdb1! That "central repository" of RefDB used to be called "refdb", then it became "refdb1" and in 0.9.4-pre5 "refdb" again. I didn't know this and I kept on getting errors saying
</para>
<screen>
<![CDATA[failed to connect to database server]]>
</screen>
<para>
without telling me why! After I changed
</para>
<screen>
<![CDATA[ if (dbi_conn_connect(conn) < 0) { /* -1 and -2 indicate errors */]]>
<![CDATA[ LOG_PRINT(LOG_WARNING, "failed to connect to database server");]]>
<![CDATA[ dbi_conn_close(conn);]]>
<![CDATA[ return NULL;]]>
<![CDATA[ }]]>
</screen>
<para>
in src/refdba.c to
</para>
<screen>
<![CDATA[ const char *errmsg;]]>
<![CDATA[ if (dbi_conn_connect(conn) < 0) { /* -1 and -2 indicate errors */]]>
<![CDATA[ dbi_conn_error(conn, &errmsg);]]>
<![CDATA[ printf("\nUnable to connect! Error message: %s\n", errmsg);]]>
<![CDATA[ LOG_PRINT(LOG_WARNING, "failed to connect to database server");]]>
<![CDATA[ dbi_conn_close(conn);]]>
<![CDATA[ return NULL;]]>
<![CDATA[ }]]>
</screen>
<para>
I was able to see that the reason was that it was trying to connect to refdba, and NOT to refdba1: 
</para>
<screen>
<![CDATA[Unable to connect! Error message: 1044: Access denied for user: 'chris@localhost' to database 'refdb']]>
<![CDATA[failed to connect to database server]]>
<![CDATA[command processing done, finish dialog now]]>
<![CDATA[child finished client on fd 5]]>
<![CDATA[child exited with code 0]]>
<![CDATA[server waiting n_max_fd=4]]>
</screen>
</caution>
<para>The next step is to create the global configuration files. There are half a dozen of them, one for each RefDB <indexterm><primary>RefDB</primary></indexterm>tool. They are very well commented, so you will not encounter any problems in setting up the options there.</para><para>Further, you will have to import some citation <indexterm><primary>citation</primary></indexterm>styles. There are only two readily available: J.Biol.Chem.xml <indexterm><primary>J.Biol.Chem.xml</primary></indexterm>and Eur.J.Pharmacol.<indexterm><primary>Eur.J.Pharmacol</primary></indexterm>xml,<indexterm><primary>Eur.J.Pharmacol.xml</primary></indexterm> both in the /usr/src/refdb-0.9.4pre5/styles directory. To import them, start the RefDB <indexterm><primary>RefDB</primary></indexterm>administration tool refdba <indexterm><primary>refdba</primary></indexterm>and type:</para><screen><![CDATA[addstyle /usr/src/refdb-0.9.4-pre5/styles/J.Biol.Chem.xml
]]><![CDATA[addstyle /usr/src/refdb-0.9.4-pre5/styles/Eur.J.Pharmacol.xml
]]></screen><para>in the refdba <indexterm><primary>refdba</primary></indexterm>prompt. Then, you can check which styles you have using the liststyle <indexterm><primary>liststyle</primary></indexterm>command in refdba:<indexterm><primary>refdba</primary></indexterm></para><screen><![CDATA[refdba: liststyle .*
]]></screen><para>which will produce:</para><screen><![CDATA[J.Biol.Chem.
]]><![CDATA[Eur.J.Pharmacol.
]]></screen><para>You must also create at least one database <indexterm><primary>database</primary></indexterm>that will hold your bibliographic<indexterm><primary>bibliographic</primary></indexterm> entries. For example, to create the ck_refdb <indexterm><primary>ck_refdb</primary></indexterm>database, start refdba <indexterm><primary>refdba</primary></indexterm>and type on the refdba <indexterm><primary>refdba</primary></indexterm>prompt:</para><screen><![CDATA[createdb ck_refdb
]]><![CDATA[adduser -d ck_refdb chris -N newpassword
]]></screen><para>If you want to enter the bibliographic <indexterm><primary>bibliographic</primary></indexterm>entries via a web interface <indexterm><primary>interface</primary></indexterm>and not from the command line, you have to configure Apache <indexterm><primary>Apache</primary></indexterm>by inserting the following in its configuration file (adapt it to your situation accordingly):</para><screen><![CDATA[Alias /refdb/ /usr/share/refdb/www/
]]><![CDATA[<Directory "/refdb">
]]><![CDATA[Options Indexes MultiViews
]]><![CDATA[AllowOverride None
]]><![CDATA[Order allow,deny
]]><![CDATA[# Allow from all
]]><![CDATA[Allow from 192.168.0.0/24
]]><![CDATA[</Directory>
]]></screen><para>then copy some programs in the cgi-bin <indexterm><primary>cgi-bin</primary></indexterm>directory:</para><screen><![CDATA[cd /usr/bin/
]]><![CDATA[cp refdbc bib2ris nmed2ris /usr/local/httpd/cgi-bin/
]]></screen><para>and restart Apache.<indexterm><primary>Apache</primary></indexterm></para><para>To test RefDB,<indexterm><primary>RefDB</primary></indexterm> start the refdbd <indexterm><primary>refdbd</primary></indexterm>daemon with:</para><screen><![CDATA[refdbd -s -e 0 -l 7
]]></screen><para>You should see something like:</para><screen><![CDATA[refdbd -s -e 0 -l 7
]]><![CDATA[dbi_driver_dir went to:
]]><![CDATA[libdbi: Failed to load driver: /usr/lib/dbd/libpgsql.so
]]><![CDATA[dbi is up using default driver dir
]]><![CDATA[Available libdbi database drivers:
]]><![CDATA[mysql
]]><![CDATA[application server started
]]><![CDATA[use /tmp/refdbd_fifo25577 as fifo
]]><![CDATA[server waiting n_max_fd=4
]]></screen><para>If you don't have a database <indexterm><primary>database</primary></indexterm>server correctly configured, although you asked for support of it in the libdbi-drivers <indexterm><primary>libdbi-drivers</primary></indexterm>configure command on compilation<indexterm><primary>compilation</primary></indexterm> time, you will get an error like the above for PostgreSQL <indexterm><primary>PostgreSQL</primary></indexterm>(libpgsql.so). In refdba,<indexterm><primary>refdba</primary></indexterm> type</para><screen><![CDATA[viewstat
]]></screen><para>If the server outputs look like the following:</para><screen><![CDATA[You are served by: refdb 0.9.4-pre5
]]><![CDATA[Client IP: 127.0.0.1
]]><![CDATA[Connected via mysql driver (dbd_mysql v0.7.1)
]]><![CDATA[to: 3.23.44-log
]]><![CDATA[serverip: localhost
]]><![CDATA[timeout: 60
]]><![CDATA[dbs_port: 3306
]]><![CDATA[logfile: /var/log/refdbd.log
]]><![CDATA[logdest: 0
]]><![CDATA[loglevel: 7
]]><![CDATA[remoteadmin: off
]]><![CDATA[pidfile: /var/run/refdbd.pid
]]></screen><para>then you know that everything is working fine. See the <ulink url="http://refdb.sourceforge.net/doc.html">RefDB documentation</ulink> for more details.</para></sect1>
</chapter>
<chapter id="required-preliminary-steps"><title>Required preliminary steps</title><para>Just installing the required software (see <xref linkend="required-software">) will not do the trick. There are quite a few details that will need your attention and will have to be configured correctly. In this section I will discuss all those preliminary steps. Don't worry, you will need to do them only once. Then, you may forget them forever.</para><sect1 id="reconfigure-LyX"><title>Reconfigure LyX </title><para>Before you write anything in LyX,<indexterm><primary>LyX</primary></indexterm> and after having installed all the required packages <indexterm><primary>packages</primary></indexterm>(see <xref linkend="required-software">), you should reconfigure <indexterm><primary>reconfigure</primary></indexterm>LyX to let it take into account all this software. Just do Edit--&gt;Reconfigure. Check the output of this command (if you did not put LyX <indexterm><primary>LyX</primary></indexterm>in the background,<indexterm><primary>background</primary></indexterm> you should see it in the x terminal you started LyX <indexterm><primary>LyX</primary></indexterm>in). You should see among others:</para><screen><![CDATA[+checking for docbook class docbook-algo... yes 
]]><![CDATA[+checking for docbook class docbook-book... yes 
]]><![CDATA[+checking for docbook class docbook-chapter... yes 
]]><![CDATA[+checking for docbook class docbook... yes 
]]><![CDATA[+checking for docbook class docbook-section... yes 
]]></screen><para>If you don't, you miss the docbook DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets (see <xref linkend="DocBook">) or something else went wrong. Don't continue before you fix this.</para></sect1>
<sect1 id="DSSSL-stylesheets"><title>Adapt the DocBook DSSSL stylesheets </title><para>There are a lot of changes that must be done in the DocBook <indexterm><primary>DocBook</primary></indexterm>DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets. The best way to incorporate them is to keep copies of the following files in your working directory:</para><itemizedlist><listitem><para><ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink>, <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink>, <ulink url="lyxtox-print-ps.dsl">lyxtox-print-ps.dsl</ulink>, <ulink url="lyxtox-print-rtf.dsl">lyxtox-print-rtf.dsl</ulink>, <ulink url="lyxtox-print-txt.dsl">lyxtox-print-txt.dsl</ulink> and <ulink url="lyxtox-print-howto.dsl">lyxtox-print-howto.dsl</ulink>. These control the style of the print formats (i.e. all formats except HTML). They contain some code from the original print.dsl <indexterm><primary>print.dsl</primary></indexterm>file of the sgmltools-lite<indexterm><primary>sgmltools-lite</primary></indexterm> package (located in /usr/share/sgml/stylesheets/sgmltools/print.dsl, see <xref linkend="sgmltools">), but also code from the RefDB <indexterm><primary>RefDB</primary></indexterm>(<xref linkend="Refdb">), DBTeXMath <indexterm><primary>DBTeXMath</primary></indexterm>(<xref linkend="DBTeXMath">) and the <productname>Mandrake</productname> <indexterm><primary>Mandrake</primary></indexterm>print-manual.dsl.</para></listitem><listitem><para><ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink>: this file will be used as the DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet to control the HTML <indexterm><primary>HTML</primary></indexterm>output in many HTML <indexterm><primary>HTML</primary></indexterm>files (one HTML <indexterm><primary>HTML</primary></indexterm>file per section).</para></listitem><listitem><para><ulink url="lyxtox-onehtml.dsl">lyxtox-onehtml.dsl</ulink>: this file will be used as the DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet to control the HTML <indexterm><primary>HTML</primary></indexterm>output in one big HTML <indexterm><primary>HTML</primary></indexterm>file (Jade option: nochunks).</para></listitem></itemizedlist><para>See <xref linkend="explain-DSSSL-stylesheets"> for an explanation of the changes that have been incorporated in the above files. Make sure that their location is correctly set in <ulink url="lyxtox">lyxtox</ulink>:</para><screen><![CDATA[  HTML_CHUNKS_DSL="lyxtox-html.dsl"
]]><![CDATA[  HTML_NOCHUNKS_DSL="lyxtox-onehtml.dsl"
]]><![CDATA[  PRINT_PDF_DSL="lyxtox-print-pdf.dsl"
]]><![CDATA[  PRINT_PS_DSL="lyxtox-print-ps.dsl"
]]><![CDATA[  PRINT_RTF_DSL="lyxtox-print-rtf.dsl"
]]><![CDATA[  PRINT_TXT_DSL="lyxtox-print-txt.dsl"
]]></screen><para>Also, you must insert &quot;PDF&quot;<indexterm><primary>PDF</primary></indexterm> in the notation.class <indexterm><primary>notation.class</primary></indexterm>of the /usr/share/sgml/docbook_4/dbnotn.mod file:</para><screen><![CDATA[<!ENTITY % notation.class "BMP| CGM-CHAR | CGM-BINARY | CGM-CLEAR | DITROFF | DVI | EPS | EQN | FAX | GIF | GIF87a | GIF89a | JPG | JPEG | IGES | PCX | PDF | PIC | PNG | PS | SGML | TBL | TEX | TIFF | WMF | WPG | linespecific %local.notation.class;"> 
]]></screen><para>If you still use LyX <indexterm><primary>LyX</primary></indexterm>v.1.1.x, you should change /usr/share/sgml/docbook_3/dbnotn.mod to include &ldquo;PDF&rdquo; in the list of accepted file extensions:<indexterm><primary>extensions</primary></indexterm></para><screen><![CDATA[<!ENTITY % notation.class                 "BMP| CGM-CHAR | CGM-BINARY | CGM-CLEAR | DITROFF | DVI                 | EPS | EQN | FAX | GIF | GIF87a | GIF89a                  | JPG | JPEG | IGES | PCX                 | PIC | PS | SGML | TBL | TEX | TIFF | WMF | WPG | PDF | PNG                 | linespecific                 %local.notation.class;"> 
]]></screen><para>If you omit this change, you will get a 'value&nbsp;of&nbsp;attribute&nbsp;&quot;FORMAT&quot;&nbsp;cannot&nbsp;be&nbsp;&quot;PDF&quot;' error when trying to produce a PDF <indexterm><primary>PDF</primary></indexterm>(due to a 'format=&rdquo;PDF&rdquo;' attribute <indexterm><primary>attribute</primary></indexterm>in the code for images, see <xref linkend="explain-figures">). This error is also discussed in <xref linkend="errors-and-warnings">.</para><para>Open each one of the DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets that you copied in your working directory and check if the paths <indexterm><primary>paths</primary></indexterm>used there are correct. The affected files are:</para><itemizedlist><listitem><para><ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink></para></listitem><listitem><para><ulink url="lyxtox-onehtml.dsl">lyxtox-onehtml.dsl</ulink></para></listitem><listitem><para><ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink></para></listitem></itemizedlist><para>Check whether the paths <indexterm><primary>paths</primary></indexterm>in the ENTITY declarations are correct for your system. For example, in <ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink> you must check whether the following ENTITY declarations are correct:</para><screen><![CDATA[<!ENTITY refdblib SYSTEM "/usr/share/refdb/dsssl/lib/refdblib.dsl">
]]><![CDATA[<!ENTITY refdbvar SYSTEM "/usr/share/refdb/dsssl/lib/refdbvar.dsl">
]]></screen><para>Practically, this amounts to checking the right path <indexterm><primary>path</primary></indexterm>for refdblib.dsl and refdbvar.dsl in your system. Repeat this check for the other two files.</para><note>
<title>
Stylesheet location and RefDB
</title>
<para>
Currently, if you use RefDB, the above stylesheets have to be in the current directory (i.e. where also <ulink url="lyxtox">lyxtox</ulink> is in). This is because in this case the <ulink url="refdb-html.dsl">refdb-html.dsl</ulink> and <ulink url="refdb-print.dsl">refdb-print.dsl</ulink> will be used. They are automatically generated from the RefDB stylesheet  (e.g. J.Biol.Chem.dsl) which, in turn, is also automatically generated by RefDB (see <xref linkend="explain-RefDB"> for all the details). <ulink url="refdb-html.dsl">refdb-html.dsl</ulink> and <ulink url="refdb-print.dsl">refdb-print.dsl</ulink> will point to the above lyxtox-*.dsl stylesheets for further processing, but they don't do it through a catalog (at the moment). Thus the lyxtox-*.dsl files have to be in the same directory, unless you change the generating <ulink url="awkscr&amp;lowbar;refdb&amp;lowbar;html">awkscr_refdb_html</ulink> and <ulink url="awkscr&amp;lowbar;refdb&amp;lowbar;print">awkscr_refdb_print</ulink> scripts.
</para>
</note>
</sect1>
<sect1 id="pdftex_cfg"><title>Adapt pdftex.cfg </title><para>pdftex <indexterm><primary>pdftex</primary></indexterm>(part of the te_pdf package which you hopefully installed in <xref linkend="TeX-LaTeX">) uses a file <ulink url="pdftex.cfg">pdftex.cfg</ulink> (located in /var/lib/texmf/pdftex/config/pdftex.cfg on my system), which contains amongst other things the names of the so-called &ldquo;map files&rdquo;. There is currently only one of these files there, <ulink url="pdftex.map">pdftex.map</ulink> (located in /var/lib/texmf/dvips/config/pdftex.map on my system). It contains the mapping between the short names (like hlsu8r) and the long PostScript® <indexterm><primary>PostScript®</primary></indexterm>names (like LucidaSans-Bold) of the fonts.<indexterm><primary>fonts</primary></indexterm> It must contain the mappings for the Computer Modern fonts <indexterm><primary>fonts</primary></indexterm>(lines like &ldquo; cmr9 <indexterm><primary>cmr9</primary></indexterm>CMR9 &lt;cmr9.pfb&rdquo;), in order to be able to use them in PDF.<indexterm><primary>PDF</primary></indexterm> Normally, this is already done by your distribution <indexterm><primary>distribution</primary></indexterm>and you don't need to change anything. </para><para>On other systems, the mapping for the Computer Modern fonts <indexterm><primary>fonts</primary></indexterm>may be located in a different file (perhaps under the name cm.map). Check your TeX/LaTeX documentation.</para></sect1>
<sect1 id="jadetex_cfg"><title>Adapt jadetex.cfg</title><para><ulink url="./jadetex.cfg">jadetex.cfg</ulink> is the configuration file for pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>(see <xref linkend="openjade-pdftex-jadetex">). You should copy it in your working directory. You will definitely want to adapt <ulink url="./jadetex.cfg">jadetex.cfg</ulink> to reflect the right author, keywords etc. for the PDF <indexterm><primary>PDF</primary></indexterm>document (scroll to the end of jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg to find the relevant code):</para><screen>
baseurl={http://www.karakas-online.de/mySGML/}, <co id="baseurl">
pdftitle={Document processing with LyX and SGML}, <co id="pdftitle">
pdfsubject={Linux,document formatting}, <co id="pdfsubject">
pdfauthor={Copyright \textcopyright 2003, Chris Karakas}, <co id="pdfauthor">
pdfkeywords={Linux SGML LyX DSSSL DocBook} <co id="pdfkeywords">
</screen>
<calloutlist>
    <callout arearefs="baseurl">
       <para>
      The baseurl will be added in front of any relative WWW link that you have in your PDF document.
      </para>
    </callout>
<callout arearefs="pdftitle">
       <para>
      The pdftitle  will appear as the title of your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General.
      </para>
    </callout>
<callout arearefs="pdfsubject">
       <para>
      The   pdfsubject will appear as the subject  of your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General.
      </para>
    </callout>
<callout arearefs="pdfauthor">
       <para>
      The   pdfauthor  will appear as the author  of your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General. You may add copyright information as shown here.
      </para>
    </callout>
<callout arearefs="pdfkeywords">
       <para>
      The   pdfkeywords will appear as a list of keywords for  your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General. Keywords are separated by blanks.
     </para>
    </callout>
</calloutlist>
<para>You can see the above information when you choose File--&gt;Document Info--&gt;General, see <xref linkend="fig-general-document-info">.</para><para>
<figure id="fig-general-document-info" float="1">
   <title>
   General document info.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1001;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1001;.pdf" format="PDF">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1001;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1001;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>General document info.</phrase>
      </textobject>
      <caption>
         <para>General document info.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>These are the minimum required changes for jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg. You may change a lot of other settings for the PDF <indexterm><primary>PDF</primary></indexterm>output. The jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg file itself contains a lot of code which you may use as a point of departure for your explorations (don't forget to backup the original before you change it!). Some of the more advanced settings are discussed in <xref linkend="explain-optimal-PDF">. But if you are not interested in the gory details, you are already done with the above.</para></sect1>
<sect1 id="catalog-paths"><title>Check paths of catalog files </title><para>Check the <ulink url="lyxtox">lyxtox</ulink> script and adapt the catalog <indexterm><primary>catalog</primary></indexterm>files paths <indexterm><primary>paths</primary></indexterm>(see <xref linkend="explain-catalogs">) to your situation. You may already have a master catalog <indexterm><primary>catalog</primary></indexterm>installed on your system by your distribution.<indexterm><primary>distribution</primary></indexterm> In my <productname>SuSE</productname> system, I have one in /etc/sgml/catalog. Open the file and pick the catalogs you need, adding them to the SGML_CATALOG_FILES variable as follows:</para><screen><![CDATA[# openjade needs this! It is just the content of
]]><![CDATA[# the /etc/sgml/catalog file. Please modify accordingly.
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.iso_ent"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.docbook-dsssl-stylesheets"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.mathml-2.0"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.svg-1.1"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.docbook_4"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/openjade/catalog"
]]></screen><para>Not all catalogs from /etc/sgml/catalog should be added to SGML_CATALOG_FILES,<indexterm><primary>SGML_CATALOG_FILES</primary></indexterm> although in theory, you should be able to just add the master catalog <indexterm><primary>catalog</primary></indexterm>and let it do the rest (FIXME: I had problems with that, need to investigate why). Also, add the RefDB <indexterm><primary>RefDB</primary></indexterm>catalog only if you have RefDB <indexterm><primary>RefDB</primary></indexterm>installed:</para><screen><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/refdb/refdb.cat"
]]><![CDATA[
]]><![CDATA[
]]></screen></sect1>
<sect1 id="preample"><title>Adapt the preample </title><para>Put the following lines in the preample <indexterm><primary>preample</primary></indexterm>(menue Layout--&gt;Preample) of your LyX <indexterm><primary>LyX</primary></indexterm>document:</para><screen><![CDATA[<!entity index SYSTEM "index.sgml">
]]><![CDATA[<!entity bibliography SYSTEM "bibliography.sgml"> 
]]><![CDATA[<!entity appendix SYSTEM "appendix.sgml">
]]><![CDATA[<!ENTITY % output.print.png "IGNORE"> 
]]><![CDATA[<!ENTITY % output.print.pdf "IGNORE"> 
]]><![CDATA[<!ENTITY % output.print.eps "IGNORE">
]]><![CDATA[<!ENTITY % output.print.bmp "IGNORE">
]]></screen><para>If you don't want to do this for each and every document <indexterm><primary>document</primary></indexterm>you write in LyX,<indexterm><primary>LyX</primary></indexterm> you can put the above lines at the very start of the template file docbook_article.lyx (located in /usr/share/lyx/templates in my system) as follows:</para><screen><![CDATA[#LyX 1.2 created this file. For more info see http://www.lyx.org/
]]><![CDATA[\lyxformat 220
]]><![CDATA[\textclass docbook
]]><![CDATA[\begin_preamble
]]><![CDATA[<!entity index SYSTEM "index.sgml">
]]><![CDATA[<!entity bibliography SYSTEM "bibliography.sgml"> 
]]><![CDATA[<!entity appendix SYSTEM "appendix.sgml">
]]><![CDATA[<!ENTITY % output.print.png "IGNORE">
]]><![CDATA[<!ENTITY % output.print.pdf "IGNORE">
]]><![CDATA[<!ENTITY % output.print.eps "IGNORE">
]]><![CDATA[<!ENTITY % output.print.bmp "IGNORE">
]]><![CDATA[\end_preamble
]]><![CDATA[\language english
]]><![CDATA[\inputencoding latin1
]]><![CDATA[\fontscheme default
]]><![CDATA[\graphics default
]]><![CDATA[...
]]></screen><important>
<title>IMPORTANT: </title>
<para>
If you use RefDB (<xref linkend="Refdb">), you have to change the bibliography entity to basename.bib.sgml, where basename is the name of your file, <emphasis>without</emphasis> the ending. Example: if your file is myTemplate.lyx and you use RefDB, then the bibliography entity should be declared as follows in the preample:
</para>
<screen>
<![CDATA[<!entity bibliography SYSTEM "myTemplate.bib.sgml">]]>
</screen>
</important>
<para>See <xref linkend="explain-appendix">, <xref linkend="explain-bibliography">, <xref linkend="explain-index"> and <xref linkend="explain-figures"> for an explanation of this magic <indexterm><primary>magic</primary></indexterm>regarding the Appendix, Bibliography, Index and the figures <indexterm><primary>figures</primary></indexterm>respectively.</para></sect1>
<sect1 id="admonitions"><title>Admonitions </title><para>For graphical admonitions <indexterm><primary>admonitions</primary></indexterm>(see <xref linkend="conventions">), you will need to copy the admonitions <indexterm><primary>admonitions</primary></indexterm>graphics. These are expected in /usr/share/sgml/docbkdsl/images by pdfjadetex,<indexterm><primary>pdfjadetex</primary></indexterm> as the following error shows:</para><screen><![CDATA[Error: pdfjadetex (file /usr/share/sgml/docbkdsl/images/important.pdf): cannot open image file
]]></screen><para>This is because the <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink> file (see <xref linkend="DSSSL-stylesheets">) contains the lines</para><screen><![CDATA[    (define %admon-graphics-path%
]]><![CDATA[    "/usr/share/sgml/docbkdsl/images/")
]]></screen><para>The images themselves are installed in /usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/images by the package docbook-dsssl-stylesheets-1.72-34 <indexterm><primary>docbook-dsssl-stylesheets-1.72-34</primary></indexterm>on my <productname>SuSE</productname> 7.3 system. Instead of changing the location in <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink>, I have decided to copy them: </para><screen><![CDATA[cp /usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/images/* /usr/share/sgml/docbkdsl/images/
]]></screen><warning>
<title>Warning:</title> 
<para> 
DO NOT use a relative path, as in the commented line below! You will get errors of the form
<screen>
LaTeX Warning: File `./images/important.pdf' not found on input line 5223.
</screen>
although <emphasis>the files will be there</emphasis>. Most curiously, the images may nevertheless be included, but thumbpdf <emphasis>will</emphasis> fail!
</para> 
</warning>
<para>The above is valid only for the print formats (like PDF,<indexterm><primary>PDF</primary></indexterm> PS,<indexterm><primary>PS</primary></indexterm> RTF <indexterm><primary>RTF</primary></indexterm>etc.). For the HTML <indexterm><primary>HTML</primary></indexterm>output we use the <ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink> and <ulink url="lyxtox-onehtml.dsl">lyxtox-onehtml.dsl</ulink>, for many HTML <indexterm><primary>HTML</primary></indexterm>files and one HTML <indexterm><primary>HTML</primary></indexterm>file respectively. There, the directory of the admonition <indexterm><primary>admonition</primary></indexterm>graphics is specified with the following code:</para><screen><![CDATA[(define %admon-graphics-path%
]]><![CDATA[;; REFENTRY admon-graphics-path
]]><![CDATA[;; PURP Path to admonition graphics
]]><![CDATA[;; DESC
]]><![CDATA[;; Sets the path, probably relative to the directory where the HTML
]]><![CDATA[;; files are created, to the admonition graphics.
]]><![CDATA[;; /DESC
]]><![CDATA[;; AUTHOR N/A
]]><![CDATA[;; /REFENTRY
]]><![CDATA["./images/")
]]></screen><para>Create a directory with the same name as the . lyx <indexterm><primary>lyx</primary></indexterm>file in your working directory, but without the . lyx <indexterm><primary>lyx</primary></indexterm>ending:</para><screen><![CDATA[mkdir myTemplate
]]></screen><para>Change to that directory and extract the <ulink url="http://www.karakas-online.de/mySGML/admonitions.tar.gz">admonitions</ulink> archive:</para><screen><![CDATA[tar -xzvf admonitions.tar.gz
]]></screen><para>This will create a subdirectory <indexterm><primary>subdirectory</primary></indexterm>&ldquo;images&rdquo;, with all admonition <indexterm><primary>admonition</primary></indexterm>graphics in it, in all the formats needed. Alternatively, you could copy the admonition <indexterm><primary>admonition</primary></indexterm>images in the various formats into the images directory. The images contained are:</para><screen><![CDATA[images/caution.bmp
]]><![CDATA[images/caution.eps
]]><![CDATA[images/caution.pdf
]]><![CDATA[images/caution.png
]]><![CDATA[images/important.bmp
]]><![CDATA[images/important.eps
]]><![CDATA[images/important.pdf
]]><![CDATA[images/important.png
]]><![CDATA[images/tip.bmp
]]><![CDATA[images/tip.eps
]]><![CDATA[images/tip.pdf
]]><![CDATA[images/tip.png
]]><![CDATA[images/note.bmp
]]><![CDATA[images/note.eps
]]><![CDATA[images/note.pdf
]]><![CDATA[images/note.png
]]><![CDATA[images/warning.bmp
]]><![CDATA[images/warning.eps
]]><![CDATA[images/warning.pdf
]]><![CDATA[images/warning.png
]]></screen><para>If you have only the GIF <indexterm><primary>GIF</primary></indexterm>versions of the admonitions,<indexterm><primary>admonitions</primary></indexterm> you can use the <ulink url="adddscr">adddscr</ulink> script as follows:</para><screen><![CDATA[cd images
]]><![CDATA[adddscr gif
]]></screen><para>Instead of &ldquo;gif&rdquo;, you can use whatever version you happen to have (like &ldquo;png&rdquo;, &ldquo;bmp&rdquo; etc). The adddscr <indexterm><primary>adddscr</primary></indexterm>script will convert <indexterm><primary>convert</primary></indexterm>the format you designated into PNG <indexterm><primary>PNG</primary></indexterm>first, then use the <ulink url="addd">addd</ulink> script to add density <indexterm><primary>density</primary></indexterm>(see<xref linkend="add-density"> and <xref linkend="explain-figures">) and finally will create all the other formats with ImageMagik <indexterm><primary>ImageMagik</primary></indexterm>(see <xref linkend="dvips-Ghostscript-Imagemagik">).See <xref linkend="explain-figures"> for the background.<indexterm><primary>background</primary></indexterm></para></sect1>
<sect1 id="callouts"><title>Callouts </title><para>You can control various parameters regarding callouts <indexterm><primary>callouts</primary></indexterm>in the .dsl files (see <xref linkend="DSSSL-stylesheets"> and <xref linkend="explain-DSSSL-stylesheets">). You should especially check the path <indexterm><primary>path</primary></indexterm>to the callout images. In our case, it has to be &ldquo;./images/callouts&rdquo; , i.e.the images will be located in a subdirectory <indexterm><primary>subdirectory</primary></indexterm>of the images directory, which in turn will be located inside the directory of the HTML <indexterm><primary>HTML</primary></indexterm>files. </para><screen><![CDATA[(define %callout-graphics%
]]><![CDATA[  ;; If true, callouts are presented with graphics (e.g., reverse-video
]]><![CDATA[  ;; circled numbers instead of "(1)", "(2)", etc.).
]]><![CDATA[  ;; Default graphics are provided in the distribution.
]]><![CDATA[  #t)
]]><![CDATA[(define %callout-graphics-path%
]]><![CDATA[  ;; Sets the path, probably relative to the directory where the HTML
]]><![CDATA[  ;; files are created, to the callout graphics.
]]><![CDATA[  "./images/callouts/")
]]><![CDATA[(define %callout-graphics-extension%
]]><![CDATA[  ;; REFENTRY callout-graphics-extension
]]><![CDATA[  ;; PURP Extension for callout graphics
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; Sets the extension to use on callout graphics.
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[  ".png")
]]><![CDATA[(define %callout-graphics-number-limit%
]]><![CDATA[  ;; If '%callout-graphics%' is true, graphics are used to represent
]]><![CDATA[  ;; callout numbers. The value of '%callout-graphics-number-limit%' is
]]><![CDATA[  ;; the largest number for which a graphic exists. If the callout number
]]><![CDATA[  ;; exceeds this limit, the default presentation "(nnn)" will always
]]><![CDATA[  ;; be used.
]]><![CDATA[  10)
]]></screen><para>Change to the myTemplate <indexterm><primary>myTemplate</primary></indexterm>directory (we created it in <xref linkend="admonitions">) and extract the <ulink url="http://www.karakas-online.de/mySGML/callouts.tar.gz">callouts</ulink> archive:</para><screen><![CDATA[tar -xzvf callouts.tar.gz
]]></screen><para>This will create a subdirectory <indexterm><primary>subdirectory</primary></indexterm>&ldquo;images/callouts&rdquo;, with all callouts <indexterm><primary>callouts</primary></indexterm>graphics in it, in all the formats needed. Alternatively, you could copy the admonition <indexterm><primary>admonition</primary></indexterm>images in the various formats into the images/callouts directory. The images contained are:</para><screen><![CDATA[images/callouts/10.png
]]><![CDATA[images/callouts/1.png
]]><![CDATA[images/callouts/2.png
]]><![CDATA[images/callouts/3.png
]]><![CDATA[images/callouts/4.png
]]><![CDATA[images/callouts/5.png
]]><![CDATA[images/callouts/6.png
]]><![CDATA[images/callouts/7.png
]]><![CDATA[images/callouts/8.png
]]><![CDATA[images/callouts/9.png
]]><![CDATA[images/callouts/10.eps
]]><![CDATA[images/callouts/10.bmp
]]><![CDATA[images/callouts/10.pdf
]]><![CDATA[images/callouts/1.eps
]]><![CDATA[images/callouts/1.bmp
]]><![CDATA[images/callouts/1.pdf
]]><![CDATA[images/callouts/2.eps
]]><![CDATA[images/callouts/2.bmp
]]><![CDATA[images/callouts/2.pdf
]]><![CDATA[images/callouts/3.eps
]]><![CDATA[images/callouts/3.bmp
]]><![CDATA[images/callouts/3.pdf
]]><![CDATA[images/callouts/4.eps
]]><![CDATA[images/callouts/4.bmp
]]><![CDATA[images/callouts/4.pdf
]]><![CDATA[images/callouts/5.eps
]]><![CDATA[images/callouts/5.bmp
]]><![CDATA[images/callouts/5.pdf
]]><![CDATA[images/callouts/6.eps
]]><![CDATA[images/callouts/6.bmp
]]><![CDATA[images/callouts/6.pdf
]]><![CDATA[images/callouts/7.eps
]]><![CDATA[images/callouts/7.bmp
]]><![CDATA[images/callouts/7.pdf
]]><![CDATA[images/callouts/8.eps
]]><![CDATA[images/callouts/8.bmp
]]><![CDATA[images/callouts/8.pdf
]]><![CDATA[images/callouts/9.eps
]]><![CDATA[images/callouts/9.bmp
]]><![CDATA[images/callouts/9.pdf
]]></screen><para>If you have only the GIF <indexterm><primary>GIF</primary></indexterm>versions of the callouts,<indexterm><primary>callouts</primary></indexterm> you can use the <ulink url="adddscr">adddscr</ulink> script:</para><screen><![CDATA[cd images/callouts
]]><![CDATA[adddscr gif
]]></screen><para>Instead of &ldquo;gif&rdquo;, you can use whatever version you happen to have (like &ldquo;png&rdquo;, &ldquo;bmp&rdquo; etc). The adddscr <indexterm><primary>adddscr</primary></indexterm>script will convert <indexterm><primary>convert</primary></indexterm>the format you designated into PNG <indexterm><primary>PNG</primary></indexterm>first, then use the <ulink url="addd">addd</ulink> script to add density <indexterm><primary>density</primary></indexterm>(see <xref linkend="add-density"> and <xref linkend="explain-figures">) and finally will create all the other formats with ImageMagik <indexterm><primary>ImageMagik</primary></indexterm>(see <xref linkend="dvips-Ghostscript-Imagemagik">).</para></sect1>
<sect1 id="add-density"><title>Add density to images</title><para>Since you will be creating various output formats from the same SGML <indexterm><primary>SGML</primary></indexterm>source, you are going to need not only the png images, but also the pdf ones. Those need a special preparation in order to be embedded <indexterm><primary>embedded</primary></indexterm>in the PDF <indexterm><primary>PDF</primary></indexterm>document: we need to &ldquo;add density<indexterm><primary>density</primary></indexterm>&rdquo; to them. This is one of the many reasons that the tools <indexterm><primary>tools</primary></indexterm>described in this document<indexterm><primary>document</primary></indexterm> fail to incorporate images in PDF <indexterm><primary>PDF</primary></indexterm>when ran &ldquo;out-of-the-box&rdquo;.</para><para>The gory details behind this are described in <xref linkend="explain-figures">. Here, I will describe the most straightforward way to get working images for your PDF <indexterm><primary>PDF</primary></indexterm>documents. For this purpose I have written a small utility,<indexterm><primary>utility</primary></indexterm> which I call <ulink url="./addd">addd</ulink> (for add density). Download it, make it executable and put it somewhere like /usr/local/bin. It calls two programs which you should also have installed on your system: convert <indexterm><primary>convert</primary></indexterm>(package ImageMagick) and <ulink url="http://search.cpan.org/dist/eps2png/">eps2png</ulink>. You should also download the <ulink url="adddscr">adddscr</ulink> script, make it executable and put it in the images directory. The adddscr <indexterm><primary>adddscr</primary></indexterm>script expects a parameter,<indexterm><primary>parameter</primary></indexterm> which should be one of the usual image file endings <indexterm><primary>endings</primary></indexterm>like &ldquo;gif&rdquo;, &ldquo;png&rdquo;, &ldquo;jpg&rdquo; etc. The idea is the following: you have all your images under the images directory and they are all of the same type, say GIF.<indexterm><primary>GIF</primary></indexterm> Then you just call</para><screen><![CDATA[adddscr gif
]]></screen><para>The adddscr <indexterm><primary>adddscr</primary></indexterm>script will convert <indexterm><primary>convert</primary></indexterm>all GIFs in the current directory to PNG<indexterm><primary>PNG</primary></indexterm> format, then call the addd utility <indexterm><primary>utility</primary></indexterm>to add the right density <indexterm><primary>density</primary></indexterm>to each image. Since addd produces .pdf and .eps from a given .png image and adddscr <indexterm><primary>adddscr</primary></indexterm>produces an additional .bmp, you end up with all the required image formats with the right properties for the subsequent inclusion in the various documents, be it PS,<indexterm><primary>PS</primary></indexterm> PDF <indexterm><primary>PDF</primary></indexterm>or RTF.<indexterm><primary>RTF</primary></indexterm> You may then delete your GIFs, you will not need them anymore (see <ulink url="http://burnallgifs.org">Burn All GIFs</ulink>.</para><para>If your images are all of type JPG,<indexterm><primary>JPG</primary></indexterm> just call </para><screen><![CDATA[adddscr jpg
]]></screen><para>in the images directory. If you just produced a sole image, you must call addd manually and then convert <indexterm><primary>convert</primary></indexterm>the png file to bmp. Example: Suppose you have just produced an image in JPG <indexterm><primary>JPG</primary></indexterm>format, say myimage.jpg. Then do:</para><screen><![CDATA[convert myimage.jpg myimage.png
]]><![CDATA[addd myimage
]]><![CDATA[convert myimage.png myimage.bmp
]]></screen><caution>
<title>Caution</title> 
<para> 
You will need to repeat the above steps for each and every image you produce! If you omit it, or use your own .pdf and .eps versions, most probably they will FAIL to be embedded in your PDF, resp. PS document! 
</para> 
</caution>
</sect1>
<sect1 id="run-sed-awk-scripts"><title>Run sed and awk scripts</title><para>Copy the following files in your working directory:</para><itemizedlist><listitem><para><ulink url="./sedscr">sedscr</ulink> (a sed script that corrects LyX' exported SGML <indexterm><primary>SGML</primary></indexterm>file), </para></listitem><listitem><para><ulink url="sedscr_top">sedscr_top</ulink> (a sed script you can use to eliminate <indexterm><primary>eliminate</primary></indexterm>the &ldquo;_top&rdquo; target attribute <indexterm><primary>attribute</primary></indexterm>of links whose link text contains a given regular expression string of your choice),</para></listitem><listitem><para><ulink url="sedscr_val">sedscr_val</ulink> (a sed script that effects all changes that are necessary for the HTML<indexterm><primary>HTML</primary></indexterm> document <indexterm><primary>document</primary></indexterm>to validate <indexterm><primary>validate</primary></indexterm>as conforming to the HTML <indexterm><primary>HTML</primary></indexterm>standards,<indexterm><primary>standards</primary></indexterm> see <xref linkend="HTML-validation"> for this subject),</para></listitem><listitem><para><ulink url="sedscr_ris">sedscr_ris</ulink> (a sed script that can create full RIS <indexterm><primary>RIS</primary></indexterm>datasets out of a file containings URLs - included only for your convenience and not absolutely necessary for our method, see more details in <xref linkend="Refdb">, <xref linkend="LyX-Bibliography"> and <xref linkend="explain-bibliography">),</para></listitem><listitem><para><ulink url="sedscr_abi">sedscr_abi</ulink> (a sed script that will append <indexterm><primary>append</primary></indexterm>the SGML <indexterm><primary>SGML</primary></indexterm>entities (as defined in the Preample,<indexterm><primary>Preample</primary></indexterm> see <xref linkend="preample">) for the Appendix, the Bibliography and the Index at the end of the corrected SGML <indexterm><primary>SGML</primary></indexterm>file, see <xref linkend="explain-appendix">),</para></listitem><listitem><para><ulink url="sedscr_app">sedscr_app</ulink> (a sed script that will insert a label <indexterm><primary>label</primary></indexterm>and title in the Appendix, as well as change the end tag from &lt;/article&gt; to &lt;/appendix&gt;),</para></listitem><listitem><para><ulink url="sedscr_cit">sedscr_cit</ulink> (a sed script that will create a LyX <indexterm><primary>LyX</primary></indexterm>file containing citation <indexterm><primary>citation</primary></indexterm>labels, to be used in citations),</para></listitem><listitem><para><ulink url="sedscr_bib">sedscr_bib</ulink> (a sed script that corrects the Appendix code, for the case we insert a bibliography <indexterm><primary>bibliography</primary></indexterm>after it, see <xref linkend="explain-appendix">),</para></listitem><listitem><para><ulink url="awkscr_math">awkscr_math</ulink> (an awk <indexterm><primary>awk</primary></indexterm>script that prepares the Mathematics <indexterm><primary>Mathematics</primary></indexterm>parts, like equations,<indexterm><primary>equations</primary></indexterm> for further processing,<indexterm><primary>processing</primary></indexterm> see <xref linkend="mathematics">, <xref linkend="DBTeXMath">, <xref linkend="magic-behind-the-math">),</para></listitem><listitem><para><ulink url="awkscr_refdb_html">awkscr_refdb_html</ulink> and <ulink url="awkscr_refdb_print">awkscr_refdb_print</ulink>, used to create the necessary stylesheets if you are using RefDB <indexterm><primary>RefDB</primary></indexterm>(see <xref linkend="Refdb">, <xref linkend="LyX-Bibliography"> and <xref linkend="explain-bibliography">),</para></listitem><listitem><para><ulink url="sedscr_tidy">sedscr_tidy</ulink>, a very rudimentary script that tries to reduce line length of the SGML<indexterm><primary>SGML</primary></indexterm> file by inserting newlines after &lt;para&gt; and &lt;/para&gt; tags. Also <ulink url="sedscr_tidy2">sedscr_tidy2</ulink>, another sed script, to correct the first tidy script. You would run these two as follows:</para><screen><![CDATA[# Tidy up the SGML file.
]]><![CDATA[# ${RUNSED} ${SEDSCRTIDY} $1.sgml
]]><![CDATA[# ${RUNSED} ${SEDSCRTIDY2} $1.sgml
]]></screen><para>However, they don't produce correct results, so the calls are commented in the lyxtox script.</para></listitem><listitem><para><ulink url="sedscr_ima">sedscr_ima</ulink>, a sed script that is used to produce another sed script, sedscr_img (sedscr_img is not included, as it is produced dynamically from the SGML file of the document and the sed script sedscr_ima).</para></listitem><listitem><para><ulink url="sedscr_apa">sedscr_apa</ulink>, a sed script that is used to erase &lt;acronym&gt;, &lt;productname&gt; and &lt;application&gt; tags from the alt and title texts in the dynamically created sed script sedscr_img.</para></listitem><listitem><para><ulink url="./lyxtox">lyxtox</ulink>, the main script that creates all documents using the above scripts and and the rest of the required software (<xref linkend="required-software">),</para></listitem></itemizedlist><para>Copy <ulink url="./runsed">runsed</ulink> somewhere like /usr/local/bin. <ulink url="./lyxtox">lyxtox</ulink> and <ulink url="./runsed">runsed</ulink> should be executable.</para><para><ulink url="./runsed">runsed</ulink> is a simple script that I modified from the original runsed <indexterm><primary>runsed</primary></indexterm>script found in O'Reilly's <ulink url="http://www.oreilly.com/catalog/upt3">Unix Power Tools</ulink>, Chapter <indexterm><primary>Chapter</primary></indexterm>34, Section 3 &ldquo;Testing and Using a sed Script: checksed, runsed<indexterm><primary>runsed</primary></indexterm>&rdquo;. It simply takes two filenames as an argument and then runs sed on the second file using the first file as a sed script:</para><screen><![CDATA[runsed sedscript file
]]></screen><para>A sed script is a script that tells sed what to do. sed, <indexterm><primary>sed,</primary></indexterm>in turn, is a powerful line editor suitable for batch processing <indexterm><primary>processing</primary></indexterm>(see <xref linkend="sed-and-awk">). You don't have to worry about runsed,<indexterm><primary>runsed</primary></indexterm> sedscr <indexterm><primary>sedscr</primary></indexterm>and lyxtox.<indexterm><primary>lyxtox</primary></indexterm> You may want to have a look at lyxtox,<indexterm><primary>lyxtox</primary></indexterm> just to ensure that all paths <indexterm><primary>paths</primary></indexterm>are correctly set and that you get some idea of what it does. It is very well commented. The gory details are in <xref linkend="explain-document-processing">.</para></sect1>
<sect1 id="start-and-end-scripts"><title>Set up your start and end scripts</title><para>You are going to need two scripts, with the endings <indexterm><primary>endings</primary></indexterm>.start and .end respectively, and the same basename <indexterm><primary>basename</primary></indexterm>as your LyX <indexterm><primary>LyX</primary></indexterm>document (without the LyX <indexterm><primary>LyX</primary></indexterm>ending). Example: if you are processing <indexterm><primary>processing</primary></indexterm>myLyxfile.lyx, then you can create myLyxfile.start and myLyxfile.end. These files can contain code of your choice to be executed at the start and at the end of the <ulink url="./lyxtox">lyxtox</ulink> script. The .start file should contain at least the lines:</para><screen><![CDATA[# Title of this document.
]]><![CDATA[TITLE="LyX and SGML"
]]><![CDATA[FORMATSFILE="formats.html"
]]><![CDATA[COPYRIGHT="All contents <a href=\"license.html\">\&copy;<\/a> 2002-2006 <a href=\"http:\/\/www.karakas-online.de\">Chris Karakas<\/a>"
]]><![CDATA[HOMEFILE="book1.html"
]]><![CDATA[# Flags
]]><![CDATA[# Set to "1" to process math.
]]><![CDATA[process_math="1"
]]><![CDATA[# Set to "1" if you have RefDB installed
]]><![CDATA[# and want to create the bibliography.sgml file 
]]><![CDATA[# through RefDB.
]]><![CDATA[process_RefDB="1"
]]><![CDATA[RefDB_db="ck_refdb"
]]><![CDATA[REFDB_style="J.Biol.Chem."
]]></screen><para>The values for TITLE, FORMATSFILE, COPYRIGHT, HOMEFILE etc. are used in the HTML file generation. You may need them or not, depending on whether you use them in your part1, part2 and part3 files, which are responsible for your custom header and footer (see <xref linkend="explain-document-creation-HTML">).</para><para>The values for process_math and process_RefDB are necessary. If you don't use mathematics (see <xref linkend="LyX-Mathematics">), set process_math to 0. If you don't use RefDB (see <xref linkend="LyX-Bibliography-with-RefDB">), set process_RefDB to 0.</para><para>See <ulink url="example.start">example.start</ulink> for an example of a .start file.</para><para>The .end file (myLyXfile.end in our example above) is there for you to add whatever additional processing steps you like. I use it to create all the tar archives found in <xref linkend="formats">, but you can use it for whatever you like. Here is a typical .end file that you would use to massage the HTML files a bit (with <ulink url="sedscr_val">sedscr_val</ulink>, in order to make them HTML standards compliant) and then create all those tar archives found in <xref linkend="formats">:</para><screen><![CDATA[# Do some changes that are necessary for the HTML file to be validated
]]><![CDATA[# as a conforming one, according to the standards
]]><![CDATA[# of the W3C (see http://validator.w3c.org).
]]><![CDATA[$RUNSED sedscr_val $1/*.html
]]><![CDATA[rm $1/*.bak
]]><![CDATA[rm $1/*.tar.gz
]]><![CDATA[cp sedscr_top $1/
]]><![CDATA[# Admonitions and Callouts.
]]><![CDATA[cp -v admonitions.tar.gz $1/
]]><![CDATA[cp -v callouts.tar.gz $1/
]]><![CDATA[# TAR, all files.
]]><![CDATA[$TAR --exclude=$1/index.html -czvf $1.tar.gz $1/
]]><![CDATA[cp $1.tar.gz $1/
]]><![CDATA[rm $1.tar.gz
]]><![CDATA[# TAR, one big HTML file with images.
]]><![CDATA[$TAR -czvf $1-onehtml.tar.gz $1/$1.html $1/images/*.png $1/images/*.gif $1/images/*/*.png $1/ck-style.css $tarfilelist
]]><![CDATA[cp $1-onehtml.tar.gz $1/
]]><![CDATA[rm $1-onehtml.tar.gz
]]><![CDATA[# TAR, many HTML files with images.
]]><![CDATA[$TAR --exclude=$1/$1.html --exclude=$1/index.html -czvf $1-html.tar.gz $1/*.html $1/images/*.png $1/images/*.gif $1/images/*/*.png $1/ck-style.css $tarfilelist
]]><![CDATA[cp $1-html.tar.gz $1/
]]><![CDATA[rm $1-html.tar.gz
]]><![CDATA[# TAR, RTF file with images.
]]><![CDATA[$TAR -czvf $1-rtf.tar.gz $1/$1.rtf $1/images/*.bmp $1/images/*/*.bmp $tarfilelist
]]><![CDATA[cp $1-rtf.tar.gz $1/
]]><![CDATA[rm $1-rtf.tar.gz
]]><![CDATA[# TAR, SGML file with images.
]]><![CDATA[$TAR -czvf $1-sgml.tar.gz $1/$1.sgml $1/images/* $1/images/*/* $1/appendix.sgml $tarfilelist
]]><![CDATA[cp $1-sgml.tar.gz $1/
]]><![CDATA[rm $1-sgml.tar.gz
]]><![CDATA[# TAR, only the filelist.
]]><![CDATA[$TAR -czvf $1-scripts.tar.gz $tarfilelist
]]><![CDATA[cp $1-scripts.tar.gz $1/
]]><![CDATA[rm $1-scripts.tar.gz
]]></screen><para>See <ulink url="example.end">example.end</ulink> for an example of an .end file.</para></sect1>
<sect1 id="custom-headers-and-footers"><title>Set up custom headers and footers</title><para>Use <ulink url="part1">part1</ulink>, <ulink url="part2">part2</ulink> and <ulink url="part3">part3</ulink> to customize your headers and footers. You will not need to touch part1, unless you wish to change the DOCTYPE setting. You will, however, certainly want to adapt part2 (for the headers) and part3 (for the footers). These files are full-blown examples that demonstrate what you can do to enhance navigation and searching:</para><para>For the header (part2):</para><itemizedlist><listitem><para>Add META tags, for example for the character encoding (<xref linkend="localization">), the CSS (<xref linkend="CSS">) or favicon:</para><screen><![CDATA[<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
]]><![CDATA[<link rel="stylesheet" type="text/css" href="ck-style.css">
]]><![CDATA[<link rel="icon" href="images/favicon.ico" type="image/x-icon">
]]><![CDATA[<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
]]></screen></listitem><listitem><para>Add a logo image:</para><screen><![CDATA[<a href="http://www.karakas-online.de" target="_top"><img src="images/karakas-online.png" alt="Karakas Online" border="0"></a>
]]></screen></listitem><listitem><para>Add a site search field that lets your visitors do a site-specific Google search. First some Javascript constants:</para><screen><![CDATA[<div align="center">
]]><![CDATA[<script type="text/javascript"><!--
]]><![CDATA[google_ad_client = "pub-2303179107222659";
]]><![CDATA[google_ad_width = 468;
]]><![CDATA[google_ad_height = 60;
]]><![CDATA[google_ad_format = "468x60_as";
]]><![CDATA[google_color_border = "B4D0DC";
]]><![CDATA[google_color_bg = "ECF8FF";
]]><![CDATA[google_color_link = "0000CC";
]]><![CDATA[google_color_url = "008000";
]]><![CDATA[google_color_text = "6F6F6F";
]]><![CDATA[//--></script>
]]><![CDATA[<script type="text/javascript"
]]><![CDATA[  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
]]><![CDATA[</script>
]]><![CDATA[</div>
]]></screen><para>and then a few lines further down, the actual search field:</para><screen><![CDATA[<div class="BREADCRUMBS">
]]><![CDATA[<table summary="Breadcrumbs" width="100%" border="0" cellpadding="0" cellspacing="0">
]]><![CDATA[<tr>
]]><![CDATA[<td width="30%" align="left" valign="bottom">
]]><![CDATA[  <a href="http://_DOMAIN_" accesskey="S">Start</a>
]]><![CDATA[  <img src="images/small.arrow.outline.gif" alt="->" width="18" height="9" hspace="2" />
]]><![CDATA[  <a href="_HOMEFILE_" accesskey="H" target="_top">_TITLE_</a>
]]><![CDATA[  <img src="images/small.arrow.outline.gif" alt="->" width="18" height="9" hspace="2" />
]]><![CDATA[  <a href="_FILENAME_" accesskey="T" target="_top">This page</a>
]]><![CDATA[</td>
]]><![CDATA[<td width="40%" align="center" valign="bottom">
]]><![CDATA[  <!-- SiteSearch Google -->
]]><![CDATA[  <FORM method=GET action='http://www.google.com/custom'>
]]><![CDATA[  <input type=hidden name=domains value='karakas-online.de'><INPUT TYPE=text name=q size=31 maxlength=255 value=''>
]]><![CDATA[  <INPUT type=submit name=sa VALUE='Search'>
]]><![CDATA[  <input type=hidden name=sitesearch value='karakas-online.de'>
]]><![CDATA[  <input type=hidden name=client value='pub-2303179107222659'>
]]><![CDATA[  <input type=hidden name=forid value='1'>
]]><![CDATA[  <input type=hidden name=channel value='5156821179'>
]]><![CDATA[  <input type=hidden name=ie value='ISO-8859-1'>
]]><![CDATA[  <input type=hidden name=oe value='ISO-8859-1'>
]]><![CDATA[  <input type=hidden name=safe value='active'>
]]><![CDATA[  <input type=hidden name=cof value='GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:44;LW:468;L:http://_DOMAIN_/_DIRNAME_/images/karakas-online.png;S:http://www.karakas-online.de;FORID:1;'>
]]><![CDATA[  <input type=hidden name=hl value='en'>
]]><![CDATA[  </FORM>
]]><![CDATA[  <!-- SiteSearch Google -->
]]><![CDATA[</td>
]]><![CDATA[<td width="30%" align="right" valign="bottom">
]]><![CDATA[  <a href="./" accesskey="M" target="_top">Display Sitemenu</a>
]]><![CDATA[</td>
]]><![CDATA[</tr>
]]><![CDATA[</table>
]]><![CDATA[</div>
]]></screen></listitem><listitem><para>Add translation links for the current page. But how does the header know the link to the current page? Here's where the constants DOMAIN, DIRNAME and FILENAME come into play:</para><screen><![CDATA[<div class="translatelink" align="right">
]]><![CDATA[<a href="http://babelfish.altavista.com/babelfish/tr?doit=done&amp;url=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;lp=en_zh">chinese</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cfr&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">french</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cde&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">german</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cit&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">italian</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://babelfish.altavista.com/babelfish/tr?doit=done&amp;url=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;lp=en_ja">japanese</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://babelfish.altavista.com/babelfish/tr?doit=done&amp;url=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;lp=en_ko">korean</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cpt&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">portuguese</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Ces&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">spanish</a>
]]><![CDATA[</div>
]]></screen><para>DOMAIN is set in the .start file (see <xref linkend="start-and-end-scripts">), DIRNAME is replaced in lyxtox with the parameter you passed it:</para><screen><![CDATA[${SED} -e "s/_DIRNAME_/$1/g" part2_1.tmp > part2_2.tmp
]]></screen><para>Since the parameter you pass to lyxtox is supposed to be the basename of your .lyx file, which will also become the name of the directory where everything is going to be placed, you can see that DIRNAME will be replaced with the right directory name (actually, what will be replaced is _DIRNAME_, but the underscores are there only to make sure there is no other DIRNAME variable by accident there). Finally, FILENAME is determined in lyxtox as the basename of the HTML file:</para><screen><![CDATA[${SED} -e "s/_FILENAME_/${BASENAME}/g" part2_2.tmp > part2_3.tmp
]]></screen></listitem><listitem><para>Add some &ldquo;breadcrumbs&rdquo;, i.e. navigation links separated by a &ldquo;|&rdquo;. Here the links point to the various formats of the document, with a nice example of how to mail the current page to a friend using a custom text and the right page link:</para><screen><![CDATA[<div class="BREADCRUMBS">
]]><![CDATA[<table summary="Breadcrumbs" width="100%" border="0" cellpadding="0" cellspacing="0">
]]><![CDATA[<tr>
]]><![CDATA[<td width="45%" align="left" valign="bottom">
]]><![CDATA[</td>
]]><![CDATA[<td width="10%" align="center" valign="bottom">
]]><![CDATA[</td>
]]><![CDATA[<td width="45%" align="right" valign="bottom">
]]><![CDATA[<a href="mailto:?Subject=Page%20recommendation&amp;Body=I%20thought%20you%20might%20find%20this%20URL%20interesting:%20http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_" onMouseover="window.status='Recommend this page to a friend'; return true;" onMouseout="window.status=''; return true" title="Recommend this page to a friend">Send to a friend&nbsp;</a>&nbsp;|&nbsp;<a href="_DIRNAME_.pdf" title="The *whole* document in PDF format">PDF&nbsp;</a>&nbsp;|&nbsp;<a href="_DIRNAME_.rtf" title="The *whole* document in RTF format">RTF&nbsp;</a>&nbsp;|&nbsp;<a href="_DIRNAME_.ps.gz" title="The *whole* document in gzipped Postscript (PS.GZ) format">PS&nbsp;</a>&nbsp;|&nbsp;<a href="_DIRNAME_.txt" title="The *whole* document in plain text (TXT) format">TXT&nbsp;</a>&nbsp;|&nbsp;<a href="_FORMATSFILE_" title="Other formats of this document">Other formats</a>
]]><![CDATA[</td>
]]><![CDATA[</tr>
]]><![CDATA[</table>
]]><![CDATA[</div>
]]></screen></listitem></itemizedlist><para>For the footer:</para><itemizedlist><listitem><para>Add a timestamp and a &ldquo;permalink&rdquo; (a permanent link, which people can use to link to the page):</para><screen><![CDATA[<div class="colophon">
]]><![CDATA[<table summary="Colophon" width="100%" border="0" cellpadding="0" cellspacing="0">
]]><![CDATA[<tr>
]]><![CDATA[<td width="30%" align="left" valign="bottom">
]]><![CDATA[Last updated _DATE_
]]><![CDATA[</td>
]]><![CDATA[<td width="40%" align="center" valign="bottom">
]]><![CDATA[Permalink: <a href="http://_DOMAIN_/_DIRNAME_/_FILENAME_" title="Permanent link to this page">http://_DOMAIN_/_DIRNAME_/_FILENAME_</a>
]]><![CDATA[</td>
]]><![CDATA[<td width="30%" align="right" valign="bottom">
]]><![CDATA[_COPYRIGHT_
]]><![CDATA[</td>
]]><![CDATA[</tr>
]]><![CDATA[</table>
]]><![CDATA[</div>
]]></screen></listitem><listitem><para>Add breadcrumb navigation links (&ldquo;Start&rdquo;, &ldquo;Document title&rdquo;, &ldquo;This page&rdquo;) and Google site search:</para><screen><![CDATA[<div class="BREADCRUMBS">
]]><![CDATA[<table summary="Breadcrumbs" width="100%" border="0" cellpadding="0" cellspacing="0">
]]><![CDATA[<tr>
]]><![CDATA[<td width="30%" align="left" valign="bottom">
]]><![CDATA[  <a href="http://_DOMAIN_" accesskey="S">Start</a>
]]><![CDATA[  <img src="images/small.arrow.outline.gif" alt="->" width="18" height="9" hspace="2" />
]]><![CDATA[  <a href="_HOMEFILE_" accesskey="H" target="_top">_TITLE_</a>
]]><![CDATA[  <img src="images/small.arrow.outline.gif" alt="->" width="18" height="9" hspace="2" />
]]><![CDATA[  <a href="_FILENAME_" accesskey="T" target="_top">This page</a>
]]><![CDATA[</td>
]]><![CDATA[<td width="40%" align="center" valign="bottom">
]]><![CDATA[  <!-- SiteSearch Google -->
]]><![CDATA[  <FORM method=GET action='http://www.google.com/custom'>
]]><![CDATA[  <input type=hidden name=domains value='karakas-online.de'><INPUT TYPE=text name=q size=31 maxlength=255 value=''>
]]><![CDATA[  <INPUT type=submit name=sa VALUE='Search'>
]]><![CDATA[  <input type=hidden name=sitesearch value='karakas-online.de'>
]]><![CDATA[  <input type=hidden name=client value='pub-2303179107222659'>
]]><![CDATA[  <input type=hidden name=forid value='1'>
]]><![CDATA[  <input type=hidden name=channel value='5156821179'>
]]><![CDATA[  <input type=hidden name=ie value='ISO-8859-1'>
]]><![CDATA[  <input type=hidden name=oe value='ISO-8859-1'>
]]><![CDATA[  <input type=hidden name=safe value='active'>
]]><![CDATA[  <input type=hidden name=cof value='GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:44;LW:468;L:http://_DOMAIN_/_DIRNAME_/images/karakas-online.png;S:http://_DOMAIN_;FORID:1;'>
]]><![CDATA[  <input type=hidden name=hl value='en'>
]]><![CDATA[  </FORM>
]]><![CDATA[  <!-- SiteSearch Google -->
]]><![CDATA[</td>
]]><![CDATA[<td width="30%" align="right" valign="bottom">
]]><![CDATA[  <a href="./" accesskey="M" target="_top">Display Sitemenu</a>
]]><![CDATA[</td>
]]><![CDATA[</tr>
]]><![CDATA[</table>
]]><![CDATA[</div>
]]></screen></listitem><listitem><para>Add translation links to the current page. These are the same as the ones for the header, only that they are centered instead of being aligned to the right of the page:</para><screen><![CDATA[<div class="translatelink" align="center">
]]><![CDATA[<a href="http://babelfish.altavista.com/babelfish/tr?doit=done&amp;url=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;lp=en_zh">chinese</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cfr&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">french</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cde&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">german</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cit&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">italian</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://babelfish.altavista.com/babelfish/tr?doit=done&amp;url=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;lp=en_ja">japanese</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://babelfish.altavista.com/babelfish/tr?doit=done&amp;url=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;lp=en_ko">korean</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Cpt&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">portuguese</a>
]]><![CDATA[ |
]]><![CDATA[<a href="http://translate.google.com/translate?u=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;langpair=en%7Ces&amp;hl=en&amp;ie=ISO-8859-1&amp;prev=%2Flanguage_tools">spanish</a>
]]><![CDATA[</div>
]]><![CDATA[Once again, the DOMAIN, DIRNAME and FILENAME constants come into play.
]]></screen></listitem><listitem><para>Finally, add some icons. Some of them point to the validator services of the W3C (see <xref linkend="HTML-validation">). These are also nice examples of how to compute the right link that is to be sent to the validator so that it will be able to validate the current page: you have to use &ldquo;http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&rdquo; for the CSS validator, but is is enough to use &ldquo;http://validator.w3.org/check/referer&rdquo; for the HTML validator. And don't miss the special link to &ldquo;validate your browser&rdquo;! :-)</para><screen><![CDATA[<div class="imagelink">
]]><![CDATA[<table width="100%">
]]><![CDATA[<tr align="center">
]]><![CDATA[<td width="30%" align="left" valign="middle">
]]><![CDATA[<a href="http://validator.w3.org/check/referer" target="_top">
]]><![CDATA[<img border="0" src="images/valid-html401.png" alt="Valid HTML 4.01! Click here to validate current page." title="Click here to validate the HTML code of this page"></a>
]]><![CDATA[</td>
]]><![CDATA[<td width="40%" align="center" valign="middle" colspan="3">
]]><![CDATA[<a href="http://www.anybrowser.org/campaign/" target="_top">
]]><![CDATA[<img border="0" src="images/w3c_ab.png" alt="Best viewed with ANY browser!" title="Click here to validate your browser"></a>
]]><![CDATA[</td>
]]><![CDATA[<td width="30%" align="right" valign="middle">
]]><![CDATA[<a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_&amp;warning=1&amp;profile=css3&amp;usermedium=all" target="_top">
]]><![CDATA[<img border="0" src="images/valid-css.png" alt="Valid CSS! Click here to validate current CSS." title="Click here to validate the CSS of this page"></a>
]]><![CDATA[</td>
]]><![CDATA[</tr>
]]><![CDATA[<tr align="center">
]]><![CDATA[<td align="left" valign="middle">
]]><![CDATA[</td>
]]><![CDATA[<td align="center" valign="middle">
]]><![CDATA[<a href="http://www.gnu.org/copyleft/fdl.html" target="_top">
]]><![CDATA[<img border="0" src="images/gnu-fdl.png" alt="This is a free document, published under the <acronym>GNU</acronym> Free Documentation Licence" title="GNU Free Documentation Licence"></a>
]]><![CDATA[</td>
]]><![CDATA[<td align="center" valign="middle">
]]><![CDATA[<a href="http://counter.li.org" target="_top">
]]><![CDATA[<img border="0" src="images/linux_user_314103.png" alt="Linux Counter icon. Chris Karakas is  <productname>Linux</productname> Counter registered user #314103" title="Linux Counter"></a>
]]><![CDATA[</td>
]]><![CDATA[<td align="center" valign="middle">
]]><![CDATA[<a href="http://www.fsf.org" target="_top">
]]><![CDATA[<img border="0" src="images/powered-by-free-software.png" alt="This is a free document, made with free software" title="Free Software"></a>
]]><![CDATA[</td>
]]><![CDATA[<td align="right" valign="middle">
]]><![CDATA[</td>
]]><![CDATA[</tr>
]]><![CDATA[</table>
]]><![CDATA[</div>
]]></screen></listitem></itemizedlist><tip>
<title>How to set the constants in the part* files</title> 
<para> 
Do not set the DOMAIN, DIRNAME and FILENAME constants in the part* files. Set only TITLE, DOMAIN, FORMATSFILE,  COPYRIGHT and HOMEFILE in the .start file. DIRNAME and FILENAME are computed automatically in lyxtox. 
</para> 
</tip>
</sect1>
<sect1 id="bibliographic-database"><title>Set up your bibliographic database</title><para>If you don't want to use <ulink url="http://refdb.sourceforge.net">RefDB</ulink>, there is nothing you have to do at this stage, so you can skip this section. However, you will have more work in the long run, as you will need to enter the bibliographic <indexterm><primary>bibliographic</primary></indexterm>references each time by hand in pure SGML <indexterm><primary>SGML</primary></indexterm>in a separate file, see <xref linkend="LyX-Bibliography">. </para><para>If you want to use RefDB,<indexterm><primary>RefDB</primary></indexterm> to take advantage of all the automated processing <indexterm><primary>processing</primary></indexterm>offered to you by a bibliographic database,<indexterm><primary>database</primary></indexterm> RefDB <indexterm><primary>RefDB</primary></indexterm>and the <ulink url="./lyxtox">lyxtox</ulink> script, there is some prelimnary work to do: before you use your bibliographic<indexterm><primary>bibliographic</primary></indexterm> treasures in citations <indexterm><primary>citations</primary></indexterm>and the reference list, you have to import them into the RefDB <indexterm><primary>RefDB</primary></indexterm>database you created during installation of the RefDB <indexterm><primary>RefDB</primary></indexterm>package (see <xref linkend="Refdb">). Further, you must give the name of your database <indexterm><primary>database</primary></indexterm>as the value of the RefDB_db<indexterm><primary>RefDB_db</primary></indexterm> variable in <ulink url="./lyxtox">lyxtox</ulink> and also set process_RefDB to &ldquo;1&rdquo;, indicating you wish bibliographic <indexterm><primary>bibliographic</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>through RefDB.<indexterm><primary>RefDB</primary></indexterm></para><para>Adding references boils down to running the <ulink url="http://refdb.sourceforge.net/manual-0.9.4/x4965.html#APP-C-COMMAND-ADDREF">addref</ulink> command with proper input files. The input files have to be valid RIS <indexterm><primary>RIS</primary></indexterm>files. They may contain one or more RIS <indexterm><primary>RIS</primary></indexterm>datasets.</para><para>An example of a RIS <indexterm><primary>RIS</primary></indexterm>file is <ulink url="refdb.ris">refdb.ris</ulink>. A typical bibliographic <indexterm><primary>bibliographic</primary></indexterm>entry in the RIS <indexterm><primary>RIS</primary></indexterm>format looks like:</para><screen><![CDATA[TY  - ELEC
]]><![CDATA[ID  - Walsh2002
]]><![CDATA[AU  - Walsh,Norman
]]><![CDATA[AU  - Muellner,Leonard
]]><![CDATA[TI  - DocBook: The definitive Guide - Apendix
]]><![CDATA[KW  - guide
]]><![CDATA[KW  - docbook
]]><![CDATA[RP  - NOT IN FILE
]]><![CDATA[PB  - O'Reilly & Associates, Inc.
]]><![CDATA[UR  - http://docbook.org/tdg/en/html/appa.html
]]><![CDATA[N1  - Accessed 29.06.2003
]]><![CDATA[PY  - 2002/06/17/Version 2.0.8
]]><![CDATA[SN  - 156592-580-7
]]><![CDATA[ER  -
]]></screen><para>Each line starts with a two-letter <indexterm><primary>two-letter</primary></indexterm>tag followed by the string &ldquo; - &ldquo; (two spaces, a dash, and another space). Each RIS <indexterm><primary>RIS</primary></indexterm>dataset starts with the TY <indexterm><primary>TY</primary></indexterm>(type) tag and ends with the ER <indexterm><primary>ER</primary></indexterm>(End of Reference) tag. In between, tag sequence is arbitrary. The meaning of the tags is:</para><variablelist><varlistentry><term>TY:
</term><listitem><para>Citation type. Can attain many values, some of the most usual being:</para></listitem></varlistentry></variablelist><itemizedlist><listitem><para>ABST (abstract reference)</para></listitem><listitem><para>BOOK (whole book reference)</para></listitem><listitem><para>COMP (computer program)</para></listitem><listitem><para>DATA <indexterm><primary>DATA</primary></indexterm>(data file) </para></listitem><listitem><para>ELEC <indexterm><primary>ELEC</primary></indexterm>(electronic citation)</para></listitem><listitem><para>GEN (generic)</para></listitem><listitem><para>JOUR (journal/periodical reference)</para></listitem></itemizedlist><variablelist><varlistentry><term>ID:
</term><listitem><para>Unique citation <indexterm><primary>citation</primary></indexterm>ID <indexterm><primary>ID</primary></indexterm>string. This can either be explicitly set by you, or automatically <indexterm><primary>automatically</primary></indexterm>set by the RefDB<indexterm><primary>RefDB</primary></indexterm> system. It plays the same role as the citation <indexterm><primary>citation</primary></indexterm>key in the standard methods provided by LyX <indexterm><primary>LyX</primary></indexterm>for citation <indexterm><primary>citation</primary></indexterm>purposes (see <xref linkend="explain-bibliography">).</para></listitem></varlistentry><varlistentry><term>AU:
</term><listitem><para>Author. Synonym: A1.<indexterm><primary>A1</primary></indexterm></para></listitem></varlistentry><varlistentry><term>TI:
</term><listitem><para>Title</para></listitem></varlistentry><varlistentry><term>KW:
</term><listitem><para>Keyword</para></listitem></varlistentry><varlistentry><term>RP:
</term><listitem><para>Reprint status. Can be one of </para></listitem></varlistentry></variablelist><itemizedlist><listitem><para>IN FILE<indexterm><primary>FILE</primary></indexterm></para></listitem><listitem><para>NOT IN FILE<indexterm><primary>FILE</primary></indexterm></para></listitem><listitem><para>ON REQUEST MM/DD/YY</para></listitem></itemizedlist><variablelist><varlistentry><term>PB:
</term><listitem><para>Publisher</para></listitem></varlistentry><varlistentry><term>UR:
</term><listitem><para>URL <indexterm><primary>URL</primary></indexterm>(for electronic citations)</para></listitem></varlistentry></variablelist><para>Multiple AU <indexterm><primary>AU</primary></indexterm>and KW <indexterm><primary>KW</primary></indexterm>tags are possible. For a complete list of the RIS <indexterm><primary>RIS</primary></indexterm>tags and their possible values see <ulink url="http://refdb.sourceforge.net/manual-0.9.4/c2166.html">Writing RefDB data input</ulink> - here is a more elaborate example of a bibliographic <indexterm><primary>bibliographic</primary></indexterm>entry in RIS <indexterm><primary>RIS</primary></indexterm>format, taken from this document:<indexterm><primary>document</primary></indexterm></para><screen><![CDATA[TY  - CHAP
]]><![CDATA[T1  - Physiological studies of the natriuretic peptide family
]]><![CDATA[A1  - Lewicki,J.A.
]]><![CDATA[A1  - Protter,A.A.
]]><![CDATA[Y1  - 1995///
]]><![CDATA[N1  - Atrial Natriuretic Peptide   Cardiac synthesis and secretion of /
]]><![CDATA[ANP   Regulation of ANP Gene Expression   Regulation of ANP Release /
]]><![CDATA[  ANP Receptors   Biologic Actions of ANP Brain Natriuretic Peptide (BNP) /
]]><![CDATA[  BNP Structure   Biosynthesis of BNP   Biological Actions of BNP C-Type /
]]><![CDATA[ Natriuretic Peptide (CNP)   Biologic Actions of CNP Modulators of /
]]><![CDATA[ Natriuretic Peptide Clearance   Effects of Clearance Receptor Blockers /
]]><![CDATA[  Effects of Neutral Endopeptidase Inhibitors Role of the Natriuretic / 
]]><![CDATA[ Peitedes in Physiology and Disease   Hypertension   Congestive Heart  /
]]><![CDATA[Failure   Supraventricular Tachyarrhythmias   Acute Renal Dysfunction
]]><![CDATA[KW  - natriuretic
]]><![CDATA[KW  - ANF
]]><![CDATA[KW  - ANP
]]><![CDATA[KW  - receptors
]]><![CDATA[KW  - BNP
]]><![CDATA[KW  - CNP
]]><![CDATA[KW  - hypertension
]]><![CDATA[KW  - congestive heart failure
]]><![CDATA[KW  - review
]]><![CDATA[KW  - cardiac
]]><![CDATA[KW  - regulation
]]><![CDATA[KW  - gene expression
]]><![CDATA[KW  - expression
]]><![CDATA[KW  - brain
]]><![CDATA[KW  - structure
]]><![CDATA[KW  - biosynthesis
]]><![CDATA[KW  - receptor
]]><![CDATA[KW  - inhibitor
]]><![CDATA[KW  - physiology
]]><![CDATA[KW  - renal
]]><![CDATA[KW  - study
]]><![CDATA[KW  - Peptides
]]><![CDATA[KW  - atrial natriuretic peptide
]]><![CDATA[KW  - MODULATOR
]]><![CDATA[KW  - secretion
]]><![CDATA[KW  - Gene Expression Regulation
]]><![CDATA[RP  - IN FILE
]]><![CDATA[SP  - 1029
]]><![CDATA[EP  - 1053
]]><![CDATA[VL  - 2
]]><![CDATA[T2  - Hypertension: Pathophysiology, Diagnosis, and Management
]]><![CDATA[A2  - Laragh,J.H.
]]><![CDATA[A2  - Brenner,B.M.
]]><![CDATA[IS  - 61
]]><![CDATA[CY  - New York
]]><![CDATA[PB  - Raven Press, Ltd.
]]><![CDATA[ER  -
]]></screen><para>To build your own bibliographic <indexterm><primary>bibliographic</primary></indexterm>database, you thus need all your references in the RIS <indexterm><primary>RIS</primary></indexterm>format. If you found your reference in the web edition of some scientific <indexterm><primary>scientific</primary></indexterm>journal, or one of the specialized bibliographic <indexterm><primary>bibliographic</primary></indexterm>databases on the Internet, like <ulink url="http://www.pubmed.com">PubMed</ulink>, chances are that you will be able to copy the RIS <indexterm><primary>RIS</primary></indexterm>version of the bibliographic<indexterm><primary>bibliographic</primary></indexterm> entry with a mouse click on some link. Otherwise, you will either have to import it with the use of one of the input filters <indexterm><primary>filters</primary></indexterm>shipped with RefDB,<indexterm><primary>RefDB</primary></indexterm> use the Web <indexterm><primary>Web</primary></indexterm>interface <indexterm><primary>interface</primary></indexterm>(which you installed in <xref linkend="Refdb">), or write all those tags and their values by hand.</para><para>For automatic import, RefDB <indexterm><primary>RefDB</primary></indexterm>offers the following input filters:<indexterm><primary>filters</primary></indexterm></para><itemizedlist><listitem><para>dos2unix: A simple shell script to convert <indexterm><primary>convert</primary></indexterm>text files like RIS <indexterm><primary>RIS</primary></indexterm>documents from DOS-style line endings <indexterm><primary>endings</primary></indexterm>to Unix-style line endings. Most refdb <indexterm><primary>refdb</primary></indexterm>tools need their input files with Unix-style line endings.<indexterm><primary>endings</primary></indexterm> This is a valuable tool to import reference databases from <productname>Windows</productname> <indexterm><primary>Windows</primary></indexterm>reference managers.</para></listitem><listitem><para>med2ris.pl: A tool to convert <indexterm><primary>convert</primary></indexterm>Pubmed <indexterm><primary>Pubmed</primary></indexterm>data in both the tagged <indexterm><primary>tagged</primary></indexterm>and the XML format to RIS.<indexterm><primary>RIS</primary></indexterm></para></listitem><listitem><para>bib2ris: A tool to convert <indexterm><primary>convert</primary></indexterm>BibTeX data to RIS.<indexterm><primary>RIS</primary></indexterm></para></listitem><listitem><para>db2ris: A tool to convert <indexterm><primary>convert</primary></indexterm>reference data in DocBook <indexterm><primary>DocBook</primary></indexterm>SGML/XML documents to RIS.<indexterm><primary>RIS</primary></indexterm></para></listitem><listitem><para>marc2ris.pl: A tool to convert <indexterm><primary>convert</primary></indexterm>references in MARC format to RIS.<indexterm><primary>RIS</primary></indexterm></para></listitem></itemizedlist><para>To import all references from a RIS <indexterm><primary>RIS</primary></indexterm>file called, say, refdb.<indexterm><primary>refdb</primary></indexterm>ris, start refdbc and then type:</para><screen><![CDATA[addref refdb.ris
]]></screen><para>Once you have populated your own bibliographic <indexterm><primary>bibliographic</primary></indexterm>database with entries, you should export it to a file - it will serve you as a backup and reference. To export all entries in a file called refdb.<indexterm><primary>refdb</primary></indexterm>ris (this will overwrite any existing refdb.<indexterm><primary>refdb</primary></indexterm>ris file, so take care):</para><screen><![CDATA[getref -t ris -o refdb.ris -s "ALL" :ID:>0
]]></screen><para>Open the refdb.<indexterm><primary>refdb</primary></indexterm>ris file with a text editor and examine it. Pay special attention to the values of the <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>field - we will use this field in a somewhat tricky way to refer to the bibliographic <indexterm><primary>bibliographic</primary></indexterm>entries from LyX.<indexterm><primary>LyX</primary></indexterm> How this is done, is explained in <xref linkend="LyX-Bibliography">.</para></sect1>
<sect1 id="CSS"><title>Use a CSS for DocBook </title><para>The following two definitions in the HTML <indexterm><primary>HTML</primary></indexterm>stylesheets (see <xref linkend="DSSSL-stylesheets">) specify the CSS <indexterm><primary>CSS</primary></indexterm>that is to be used for HTML <indexterm><primary>HTML</primary></indexterm>output:</para><screen><![CDATA[(define %stylesheet%
]]><![CDATA[  ;; Name of the stylesheet to use
]]><![CDATA[  ;;#f)
]]><![CDATA[  "ck-style.css")
]]><![CDATA[  
]]><![CDATA[(define %stylesheet-type%
]]><![CDATA[  ;; The type of the stylesheet to use
]]><![CDATA[  "text/css")
]]></screen><para>Of course, you may decide that you don't need a CSS,<indexterm><primary>CSS</primary></indexterm> in which case you should define %stylesheet% <indexterm><primary>%stylesheet%</primary></indexterm>to &ldquo;#f&rdquo;. But this is only part of the story! You may discover that your HTML <indexterm><primary>HTML</primary></indexterm>documents still need the ck-style.css,<indexterm><primary>ck-style.css</primary></indexterm> even if you set %stylesheet% <indexterm><primary>%stylesheet%</primary></indexterm>to &ldquo;#f&rdquo;! This is because of the extra processing <indexterm><primary>processing</primary></indexterm>that the header, body <indexterm><primary>body</primary></indexterm>and footer are subject to, as described in <xref linkend="HTML-validation">. You will have to change <ulink url="part2">part2</ulink> too to reflect the right CSS.<indexterm><primary>CSS</primary></indexterm></para><para>Talking about a &ldquo;right&rdquo; CSS <indexterm><primary>CSS</primary></indexterm>for DocBook,<indexterm><primary>DocBook</primary></indexterm> you may find out that there not so many out there available - see <ulink url="http://www.karakas-online.de/myLinuxTips/css-for-docbook.html">CSS for DocBook</ulink> for a rare example. The problem is that the HTML <indexterm><primary>HTML</primary></indexterm>produced by the tools <indexterm><primary>tools</primary></indexterm>presented here uses its own classes which don't seem to be widely used outside DocBook.<indexterm><primary>DocBook</primary></indexterm> Instead of inventing the wheel <indexterm><primary>wheel</primary></indexterm>for the third time, just grab my <ulink url="ck-style.css">ck-style.css</ulink> and use it as is, or adapt it to your purposes. As the scripts currently use it, it has to be installed in the working directory, but you can certainly change that easily.</para></sect1>
<sect1 id="coolthumbs"><title>Use coolthumbs</title><para>coolthumbs is a small, fine script that will create antialiased thumbnails<indexterm><primary>thumbnails</primary></indexterm> for your PDF <indexterm><primary>PDF</primary></indexterm>document (those icons <indexterm><primary>icons</primary></indexterm>that look like miniature copies of your pages, in the left column of <productname>Acrobat</productname> Reader, besides the bookmarks <indexterm><primary>bookmarks</primary></indexterm>tab). Whithout it, the thumbnails <indexterm><primary>thumbnails</primary></indexterm>will look &ldquo;high contrast&rdquo; or &ldquo;edgy&rdquo;. Using coolthumbs will produce hight quality thumbnails,<indexterm><primary>thumbnails</primary></indexterm> with the help of Ghostscript <indexterm><primary>Ghostscript</primary></indexterm>and The GIMP (which, of course, you must also have installed, if you decide to use it). You can get coolthumbs from the <ulink url="http://www.ringlord.com/publications/latex-pdf-howto">Linux LaTeX-PDF HOW-TO</ulink> (I would love to include it here, but unfortunately its copyright <indexterm><primary>copyright</primary></indexterm>notice does not allow it explicitly).</para><para>Install coolthumbs in, say, /usr/local/bin. Then enter its location in lyxtox <indexterm><primary>lyxtox</primary></indexterm>and set the use_coolthumbs parameter<indexterm><primary>parameter</primary></indexterm> to 1:</para><screen><![CDATA[# Shall we use the coolthumbs script to create the PDF thumbnails?
]]><![CDATA[# You can get coolthumbs from
]]><![CDATA[# http://www.ringlord.com/publications/latex-pdf-howto/
]]><![CDATA[# Note that you will also need to have GIMP installed
]]><![CDATA[# and that you will have to edit some lines in coolthumbs too.
]]><![CDATA[use_coolthumbs="1"
]]></screen><para>These are the values I had to change in my copy of coolthumbs:</para><itemizedlist><listitem><para>The location of The GIMP:</para><screen><![CDATA[# Program locations
]]><![CDATA[GIMP="/usr/bin/gimp"
]]><![CDATA[My GIMP scripts directory:
]]><![CDATA[# GIMPSCRIPTS: Your GIMP scripts directory. the file named by
]]><![CDATA[# SCALEALL will be CREATED there and then DELETED again:
]]><![CDATA[GIMPSCRIPTS=${HOME}/.gimp-1.2/scripts
]]></screen></listitem><listitem><para>Width and height of the thumbnails:<indexterm><primary>thumbnails</primary></indexterm></para><screen><![CDATA[THUMBNAIL_W=74
]]><![CDATA[THUMBNAIL_H=105
]]></screen></listitem><listitem><para>Some explanation on the choice of those values is due here: the ISO/DIN paper <indexterm><primary>paper</primary></indexterm>sizes (in mm) for the various DIN paper <indexterm><primary>paper</primary></indexterm>sizes are shown in <xref linkend="tab-ISO-DIN-paper-sizes"> (taken from <ulink url="http://en.wikipedia.org/wiki/Paper_size">Paper size</ulink>).</para><para><table id="tab-ISO-DIN-paper-sizes"><title>ISO/DIN paper sizes</title><tgroup cols="4" colsep="1" rowsep="1">
<colspec colname="col0" align="center">
<colspec colname="col1" align="center">
<colspec colname="col2" align="center">
<colspec colname="col3" align="center">
<tbody>
<row>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>A</para></entry>
<entry align="center" valign="top"><para>B</para></entry>
<entry align="center" valign="top"><para>C</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>0</para></entry>
<entry align="center" valign="top"><para>841x1189</para></entry>
<entry align="center" valign="top"><para>1000x1414</para></entry>
<entry align="center" valign="top"><para>917x1297</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>1</para></entry>
<entry align="center" valign="top"><para>594x841</para></entry>
<entry align="center" valign="top"><para>707x1000</para></entry>
<entry align="center" valign="top"><para>648x917</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>2</para></entry>
<entry align="center" valign="top"><para>420x594</para></entry>
<entry align="center" valign="top"><para>500x707</para></entry>
<entry align="center" valign="top"><para>458x648</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>3</para></entry>
<entry align="center" valign="top"><para>297x420</para></entry>
<entry align="center" valign="top"><para>353x500</para></entry>
<entry align="center" valign="top"><para>324x458</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>4</para></entry>
<entry align="center" valign="top"><para>210x297</para></entry>
<entry align="center" valign="top"><para>250x353</para></entry>
<entry align="center" valign="top"><para>229x324</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>5</para></entry>
<entry align="center" valign="top"><para>148x210</para></entry>
<entry align="center" valign="top"><para>176x250</para></entry>
<entry align="center" valign="top"><para>162x229</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>6</para></entry>
<entry align="center" valign="top"><para>105x148</para></entry>
<entry align="center" valign="top"><para>125x176</para></entry>
<entry align="center" valign="top"><para>114x162</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>7</para></entry>
<entry align="center" valign="top"><para>74x105</para></entry>
<entry align="center" valign="top"><para>88x125</para></entry>
<entry align="center" valign="top"><para>81x114</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>8</para></entry>
<entry align="center" valign="top"><para>52x74</para></entry>
<entry align="center" valign="top"><para>62x88</para></entry>
<entry align="center" valign="top"><para>57x81</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>9</para></entry>
<entry align="center" valign="top"><para>37x52</para></entry>
<entry align="center" valign="top"><para>44x62</para></entry>
<entry align="center" valign="top"><para>40x57</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>10</para></entry>
<entry align="center" valign="top"><para>26x37</para></entry>
<entry align="center" valign="top"><para>31x44</para></entry>
<entry align="center" valign="top"><para>28x40</para></entry>
</row>
</tbody>
</tgroup></table></para><para>From <xref linkend="tab-ISO-DIN-paper-sizes"> we see that if, as the author of coolthumb says, the values of 82/106 are &quot;pretty much dead-on&quot; for US Letter paper,<indexterm><primary>paper</primary></indexterm> then the values 74/105 must be just as &quot;dead on&quot; for DIN paper <indexterm><primary>paper</primary></indexterm>(we try to match one paper <indexterm><primary>paper</primary></indexterm>side as good as possible - and in this case we see that 106-105 is pretty much as good as can be). More precisely, it's dead-on for for DIN A7 paper,<indexterm><primary>paper</primary></indexterm> but DIN papers have the same aspect ratio throughout the whole paper <indexterm><primary>paper</primary></indexterm>range (see <xref linkend="fig-ISO-DIN-paper-sizes">), so the ratio 74/105 for DIN A7 is the same as the ratio 210/297 for DIN A4 (which is mostly used outside the USA) and also the same as every other DIN paper.<indexterm><primary>paper</primary></indexterm></para><para>
<figure id="fig-ISO-DIN-paper-sizes" float="1">
   <title>
   ISO-DIN paper sizes.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1002;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1002;.pdf" format="PDF">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1002;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1002;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>ISO-DIN paper sizes.</phrase>
      </textobject>
      <caption>
         <para>ISO-DIN paper sizes.</para>
      </caption>
   </mediaobject>
</figure>
</para></listitem><listitem><para>DPI (dots-per-inch) value for the thumbnails:<indexterm><primary>thumbnails</primary></indexterm></para><screen><![CDATA[SNAPSHOT_DPI=133
]]></screen></listitem><listitem><para>This is the DPI value of my monitor, as taken from the output of the graphic card driver in /var/log/XFree86.0.log, where it says:</para><screen><![CDATA[DPI set to (133, 133)
]]></screen><para>Of course, YMMV (=Your Monitor May Vary ;-)).</para></listitem><listitem><para>I use thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>version 3.2, so I set</para><screen><![CDATA[THUMBPDF_V2=0
]]></screen></listitem></itemizedlist></sect1>
</chapter>
<chapter id="writing-in-LyX"><title>Writing in LyX, thinking in SGML </title><para>You have now installed the required software (see <xref linkend="required-software">) and taken the required preliminary steps (see <xref linkend="required-preliminary-steps">) to ensure that everything is in place and configured correctly. In this chapter I will describe how write in LyX <indexterm><primary>LyX</primary></indexterm>in order to achieve the desired results. This may at first look trivial,<indexterm><primary>trivial</primary></indexterm> but is not: </para><para>LyX <indexterm><primary>LyX</primary></indexterm>is a frontend <indexterm><primary>frontend</primary></indexterm>for <application>LaTeX</application>.<indexterm><primary>LaTeX</primary></indexterm> It was designed with TeX/LaTeX in mind, not SGML.<indexterm><primary>SGML</primary></indexterm> The <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>language and the <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>macros describe a document <indexterm><primary>document</primary></indexterm>not only from the structural point of view (using markup <indexterm><primary>markup</primary></indexterm>that expresses facts like &ldquo;this is a paragraph<indexterm><primary>paragraph</primary></indexterm>&rdquo;, &ldquo;this is an itemized <indexterm><primary>itemized</primary></indexterm>list&rdquo;), but also from the descriptive one (&ldquo;use 12pt <indexterm><primary>12pt</primary></indexterm>here&rdquo;, &ldquo;indent 5cm there&rdquo;). SGML,<indexterm><primary>SGML</primary></indexterm> on the other side, separates structure from style. It is clear that when you export a TeX/LaTeX document <indexterm><primary>document</primary></indexterm>not each and every TeX/LaTeX construct that is possible in LyX <indexterm><primary>LyX</primary></indexterm>will find its equivalent in SGML.<indexterm><primary>SGML</primary></indexterm> Clearly, you will have to use only those constructs that are common to both, or at least can be mapped to each other with some reasonable processing<indexterm><primary>processing</primary></indexterm> of LyX' SGML <indexterm><primary>SGML</primary></indexterm>(done by <ulink url="lyxtox">lyxtox</ulink> using <ulink url="runsed">runsed</ulink> and <ulink url="sedscr">sedscr</ulink>). Remember this each time you try something in LyX,<indexterm><primary>LyX</primary></indexterm> only to find out that it does not work in SGML.<indexterm><primary>SGML</primary></indexterm></para><tip>
<title>Use the .lyx version of this document as a template</title> 
<para> 
Even if this chapter goes into a lot of details regarding writing in LyX in a manner that is compatible with SGML processing, a real example is still worth a thousand words. You should thus study real LyX documents that use the constructs discussed here and compare with the results in the other versions (HTML, PDF, PS, RTF, TXT and of course SGML). The best starting point is to use the .lyx version of this document (to be found in the links of <xref linkend="formats">). 
</para> 
<para>
Load the <ulink url="http://www.karakas-online.de/mySGML/mySGML.lyx">LyX version</ulink> of this document in LyX and study the way various elements are used. Use it as your template, your starting point for your own document! If you look attentively, you will see that I am trying out quite a few non-trivial tricks here, which you can copy for your own use. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> 
</para>
</tip>
<sect1 id="LyX-environments"><title>LyX environments</title><para>Different parts of a document <indexterm><primary>document</primary></indexterm>have different purposes; we call these parts <emphasis>environments</emphasis>. Most of a document <indexterm><primary>document</primary></indexterm>is made up of regular text. Section (chapter, subsection,<indexterm><primary>subsection</primary></indexterm> etc.) titles let the reader know that a new topic or subtopic <indexterm><primary>subtopic</primary></indexterm>will be discussed. Certain types of documents have special environments.<indexterm><primary>environments</primary></indexterm> A journal article will have an abstract,<indexterm><primary>abstract</primary></indexterm> and a title. A letter will have neither of these, but will probably have an environment<indexterm><primary>environment</primary></indexterm> that gives the writer's address.</para><para>Environments are a major part of the &ldquo;What You See Is What You Mean&rdquo; philosophy <indexterm><primary>philosophy</primary></indexterm>of LyX.<indexterm><primary>LyX</primary></indexterm> A given environment <indexterm><primary>environment</primary></indexterm>may require a certain font style, font size, indenting,<indexterm><primary>indenting</primary></indexterm> line spacing, and more. This problem is aggravated, because the exact formatting <indexterm><primary>formatting</primary></indexterm>for a given environment may change: one journal may use boldface, 18 point, centered type for section titles while another uses italicized, 15 point, left justified type; different languages may have different standards <indexterm><primary>standards</primary></indexterm>for indenting;<indexterm><primary>indenting</primary></indexterm> and bibliography <indexterm><primary>bibliography</primary></indexterm>formats can vary widely. LyX <indexterm><primary>LyX</primary></indexterm>lets you avoid <indexterm><primary>avoid</primary></indexterm>learning all the different formatting <indexterm><primary>formatting</primary></indexterm>styles.</para><para>The Environment box is located on the left end of the toolbar (just under the File menu). It indicates which environment <indexterm><primary>environment</primary></indexterm>you're currently writing in. While you were writing your first document,<indexterm><primary>document</primary></indexterm> it said &ldquo;Standard,&rdquo; which is the default environment <indexterm><primary>environment</primary></indexterm>for text. Now you will put a number of environments <indexterm><primary>environments</primary></indexterm>in your new document <indexterm><primary>document</primary></indexterm>so that you can see how they work. You'll do so with the Environment menu, which you open by clicking on the &ldquo;down arrow&rdquo; icon <indexterm><primary>icon</primary></indexterm>just to the right of the Environment box.</para><important>
<title>Don't use the "Paragraph" environment!</title> 
<para> 
Use "Standard" instead! Using "Paragraph" interferes with the changes that <ulink url="runsed">runsed</ulink> and <ulink url="sedscr">sedscr</ulink> try to effect in the SGML code as exported by LyX. Writing paragraphs in LyX is treated in <xref linkend="LyX-paragraphs"> - although there is actually nothing more to say on this subject for the moment. Just choose "Standard" and write.<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject>
</para>
</important>
<para>An important thing to keep in mind is that whatever environment <indexterm><primary>environment</primary></indexterm>you set in LyX, it will NOT, per se, affect the formatting <indexterm><primary>formatting</primary></indexterm>of your document! LyX<indexterm><primary>LyX</primary></indexterm> environments <indexterm><primary>environments</primary></indexterm>tell something about the <emphasis>structure</emphasis> of the document,<indexterm><primary>document</primary></indexterm> never about its formatting <indexterm><primary>formatting</primary></indexterm>(at least not in the context we will be using them here, i.e. as equivalent to SGML <indexterm><primary>SGML</primary></indexterm>tags). Thus, an environment <indexterm><primary>environment</primary></indexterm>of &ldquo;Standard&rdquo; will induce the &lt;para&gt; tag when exported to SGML <indexterm><primary>SGML</primary></indexterm>from LyX.<indexterm><primary>LyX</primary></indexterm> The following quote from the sgml-tools <indexterm><primary>sgml-tools</primary></indexterm>mailing list deals with a common misconception <indexterm><primary>misconception</primary></indexterm>of &lt;para&gt; (see <ulink url="http://www.via.ecp.fr/via/ml/sgml-tools/199901/msg00153.html">Use of &lt;Para&gt; within &lt;ListItem&gt; mangles list items</ulink>):</para><blockquote><para>&gt; I think the definition of &lt;Para&gt; means to start on a new line and break on a new line.</para><para>At the risk of being pedantic,<indexterm><primary>pedantic</primary></indexterm> I think you're making a mistake of interpreting DocBook <indexterm><primary>DocBook</primary></indexterm>markup <indexterm><primary>markup</primary></indexterm>tags as having any bearing on format, which they do not. This is unlike many HTML <indexterm><primary>HTML</primary></indexterm>tags, so if that's the particular SGML <indexterm><primary>SGML</primary></indexterm>DTD that you have more experience with, it may be coloring your intepretation.</para><para>DocBook <indexterm><primary>DocBook</primary></indexterm>tags (and to be honest,<indexterm><primary>honest</primary></indexterm> most SGML <indexterm><primary>SGML</primary></indexterm>DTDs) are used to identify the type and purpose of information, but not how that information might be portrayed in a formatted fashion. That's part of the whole power of it - by separating formatting/display from content, you are free to both ignore such issues when documenting, and yet be totally flexible during formatting <indexterm><primary>formatting</primary></indexterm>on how you want to present marked up text.</para><para>In DocBook,<indexterm><primary>DocBook</primary></indexterm> the &lt;Para&gt; element <indexterm><primary>element</primary></indexterm>is just defined as a &quot;paragraph&quot;<indexterm><primary>paragraph</primary></indexterm>, a container <indexterm><primary>container</primary></indexterm>sort of element <indexterm><primary>element</primary></indexterm>for other inline,<indexterm><primary>inline</primary></indexterm> and some block, elements. It says nothing about starting nor breaking on a newline,<indexterm><primary>newline</primary></indexterm> although of course such could be selected by a style sheet as an implementation.<indexterm><primary>implementation</primary></indexterm> In that respect the more tags you have in a document <indexterm><primary>document</primary></indexterm>(and the more granularity<indexterm><primary>granularity</primary></indexterm> of the information so tagged) the better - it gives the formatter <indexterm><primary>formatter</primary></indexterm>and style sheet the most flexibility in handling how the formatted output should appear.</para></blockquote><para>We talk about stylesheets in <xref linkend="DSSSL-stylesheets">, <xref linkend="CSS">, <xref linkend="explain-DSSSL-stylesheets">, <xref linkend="explain-CSS"> and <xref linkend="explain-math-processing-in-HTML-stylesheets">.</para></sect1>
<sect1 id="LyX-Authors-Credits-Roles"><title>Authors, Credits, Roles</title><para>If you have a more complicated situation than just an author for your document,<indexterm><primary>document</primary></indexterm> like affiliations,<indexterm><primary>affiliations</primary></indexterm> translators, contributors etc., here's the right way to enter such information in LyX,<indexterm><primary>LyX</primary></indexterm> so that it can be exported to SGML:<indexterm><primary>SGML</primary></indexterm></para><para>Create an environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) of type &ldquo;SGML&rdquo; just after the title and before the abstract.<indexterm><primary>abstract</primary></indexterm> There, enter the information as in the following example:</para><screen>
<![CDATA[
<authorgroup>
<author>   
<firstname>Chris</firstname>     <surname>Karakas</surname> 
<affiliation> 
<jobtitle>Webmaster</jobtitle>    
  <orgname>www.karakas-online.de</orgname>   
 </affiliation>  
</author>
<othercredit role="converter">
<contrib>Conversion from LyX to DocBook SGML, Index generation</contrib>
<firstname>Chris</firstname> <surname>Karakas</surname>
<affiliation>www.karakas-online.de</affiliation>
</othercredit>
<othercredit role="translator">
<contrib>Translation from italian</contrib>
<firstname>Chris</firstname> <surname>Karakas</surname>
<affiliation>www.karakas-online.de</affiliation>
</othercredit>
</authorgroup>
]]>
</screen>
</sect1>
<sect1 id="LyX-keywords"><title>Keywords</title><para>The metainformation <indexterm><primary>metainformation</primary></indexterm>on keywords <indexterm><primary>keywords</primary></indexterm>is not as relevant today (in the context of search engine optimization) as it was a few years ago. Nevertheless it may be a good practice to incorporate some keywords <indexterm><primary>keywords</primary></indexterm>in the header as there are still some search engines around that use them (<ulink url="http://www.google.com">Google</ulink> does not). Here's how you enter keywords <indexterm><primary>keywords</primary></indexterm>in LyX:<indexterm><primary>LyX</primary></indexterm></para><para>After the title and before the abstract,<indexterm><primary>abstract</primary></indexterm> create an environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) of type &ldquo;SGML&rdquo;. There, enter the keywords <indexterm><primary>keywords</primary></indexterm>as in the following example:</para><screen><![CDATA[<keywordset>
]]><![CDATA[<keyword>LyX</keyword>
]]><![CDATA[<keyword>SGML</keyword>
]]><![CDATA[<keyword>DocBook</keyword>
]]><![CDATA[</keywordset>
]]></screen></sect1>
<sect1 id="LyX-revision-history"><title>Revision history</title><para>You enter a revision history as follows: </para><para>Create an environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) of type &ldquo;SGML&rdquo; that is located after the abstract <indexterm><primary>abstract</primary></indexterm>and before the first chapter/section. In this environment,<indexterm><primary>environment</primary></indexterm> enter the revision history as in the following example:</para><screen><![CDATA[<REVHISTORY>
]]><![CDATA[<REVISION>
]]><![CDATA[<REVNUMBER>1.2
]]><![CDATA[</REVNUMBER>
]]><![CDATA[<DATE>29.05.2003
]]><![CDATA[</DATE>
]]><![CDATA[<AUTHORINITIALS>CK
]]><![CDATA[</AUTHORINITIALS>
]]><![CDATA[<REVREMARK>Some remarks about this revision.
]]><![CDATA[</REVREMARK>
]]><![CDATA[</REVISION>
]]><![CDATA[<REVISION>
]]><![CDATA[<REVNUMBER>1.1
]]><![CDATA[</REVNUMBER>
]]><![CDATA[<DATE>13.02.2003
]]><![CDATA[</DATE>
]]><![CDATA[<AUTHORINITIALS>CK
]]><![CDATA[</AUTHORINITIALS>
]]><![CDATA[<REVREMARK>Some remarks about this revision.
]]><![CDATA[</REVREMARK>
]]><![CDATA[</REVISION>
]]></screen><para>Revision numbers <indexterm><primary>numbers</primary></indexterm>should be entered in reverse order (i.e., the latest revision should appear first on the list).</para></sect1>
<sect1 id="LyX-paragraphs"><title>Paragraphs</title><para>Do NOT use the &ldquo;Paragraph&rdquo; environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) when writing a paragraph.<indexterm><primary>paragraph</primary></indexterm> Use &ldquo;Standard&rdquo; instead. Using &ldquo;Paragraph&rdquo; interferes with the changes that <ulink url="runsed">runsed</ulink> and <ulink url="sedscr">sedscr</ulink> try to effect in the SGML <indexterm><primary>SGML</primary></indexterm>code as exported by LyX.<indexterm><primary>LyX</primary></indexterm></para></sect1>
<sect1 id="LyX-cross-references"><title>Cross references </title><para>Cross-references work in exactly the same way as usually in LyX:<indexterm><primary>LyX</primary></indexterm> you first insert a label <indexterm><primary>label</primary></indexterm>(choosing Insert--&gt;Label from the menu), then insert a cross-reference <indexterm><primary>cross-reference</primary></indexterm>at a point of your choice (choosing Insert--&gt;Cross-reference from the menu). BUT: You can't cross-reference <indexterm><primary>cross-reference</primary></indexterm>anything! Although it is certainly possible in LyX,<indexterm><primary>LyX</primary></indexterm> it will not work when exported to SGML:<indexterm><primary>SGML</primary></indexterm> you will get the error</para><screen><![CDATA[xref to ANCHOR unsupported
]]></screen><para>See <xref linkend="errors-and-warnings"> for a discussion of this error. For the moment, just remember that the only cross-references that work for our purposes are cross-references to</para><itemizedlist><listitem><para>chapters, sections, subsections,<indexterm><primary>subsections</primary></indexterm> subsubsections</para></listitem><listitem><para>figures</para></listitem><listitem><para>tables</para></listitem></itemizedlist><para>but that's quite enough for cross-referencing.<indexterm><primary>cross-referencing</primary></indexterm></para><important>
<title>Always set labels!</title> 
<para> 
Labels of chapters and sections will become the HTML  filenames  of the files that contain them.  Choose them wisely and make it a habit to always create a label for your  new chapter and section as soon as you write down their titles! See <xref linkend="LyX-filenames"> for more tips on this important issue.
</para> 
</important>
<sect2 id="LyX-cross-references-mass-insertion"><title>Mass insertion of cross-references in LyX</title><para>If you have to add hundreds <indexterm><primary>hundreds</primary></indexterm>of cross-references in just one section (e.g. more than 500, as in <ulink url="http://www.karakas-online.de/EN-Book/credits-version-2.0.html">Credits for version 2.0 of the <application>PHP-Nuke</application> HOWTO</ulink>), you will soon notice that, although a single cross-reference <indexterm><primary>cross-reference</primary></indexterm>is inserted very easily in LyX <indexterm><primary>LyX</primary></indexterm>(just choose Insert-&gt;Cross-reference from the menu, then choose the label <indexterm><primary>label</primary></indexterm>of the reference you want), it becomes a real pain if you have to enter hundreds <indexterm><primary>hundreds</primary></indexterm>of them.</para><para>My solution to this was to write a script that reads a LyX <indexterm><primary>LyX</primary></indexterm>file and outputs another LyX <indexterm><primary>LyX</primary></indexterm>file that contains references to all labels of the first one. It was then easier to copy the references from the file thus created, paste them in <ulink url="http://www.karakas-online.de/EN-Book/credits-version-2.0.html">Credits for version 2.0 of the <application>PHP-Nuke</application> HOWTO</ulink> and then delete the unneeded ones, than try to insert all cross-references by hand using the LyX <indexterm><primary>LyX</primary></indexterm>menu.</para><para>The following script, call it <ulink url="lyxrefs">lyxrefs</ulink>, will print a LyX <indexterm><primary>LyX</primary></indexterm>file in standard output, containing cross-references to each and every label <indexterm><primary>label</primary></indexterm>of the LyX <indexterm><primary>LyX</primary></indexterm>file whose name was passed on the command line as argument:</para><screen><![CDATA[#!/bin/bash
]]><![CDATA[#
]]><![CDATA[
]]><![CDATA[AWK="/usr/bin/awk"
]]><![CDATA[
]]><![CDATA[function preample() {
]]><![CDATA[cat <<-EOF
]]><![CDATA[#LyX 1.2 created this file. For more info see http://www.lyx.org/
]]><![CDATA[\lyxformat 220
]]><![CDATA[\textclass article
]]><![CDATA[\language english
]]><![CDATA[\inputencoding auto
]]><![CDATA[\fontscheme default
]]><![CDATA[\graphics default
]]><![CDATA[\paperfontsize default
]]><![CDATA[\papersize Default
]]><![CDATA[\paperpackage a4
]]><![CDATA[\use_geometry 0
]]><![CDATA[\use_amsmath 0
]]><![CDATA[\use_natbib 0
]]><![CDATA[\use_numerical_citations 0
]]><![CDATA[\paperorientation portrait
]]><![CDATA[\secnumdepth 3
]]><![CDATA[\tocdepth 3
]]><![CDATA[\paragraph_separation indent
]]><![CDATA[\defskip medskip
]]><![CDATA[\quotes_language english
]]><![CDATA[\quotes_times 2
]]><![CDATA[\papercolumns 1
]]><![CDATA[\papersides 1
]]><![CDATA[\paperpagestyle default
]]><![CDATA[EOF
]]><![CDATA[}
]]><![CDATA[
]]><![CDATA[function label() {
]]><![CDATA[n=$1
]]><![CDATA[echo ""
]]><![CDATA[echo "\layout Standard"
]]><![CDATA[echo ""
]]><![CDATA[echo ""
]]><![CDATA[echo "\begin_inset LatexCommand \label{cit:$n}"
]]><![CDATA[echo ""
]]><![CDATA[echo "\end_inset"
]]><![CDATA[}
]]><![CDATA[
]]><![CDATA[preample
]]><![CDATA[
]]><![CDATA[# Output LyX commands for Chapter "All references"
]]><![CDATA[cat <<-EOF
]]><![CDATA[\layout Section
]]><![CDATA[
]]><![CDATA[All references
]]><![CDATA[
]]><![CDATA[EOF
]]><![CDATA[
]]><![CDATA[# Output all references.
]]><![CDATA[$AWK 'BEGIN {FS=" "} /\\begin_inset LatexCommand \\label{/ {gsub("label","ref");
]]><![CDATA[printf("\n%s\n\n%s%s\n\n%s\n","\\layout Standard",
]]><![CDATA["\\begin_inset LatexCommand",$3,"\\end_inset")}' $1 > all-references.tmp
]]><![CDATA[
]]><![CDATA[cat all-references.tmp
]]><![CDATA[rm all-references.tmp
]]><![CDATA[
]]><![CDATA[# Output LyX commands for Chapter "All references"
]]><![CDATA[cat <<-EOF
]]><![CDATA[\layout Section
]]><![CDATA[
]]><![CDATA[All figure references
]]><![CDATA[
]]><![CDATA[EOF
]]><![CDATA[
]]><![CDATA[# Output only the figures.
]]><![CDATA[$AWK 'BEGIN {FS=" "} /\\begin_inset LatexCommand \\label{fig-/ {gsub("label","ref");
]]><![CDATA[printf("\n%s\n\n%s%s\n\n%s\n","\\layout Standard",
]]><![CDATA["\\begin_inset LatexCommand",$3,"\\end_inset")}' $1 > fig-references.tmp
]]><![CDATA[
]]><![CDATA[cat fig-references.tmp
]]><![CDATA[rm fig-references.tmp
]]><![CDATA[
]]><![CDATA[# Output LyX commands for Chapter "All references"
]]><![CDATA[cat <<-EOF
]]><![CDATA[\layout Section
]]><![CDATA[
]]><![CDATA[All table references
]]><![CDATA[
]]><![CDATA[EOF
]]><![CDATA[
]]><![CDATA[# Output only the tables.
]]><![CDATA[$AWK 'BEGIN {FS=" "} /\\begin_inset LatexCommand \\label{tab-/ {gsub("label","ref");
]]><![CDATA[printf("\n%s\n\n%s%s\n\n%s\n","\\layout Standard",
]]><![CDATA["\\begin_inset LatexCommand",$3,"\\end_inset")}' $1 > tab-references.tmp
]]><![CDATA[
]]><![CDATA[cat tab-references.tmp
]]><![CDATA[rm tab-references.tmp
]]><![CDATA[
]]><![CDATA[echo "\the_end"
]]></screen><para>The script will even create three sections, with cross-references to all labels, all figures <indexterm><primary>figures</primary></indexterm>and all tables respectively. If you named it lyxrefs,<indexterm><primary>lyxrefs</primary></indexterm> you would call it as follows:</para><screen><![CDATA[lyxrefs some-LyX-file.lyx > refs.lyx
]]></screen><para>Then refs.lyx <indexterm><primary>refs.lyx</primary></indexterm>will contain cross-references to all labels of some-LyX-file.lyx.<indexterm><primary>some-LyX-file.lyx</primary></indexterm> You can open refs.lyx <indexterm><primary>refs.lyx</primary></indexterm>with LyX,<indexterm><primary>LyX</primary></indexterm> copy all or part of the cross-references there and paste them in some-LyX-file.lyx. The cross-references in <ulink url="http://www.karakas-online.de/EN-Book/credits-version-2.0.html">Credits for version 2.0 of the <application>PHP-Nuke</application> HOWTO</ulink> were entered this way.</para></sect2>
</sect1>
<sect1 id="LyX-images"><title>Images </title><para>You insert an image quite simply: from the menu, choose Insert--&gt;Graphics. Enter the basename <indexterm><primary>basename</primary></indexterm>of your image (this is the name without the ending), followed by the ending &ldquo;.eps&rdquo;. Example: If your image is called myimage.png, enter &ldquo;myimage.eps&rdquo; in the file field. Don't worry that LyX <indexterm><primary>LyX</primary></indexterm>cannot find your image. Don't worry that all your images are located in the images directory beneath your working directory, but you didn't enter any paths.<indexterm><primary>paths</primary></indexterm> The scripts will take care of this (see <xref linkend="explain-document-processing"> for the gory details). You just enter &ldquo;myimage.eps&rdquo;, that's all.</para><para>If you want to see figure captions <indexterm><primary>captions</primary></indexterm>and titles (and the &ldquo;alternative text&rdquo; in HTML), or if you want to be able to reference a figure, or see your figure in the &ldquo;List of Figures&rdquo; that is created automatically,<indexterm><primary>automatically</primary></indexterm> then you have to use floats.<indexterm><primary>floats</primary></indexterm> Follow the instructions exactly as given:</para><itemizedlist><listitem><para>Be sure that your cursor <indexterm><primary>cursor</primary></indexterm>is in the &ldquo;Standard&rdquo; environment.<indexterm><primary>environment</primary></indexterm></para></listitem><listitem><para>From the menu, choose Insert--&gt;Floats--&gt;Figure.</para></listitem><listitem><para>In the float, insert an image as explained previously</para></listitem><listitem><para>While the cursor <indexterm><primary>cursor</primary></indexterm>is still besides the (empty) figure box and inside the float, change the environment <indexterm><primary>environment</primary></indexterm>to &ldquo;Caption&rdquo; (<xref linkend="LyX-environments">).</para></listitem><listitem><para>Now you see the text &ldquo;Figure#:&rdquo; to the left of the image box, followed by the image box . Insert a label <indexterm><primary>label</primary></indexterm>(Insert--&gt;Label) directly after (to the right of) the image box. Through this label <indexterm><primary>label</primary></indexterm>you will be able to cross-reference <indexterm><primary>cross-reference</primary></indexterm>this figure in your document.<indexterm><primary>document</primary></indexterm> </para></listitem><listitem><para>Type the figure caption <indexterm><primary>caption</primary></indexterm>text directly after the label.<indexterm><primary>label</primary></indexterm> It will become the figure title <emphasis>and</emphasis> caption <indexterm><primary>caption</primary></indexterm>text (there is currently no way to get different texts for figure title and caption <indexterm><primary>caption</primary></indexterm>text from LyX,<indexterm><primary>LyX</primary></indexterm> although SGML <indexterm><primary>SGML</primary></indexterm>would support this. If you find an alternative, please send it to me).</para></listitem></itemizedlist><sect2 id="LyX-inline-graphics"><title>Inline graphics</title><para>I will disappoint you: there is no way to include inline <indexterm><primary>inline</primary></indexterm>graphics with the method described in this document <indexterm><primary>document</primary></indexterm>- see <xref linkend="explain-inline-graphics"> for the reason.</para><para>Well, almost...<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
<para>You have always the possibility to write SGML <indexterm><primary>SGML</primary></indexterm>in LyX:<indexterm><primary>LyX</primary></indexterm> just create an environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) of type SGML <indexterm><primary>SGML</primary></indexterm>and enter your text (in &lt;para&gt; elements), followed by </para><screen><![CDATA[]]><inlinegraphic fileref="&file1001;" format="linespecific"><![CDATA[
]]></screen><para>Substitute &ldquo;1&rdquo; with the basename <indexterm><primary>basename</primary></indexterm>of the inline <indexterm><primary>inline</primary></indexterm>graphic (i.e. the name without path <indexterm><primary>path</primary></indexterm>information and without ending). Of course all necessary formats (PNG, EPS,<indexterm><primary>EPS</primary></indexterm> PDF <indexterm><primary>PDF</primary></indexterm>and BMP) with the right density <indexterm><primary>density</primary></indexterm>settings must be available under the ./images directory, see <xref linkend="add-density">.</para><caution>
<title>Caution:</title> 
<para>
You must insert the above SGML code without introducing newline characters, which in LyX will produce <screen><![CDATA[ <para> ]]> </screen> elements when exported to SGML. Thus, for the above sentence and inline icon, you would have to enter  <screen><inlinegraphic  fileref="&file2000;" format="linespecific"></screen>
</para>
</caution>
</sect2>
</sect1>
<sect1 id="LyX-admonitions"><title>Admonitions </title><para>There is no &ldquo;Admonition&rdquo; environment <indexterm><primary>environment</primary></indexterm>in LyX,<indexterm><primary>LyX</primary></indexterm> just as there are no &ldquo;Admonitions&rdquo; in TeX/LaTeX. Admonitions <indexterm><primary>Admonitions</primary></indexterm>are a DocBook <indexterm><primary>DocBook</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>element.<indexterm><primary>element</primary></indexterm> They are those text passages which alert the reader of some important fact (see <xref linkend="conventions"> for examples). They carry titles like &ldquo;Caution!&rdquo;, &ldquo;Important!&rdquo;, &ldquo;Note&rdquo;, &ldquo;Tip&rdquo;, &ldquo;Warning!&rdquo;. There is no oher way to introduce admonitions <indexterm><primary>admonitions</primary></indexterm>in a LyX <indexterm><primary>LyX</primary></indexterm>DocBook document,<indexterm><primary>document</primary></indexterm> than by creating an SGML <indexterm><primary>SGML</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>and inserting the necessary SGML <indexterm><primary>SGML</primary></indexterm>commands there. Here is an example for &ldquo;Caution&rdquo;:</para><screen><![CDATA[<caution>
]]><![CDATA[<title>Caution</title> 
]]><![CDATA[<para> 
]]><![CDATA[You will need to repeat the above steps for each and every image you produce! 
]]><![CDATA[If you omit it, or use your own .pdf and .eps versions, most probably they 
]]><![CDATA[will FAIL to be embedded in your PDF, resp. PS document! 
]]><![CDATA[</para> 
]]><![CDATA[</caution>
]]></screen><para>which looks like this:</para><caution>
<title>Caution</title> 
<para> 
You will need to repeat the above steps for each and every image you produce! If you omit it, or use your own .pdf and .eps versions, most probably they will FAIL to be embedded in your PDF, resp. PS document! 
</para> 
</caution>
<para>Since the environment <indexterm><primary>environment</primary></indexterm>is SGML,<indexterm><primary>SGML</primary></indexterm> you can put any legal (from the DTD <indexterm><primary>DTD</primary></indexterm>point of view) SGML <indexterm><primary>SGML</primary></indexterm>tag inside &lt;caution&gt;/&lt;/caution&gt;, not only &lt;para&gt; or &lt;title&gt;. Here is a more complicated example that uses an itemized <indexterm><primary>itemized</primary></indexterm>list (through the &lt;itemizedlist&gt; tag) , this time for the &ldquo;Tip&rdquo; admonition:<indexterm><primary>admonition</primary></indexterm></para><screen><![CDATA[<tip>
]]><![CDATA[<title>Tip</title> 
]]><![CDATA[<para> 
]]><![CDATA[FYI, all changes presented here refer to variables that were 
]]><![CDATA[originally defined in one of the following files:
]]><![CDATA[<itemizedlist>
]]><![CDATA[</listitem>
]]><![CDATA[<listitem>
]]><![CDATA[<para>
]]><![CDATA[/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/html/dbparam.dsl
]]><![CDATA[</para>
]]><![CDATA[</listitem>
]]><![CDATA[<listitem>
]]><![CDATA[<para>
]]><![CDATA[/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/dbparam.dsl
]]><![CDATA[</para>
]]><![CDATA[</listitem>
]]><![CDATA[<listitem>
]]><![CDATA[<para>
]]><![CDATA[/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/db31.dsl
]]><![CDATA[</para>
]]><![CDATA[</listitem>
]]><![CDATA[</itemizedlist>
]]><![CDATA[As said above, you should not change these files directly, because 
]]><![CDATA[you will run into a lot of work when you upgrade them.
]]><![CDATA[</para>
]]><![CDATA[</tip>
]]></screen><para>It looks like this:</para><tip>
<title>Tip</title> 
<para> 
FYI, all changes presented here refer to variables that were originally defined in one of the following files:
<itemizedlist>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/html/dbparam.dsl
</para>
</listitem>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/dbparam.dsl
</para>
</listitem>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/db31.dsl</para>
</listitem>
</itemizedlist>
As said above, you should not change these files directly, because you will run into a lot of work when you upgrade them.
</para>
</tip>
<para>Another example (of a &quot;Note&quot; admonition) that makes use of a code example (though the &lt;screen&gt; tag):</para><screen><![CDATA[<note>
]]><![CDATA[<title>Please note:</title> 
]]><![CDATA[<para> 
]]><![CDATA[A file containing ]]><emphasis><![CDATA[graphical]]></emphasis><![CDATA[ callouts (see ]]><xref linkend="callouts"><![CDATA[ and ]]><xref linkend="LyX-callouts"><![CDATA[) 
]]><![CDATA[will NOT be validated! You will get an error saying
]]><![CDATA[<screen>
]]><![CDATA[document type does not allow element "IMG" here
]]><![CDATA[</screen>
]]><![CDATA[</para>
]]><![CDATA[</note>
]]></screen><para>It will look like this:</para><note>
<title>Please note:</title> 
<para> 
A file containing <emphasis>graphical</emphasis> callouts (see <xref linkend="callouts"> and <xref linkend="LyX-callouts">) will NOT be validated! You will get an error saying
<screen>
document type does not allow element "IMG" here
</screen>
</para>
</note>
</sect1>
<sect1 id="LyX-callouts"><title>Callouts </title><para>Callouts are those reverse-video <indexterm><primary>reverse-video</primary></indexterm>circled numbers <indexterm><primary>numbers</primary></indexterm>or &quot;(1)&quot;, &quot;(2)&quot;, etc. that you see appended to selected lines in some code examples, like the following:</para><screen>
baseurl={http://www.karakas-online.de/mySGML/}, <co id="Baseurl1">
pdftitle={Document processing with LyX and SGML}, <co id="Pdftitle1">
pdfsubject={Linux,document formatting}, <co id="Pdfsubject1">
pdfauthor={Copyright \textcopyright 2004, Chris Karakas}, <co id="Pdfauthor1">
pdfkeywords={Linux SGML LyX DSSSL DocBook} <co id="Pdfkeywords1">
</screen>
<calloutlist>
    <callout arearefs="Baseurl1">
       <para>
      The baseurl will be added in front of any relative WWW link that you have in your PDF document.
      </para>
    </callout>
<callout arearefs="Pdftitle1">
       <para>
      The pdftitle  will appear as the title of your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General.
      </para>
    </callout>
<callout arearefs="Pdfsubject1">
       <para>
      The   pdfsubject will appear as the subject  of your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General.
      </para>
    </callout>
<callout arearefs="Pdfauthor1">
       <para>
      The   pdfauthor  will appear as the author  of your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General. You may add copyright information as shown here.
      </para>
    </callout>
<callout arearefs="Pdfkeywords1">
       <para>
      The   pdfkeywords will appear as a list of keywords for  your PDF document in Acrobat® <application>Reader</application> under File-->Document Info-->General. Keywords are separated by blanks.
     </para>
    </callout>
</calloutlist>
<para>Just as is the case with admonitions <indexterm><primary>admonitions</primary></indexterm>(see <xref linkend="LyX-admonitions">), there is no LyX <indexterm><primary>LyX</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) for callouts <indexterm><primary>callouts</primary></indexterm>(there is no such environment <indexterm><primary>environment</primary></indexterm>for TeX/LaTeX either, which is the reason why it is absent from LyX <indexterm><primary>LyX</primary></indexterm>too). The only way to get callouts <indexterm><primary>callouts</primary></indexterm>to work with LyX <indexterm><primary>LyX</primary></indexterm>ist to create an SGML <indexterm><primary>SGML</primary></indexterm>environment<indexterm><primary>environment</primary></indexterm> and put the SGML <indexterm><primary>SGML</primary></indexterm>code there. For the example above, here is what you would have to write in the SGML<indexterm><primary>SGML</primary></indexterm> environment:<indexterm><primary>environment</primary></indexterm></para><screen><![CDATA[<screen>
]]><![CDATA[baseurl={http://www.karakas-online.de/mySGML/}, <co id="baseurl">
]]><![CDATA[pdftitle={Document processing with LyX and SGML}, <co id="pdftitle">
]]><![CDATA[pdfsubject={Linux,document formatting}, <co id="pdfsubject">
]]><![CDATA[pdfauthor={Copyright \textcopyright 2003, Chris Karakas}, <co id="pdfauthor">
]]><![CDATA[pdfkeywords={Linux SGML LyX DSSSL DocBook} <co id="pdfkeywords">
]]><![CDATA[</screen>
]]><![CDATA[<calloutlist>
]]><![CDATA[    <callout arearefs="baseurl">
]]><![CDATA[       <para>
]]><![CDATA[      The baseurl will be added in front of any relative WWW link 
]]><![CDATA[      that you have in your PDF document.
]]><![CDATA[      </para>
]]><![CDATA[    </callout>
]]><![CDATA[<callout arearefs="pdftitle">
]]><![CDATA[       <para>
]]><![CDATA[      The pdftitle  will appear as the title of your PDF document 
]]><![CDATA[      in Acrobat® <application>Reader</application> under File-->Document Info-->General.
]]><![CDATA[      </para>
]]><![CDATA[    </callout>
]]><![CDATA[<callout arearefs="pdfsubject">
]]><![CDATA[       <para>
]]><![CDATA[      The   pdfsubject will appear as the subject  of your PDF document 
]]><![CDATA[      in Acrobat® <application>Reader</application> under File-->Document Info-->General.
]]><![CDATA[      </para>
]]><![CDATA[    </callout>
]]><![CDATA[<callout arearefs="pdfauthor">
]]><![CDATA[       <para>
]]><![CDATA[      The   pdfauthor  will appear as the author  of your PDF document 
]]><![CDATA[      in Acrobat® <application>Reader</application> under File-->Document Info-->General. You may add copyright information as shown here.
]]><![CDATA[      </para>
]]><![CDATA[    </callout>
]]><![CDATA[<callout arearefs="pdfkeywords">
]]><![CDATA[       <para>
]]><![CDATA[      The   pdfkeywords will appear as a list of keywords for  your PDF document 
]]><![CDATA[      in Acrobat® <application>Reader</application> under File-->Document Info-->General. Keywords are separated by blanks.
]]><![CDATA[     </para>
]]><![CDATA[    </callout>
]]><![CDATA[</calloutlist>
]]></screen></sect1>
<sect1 id="LyX-tables"><title>Tables</title><para>For table captions <indexterm><primary>captions</primary></indexterm>and titles to be output correctly, you have to insert tables in the following way: </para><itemizedlist><listitem><para>Be sure that your cursor <indexterm><primary>cursor</primary></indexterm>is in the &ldquo;Standard&rdquo; environment <indexterm><primary>environment</primary></indexterm>(see <xref linkend="LyX-environments">).</para></listitem><listitem><para>Insert a table float (from the menu: Insert--&gt;Floats--&gt;Table)</para></listitem><listitem><para>You get a table float containing one line. Change the environment <indexterm><primary>environment</primary></indexterm>on that line to &ldquo;Caption&rdquo;.</para></listitem><listitem><para>You see the text &ldquo;Table#:&rdquo; and the cursor <indexterm><primary>cursor</primary></indexterm>is positioned immediately to the right of it. Insert a label <indexterm><primary>label</primary></indexterm>for the table (from the menu: Insert--&gt;Label).</para></listitem><listitem><para>After the label,<indexterm><primary>label</primary></indexterm> on the same one line: type the table title and press &lt;enter&gt;. This will produce a &lt;para&gt; element <indexterm><primary>element</primary></indexterm>we will eliminate <indexterm><primary>eliminate</primary></indexterm>in <ulink url="sedscr">sedscr</ulink> (see <xref linkend="explain-runsed-sed-sedscr">).</para></listitem><listitem><para>On the new line, insert your table as usual.</para></listitem></itemizedlist><para>A warning about an &quot;end tag for element <indexterm><primary>element</primary></indexterm>&quot;TABLE&quot; which is not open&quot;, when processing <indexterm><primary>processing</primary></indexterm>the SGML <indexterm><primary>SGML</primary></indexterm>file with Jade,<indexterm><primary>Jade</primary></indexterm> is the less evil we can get (see <xref linkend="errors-and-warnings">) and is harmless (probably caused by a LyX <indexterm><primary>LyX</primary></indexterm>bug in version 1.2.0).</para><para>A LyX <indexterm><primary>LyX</primary></indexterm>related concern is that text within a cell will not wrap to fit the page, so if a line of text in a table is too long, the table will extend beyond the right margin of the page. Similarly, LyX's table inset will not split itself at the bottom of a page, and so might extend below the bottom margin. You have these options to resolve this problem (taken from the LyX <indexterm><primary>LyX</primary></indexterm>User's Guide):</para><orderedlist><listitem><para>Split it into two tables, to correctly handle pagebreaks <indexterm><primary>pagebreaks</primary></indexterm>and margins.</para></listitem><listitem><para>Select the Longtable button in the Table&nbsp;Layout dialog. This automatically <indexterm><primary>automatically</primary></indexterm>splits <indexterm><primary>splits</primary></indexterm>the table over more pages, if it is too high. After doing this, the list of Longtable buttons activate themselves and you may now define:</para><orderedlist><listitem><para>FirstHead: The current row and all rows above that don't have any special options defined, are defined to be the header-lines of the first page of the multipage-table.</para></listitem><listitem><para>Head: The current row and all rows above that don't have any special options defined, are defined to be the header-lines of all pages of the multipage-table<indexterm><primary>multipage-table</primary></indexterm> except for the first page if FirstHead is defined.</para></listitem><listitem><para>Foot: The current row and all rows above that don't have any special options defined, are defined to be the footer-lines of all pages of the multipage-table<indexterm><primary>multipage-table</primary></indexterm> except for the last page if LastFoot is defined.</para></listitem><listitem><para>LastFoot: The current row and all rows above that don't have any special options defined, are defined to be the footer-lines of the last page of the multipage-table.</para></listitem><listitem><para>NewPage: This forces a pagebreak after the row where this flag is defined.</para></listitem></orderedlist><para>If you define more flags in the same table row, you should be aware of the fact that only the first flag is used in the defined table rows. The others will the be defined as <emphasis>empty</emphasis>. In this context, first means first in this order: Foot, LastFoot,<indexterm><primary>LastFoot</primary></indexterm> Head, FirstHead.<emphasis> </emphasis>See the <indexterm><primary>typewriter</primary></indexterm>TableExamples.lyx example file to see how this works.<emphasis> </emphasis></para></listitem><listitem><para>Use the Width entry in the Table&nbsp;Layout dialog to restrict the width of the table till it fits horizontally.</para></listitem><listitem><para>A table can also be placed in a float, as described below, which will allow <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>to place it as well as it can within the page.</para></listitem></orderedlist><para>One&nbsp;last&nbsp;remark: Longtable and Rotate&nbsp;90° use special <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>packages, so you should look into LaTeX&nbsp;configuration in the Help menu to see if your system supports these features.</para></sect1>
<sect1 id="LyX-table-of-contents"><title>Table of contents </title><para>LyX <indexterm><primary>LyX</primary></indexterm>provides its own command for the creation of a Table of Contents (from the menu: Insert--&gt;Lists&amp;TOC--&gt;Table of Contents) - <emphasis>but you should not use it!</emphasis> Whether a table of contents will be created or not is entirely controlled by the stylesheets (see <xref linkend="DSSSL-stylesheets"> and <xref linkend="explain-DSSSL-stylesheets">). For example, the following code in a stylesheet <indexterm><primary>stylesheet</primary></indexterm>specifies that a Table of Contents has to be created for document <indexterm><primary>document</primary></indexterm>type &ldquo;Article&rdquo;:</para><screen><![CDATA[(define %generate-article-toc%
]]><![CDATA[  ;; Should a Table of Contents be produced for Articles?
]]><![CDATA[  #t)
]]></screen></sect1>
<sect1 id="LyX-list-of-figures"><title>List of figures, tables and equations </title><para>A list of figures <indexterm><primary>figures</primary></indexterm>is created automatically <indexterm><primary>automatically</primary></indexterm>for the document <indexterm><primary>document</primary></indexterm>type &ldquo; DocBook <indexterm><primary>DocBook</primary></indexterm>book SGML<indexterm><primary>SGML</primary></indexterm>&rdquo;. You don't need to undertake anything here. The same is true for lists of tables and equations.<indexterm><primary>equations</primary></indexterm> This is true as long as you use the DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets (that form part of DocBook,<indexterm><primary>DocBook</primary></indexterm> see<xref linkend="DocBook">) with their default settings. In case you don't get a list, when you think you should, read in <xref linkend="explain-DSSSL-stylesheets"> about the generate-book-lot-list stylesheet <indexterm><primary>stylesheet</primary></indexterm>parameter.</para></sect1>
<sect1 id="epigraphs"><title>Epigraphs</title><para>An <ulink url="http://www.oreilly.com/catalog/docbook/chapter/book/epigraph.html">epigraph</ulink> is a short inscription at the beginning of a document <indexterm><primary>document</primary></indexterm>or component. LyX <indexterm><primary>LyX</primary></indexterm>only provides the &ldquo;Quotation&rdquo; environment,<indexterm><primary>environment</primary></indexterm> which is mapped onto the <ulink url="http://www.oreilly.com/catalog/docbook/chapter/book/blockquote.html">blockquote</ulink> SGML <indexterm><primary>SGML</primary></indexterm>element,<indexterm><primary>element</primary></indexterm> when exported. For an epigraph <indexterm><primary>epigraph</primary></indexterm>as such, there is no provision (as is the case with all SGML <indexterm><primary>SGML</primary></indexterm>tags that do not have a clear correspondence to TeX/LaTeX environments<indexterm><primary>environments</primary></indexterm> - see <xref linkend="LyX-environments"> for the notion of an environment <indexterm><primary>environment</primary></indexterm>in LyX). </para><para>However, you can always define an SGML environment and write the necessary SGML tags there. For an epigraph, you would then write for Norm's favourite quote:<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<screen><![CDATA[<epigraph>
]]><![CDATA[<attribution>William Safire</attribution>
]]><![CDATA[<para>
]]><![CDATA[Knowing how things work is the basis for appreciation, and is
]]><![CDATA[thus a source of civilized delight.
]]><![CDATA[</para>
]]><![CDATA[</epigraph>
]]></screen><para>See <xref linkend="explain-magic"> for how the end result looks like.</para></sect1>
<sect1 id="LyX-SGML-code"><title>SGML code in program listings</title><para>If you want to write <emphasis>executable</emphasis> SGML <indexterm><primary>SGML</primary></indexterm>code in LyX,<indexterm><primary>LyX</primary></indexterm> e.g. to implement an admonition <indexterm><primary>admonition</primary></indexterm>(see <xref linkend="LyX-admonitions">) or a callout (see <xref linkend="LyX-callouts">), there is no problem: just create an environment <indexterm><primary>environment</primary></indexterm>of type &ldquo;SGML&rdquo; and enter your code there. It will be part of the exported SGML <indexterm><primary>SGML</primary></indexterm>file.</para><para>But if you want to give some <emphasis>example</emphasis> SGML <indexterm><primary>SGML</primary></indexterm>code, like in a program listing, then it might be a better idea to move the code in a separate file and include that file per reference. This is because if the SGML <indexterm><primary>SGML</primary></indexterm>code contains &ldquo;&lt;![CDATA[&rdquo; and &ldquo;]]&gt;&rdquo;, it is likely to interefere with the normal SGML <indexterm><primary>SGML</primary></indexterm>processing,<indexterm><primary>processing</primary></indexterm> causing errors like the following:</para><screen><![CDATA[/usr/bin/openjade:<OSFD>0:382:323:E: marked section end not in marked section declaration
]]></screen><para>To include a file, choose from the menu Insert--&gt;Include file. In the dialog box, choose &ldquo;Verbatim&rdquo; and enter the file name. The file should best be located in the same directory as the SGML <indexterm><primary>SGML</primary></indexterm>file exported from LyX <indexterm><primary>LyX</primary></indexterm>(but need not necessarily to).</para><para>LyX <indexterm><primary>LyX</primary></indexterm>will use the &ldquo;inlinegraphic&rdquo; SGML <indexterm><primary>SGML</primary></indexterm>tag to include the file. This will collide with inline <indexterm><primary>inline</primary></indexterm>graphics, if you want to include them using this method too (see <xref linkend="LyX-inline-graphics"> and <xref linkend="explain-inline-graphics">).</para></sect1>
<sect1 id="LyX-filenames"><title>Filenames</title><para>It would be nice to have a &ldquo;Filename&rdquo; environment <indexterm><primary>environment</primary></indexterm>for DocBook <indexterm><primary>DocBook</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>articles or books in LyX,<indexterm><primary>LyX</primary></indexterm> it would make computer documentation much nicer. But I was unable to find one, or a workaround <indexterm><primary>workaround</primary></indexterm>to it. If you find a way, please let me know. Of course, a poor man's solution could be to mark <indexterm><primary>mark</primary></indexterm>a filename with the &ldquo;!&rdquo; button, making it part of an &lt;emphasis&gt; tag, which would then appear in italics. But this contradicts the very idea of SGML <indexterm><primary>SGML</primary></indexterm>- separation <indexterm><primary>separation</primary></indexterm>of content from formatting.<indexterm><primary>formatting</primary></indexterm></para><sect2 id="labels-as-filenames"><title>Labels as filenames</title><para>You should always put a label <indexterm><primary>label</primary></indexterm>after the chapter/section/subsection/subsubsection title (from the LyX <indexterm><primary>LyX</primary></indexterm>menu: Insert--&gt;Label). The text you use for the label <indexterm><primary>label</primary></indexterm>will become the name of the HTML <indexterm><primary>HTML</primary></indexterm>file that contains that chapter/section etc. See <xref linkend="explain-DSSSL-stylesheets"> for the code that controls this setting in the stylesheets (it is the <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/html/use-id-as-filename.html">use-id-as-filename DSSSL parameter.</ulink> that does this).</para><tip>
<title>SEO (Search Engine Optimization) tips</title>
<para>
There is circumstancial evidence that the search engines (especially <ulink url="http://www.google.com">Google</ulink>) weigh substantially the keywords that appear between &lt;H1&gt;, &lt;H2&gt;, &lt;H3&gt; tags (that's the chapter's and sections' titles) especially if they also appear as part of the HTML filename. You are thus well advised to follow some simple rules for your titles (er...filenames<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject>):
<itemizedlist>
<listitem>
<para>
Always create a label. Failing to do so, will produce and automatic, nothing-saying filename. You loose a potential (although small) ranking boost from the search engines, if your section is about, say, blue widgets, but is called x543.html, instead of blue-widgets.html.
</para>
</listitem>
<listitem>
<para>
The label should contain the same text as the title. The title you enter in LyX will automatically be the HTML title in the header part of the resulting HTML file (this is a meta-information, not visible to you, but very well visible to the search engines), as well as the title inside the &lt;H1&gt;, &lt;H2&gt;, or &lt;H3&gt; tag that is produced  in the HTML body  automatically as well. If the label is similar to the title, then the HTML filename will be similar  to the titles (meta-title and actual text title) of the text inside it. This wil be rewarded with  more weight in the search engine ranking, resulting in a higher place in the SERPS (Search Engine Result Pages). And believe me,  even if you hate search engines, it is much easier to find a chapter by reading "talking" filenames, like blue-widgets.html, than cryptic ones like x543.html!
</para>
</listitem>
<listitem>
<para>
Dont'use blanks. Use hyphen &ldquo;-&rdquo; instead. This makes use of the fact that for most search engines &ldquo;-&rdquo; is equivalent to a blank. This is not the case for underscore &ldquo;_&rdquo;.
</para>
</listitem>
<listitem>
<para>
Don't use illegal characters, i.e. characters that are not allowed in HTML filenames.
</para>
</listitem>
</itemizedlist>
</para>
</tip>
</sect2>
<sect2 id="cool-labels-dont-change"><title>Cool labels don't change!</title><para>There is one thing to keep in mind when regrouping:<indexterm><primary>regrouping</primary></indexterm> chapter and section labels - DON'T change existing ones! You may change their position, but please not the label.<indexterm><primary>label</primary></indexterm> Subsection <indexterm><primary>Subsection</primary></indexterm>and subsubsection <indexterm><primary>subsubsection</primary></indexterm>labels can be changed without problem.</para><para>Why? Because chapters and sections will become separate HTML <indexterm><primary>HTML</primary></indexterm>documents. There is a DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet setting which controls how deep a level will still produce a separate HTML <indexterm><primary>HTML</primary></indexterm>document (see the decription of chunk-section-depth in <xref linkend="explain-DSSSL-stylesheets">). The name of the documents will be the label <indexterm><primary>label</primary></indexterm>of the chapter and section respectively. This is a behaviour <indexterm><primary>behaviour</primary></indexterm>we explicitly set in the DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets (see <xref linkend="explain-DSSSL-stylesheets">) through the <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/html/use-id-as-filename.html">use-id-as-filename DSSSL parameter.</ulink>. </para><para>Obviously, you can move a section around, without affecting the HTML <indexterm><primary>HTML</primary></indexterm>name of the resulting file, if you don't change its label.<indexterm><primary>label</primary></indexterm> You can of course change its contents, put it somewhere else as a section of a different chapter etc., but you should leave the label <indexterm><primary>label</primary></indexterm>untouched.</para><para>The problem is that, if the document <indexterm><primary>document</primary></indexterm>is already on the Web <indexterm><primary>Web</primary></indexterm>and is receiving a lot of visits, most of them (experience suggests a number around two-thirds of the total number of visits) will be from search engines. If you change the section label,<indexterm><primary>label</primary></indexterm> the HTML <indexterm><primary>HTML</primary></indexterm>name changes. Consequently, the link from the search engines is no longer valid. The same is true for private bookmarks,<indexterm><primary>bookmarks</primary></indexterm> or public bookmark lists.</para><para>But there is more to it: it's not only a matter of waiting 2-3 weeks for the new HTML document that contains the old (a bit reorganized) content to be indexed by the search engines. It's that the old name might have been at page 1 of the SERPS (Search Engine Result Pages) of some search engine for some keyword, because a lot of other people linked to it. Now, with a changed label and, consequently, a new HTML file name, those links do not reference the new document, and it gets a ranking close to "nowhere" (because search engines, notably Google, take links to a document to mean "votes" for that document and rank that document accordingly). The result: nobody finds it. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_frown.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_frown.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_frown.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_frown.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<note>
<title>It's not a question of sacrificing quality!</title>
<para>
I am not trying to tie up your hands in favour of a higher search engine ranking here! This discussion is not one of quality vs. ranking, but one of consistency. All I am advocating is: keep your labels (and consequently your filenames) consistent between various releases of your document! Once you have chosen a label for a chapter of section, stick with it. 
</para>
<para>
Please also note that we are not talking about the title of a chapter or section, but its label. "Label" is LyXese for  the "SGML id". You get a label from the "Insert -> Label" menu of LyX. Don't confuse title and label in this discussion!  
</para>
</note>
<para>For example, suppose a chapter with the title &ldquo;Blue widgets<indexterm><primary>widgets</primary></indexterm>&rdquo; is at around place 6 out of 2,5 million (!) for &quot;blue widgets&quot; on Google.<indexterm><primary>Google</primary></indexterm> If you change the label <indexterm><primary>label</primary></indexterm>of the chapter from &quot;blue-widgets&quot;<indexterm><primary>blue-widgets</primary></indexterm> to something else, then the original URI <indexterm><primary>URI</primary></indexterm>will disappear and you loose readers. Of course, changing the title also affects the SERPS <indexterm><primary>SERPS</primary></indexterm>(Search Engine Result Pages), but not as drastically as to eliminate <indexterm><primary>eliminate</primary></indexterm>the document <indexterm><primary>document</primary></indexterm>altogether. However, Google <indexterm><primary>Google</primary></indexterm>likes a title that is correlated <indexterm><primary>correlated</primary></indexterm>to the file name, so a title &quot;Blue widgets&quot; and a label <indexterm><primary>label</primary></indexterm>&quot;blue-widgets&quot; are optimal from the SEO<indexterm><primary>SEO</primary></indexterm> (Search Engine Optimization) point of view (see <xref linkend="labels-as-filenames">).</para><para>&ldquo;But you are talking me into subjecting my writing to the whims of a search engine!&rdquo;, you might counter. Nothing more far away than that! The point is not to restrict your writing. The point is: you write whatever you like, however you like and structure it as you please. There are rules <indexterm><primary>rules</primary></indexterm>for good writing that you might choose to observe, or not. There are also rules <indexterm><primary>rules</primary></indexterm>for good &ldquo;copy&rdquo; , from the point of view of keywords,<indexterm><primary>keywords</primary></indexterm> search engines and ranking <indexterm><primary>ranking</primary></indexterm>- which you are also free to observe or defy. </para><para>Then, at some point, you decide to put the document <indexterm><primary>document</primary></indexterm>on the web. People will come, read it and, hopefully, find it good. Those people may like your document <indexterm><primary>document</primary></indexterm>so much, as to go into the trouble to say something like &quot;there's a cool document <indexterm><primary>document</primary></indexterm>on blue widgets <indexterm><primary>widgets</primary></indexterm>in this link here&quot; - and link to it. Hundreds of people may do this perhaps - even thousands. Imagine the effort!</para><para>Now you come up with a new restructuring of you document <indexterm><primary>document</primary></indexterm>- fine! You change the content - also fine! Then you change the label <indexterm><primary>label</primary></indexterm>from: </para><screen><![CDATA[<sect1 id="blue-widgets"><title>Blue widgets</title>
]]></screen><para>to:</para><screen><![CDATA[<sect1 id="blue-widgets-2"><title>Blue widgets revisited</title>
]]></screen><para>In LyX,<indexterm><primary>LyX</primary></indexterm> this is equivalent to changing the title from &ldquo;Blue widgets<indexterm><primary>widgets</primary></indexterm>&rdquo; to &ldquo;Blue widgets <indexterm><primary>widgets</primary></indexterm>revisited&rdquo; and the label <indexterm><primary>label</primary></indexterm>from &ldquo;blue-widgets&rdquo; to &ldquo;blue-widgets-2&rdquo;. Perhaps you thought it would be a nice idea to change the title to reflect the reorganization.<indexterm><primary>reorganization</primary></indexterm> This will affect your ranking <indexterm><primary>ranking</primary></indexterm>too, but then, almost everything that you write will affect it, so we will not discuss it here. (Actually, it will affect it a little more because it's on the title - but that's again not the point.). </para><para>But by changing that label <indexterm><primary>label</primary></indexterm>from &ldquo;blue-widgets&rdquo; to &ldquo;blue-widgets-2&rdquo; you just managed to throw your document <indexterm><primary>document</primary></indexterm>from place 6 to place 600 (or 6000, or...) in the SERPS.<indexterm><primary>SERPS</primary></indexterm> You just killed all the efforts of thousands of people that linked to your document!</para><para>Why? </para><para>Because labels become filenames in the document <indexterm><primary>document</primary></indexterm>process from SGML <indexterm><primary>SGML</primary></indexterm>to HTML<indexterm><primary>HTML</primary></indexterm> (see <xref linkend="explain-magic"> for a detailed explanation of this process). The document <indexterm><primary>document</primary></indexterm>that would be blue-widgets.<indexterm><primary>blue-widgets</primary></indexterm>html now is blue-widgets-2.html. The original blue-widgets.<indexterm><primary>blue-widgets</primary></indexterm>html is nowhere to be found in your domain - hundreds,<indexterm><primary>hundreds</primary></indexterm> or even thousands of links on the Web <indexterm><primary>Web</primary></indexterm>now point to vacuum!</para><para>Google <indexterm><primary>Google</primary></indexterm>- and every other search engine - sees this and takes the old URL<indexterm><primary>URL</primary></indexterm> out of the index. Of course, it indexes the new one. But the new one does not have any links pointing to it - not yet. And perhaps people will not be willing to go into the trouble of changing all their documents, just because you wanted to keep your freedom of choosing (and changing!) the label <indexterm><primary>label</primary></indexterm>(and the resulting HTML <indexterm><primary>HTML</primary></indexterm>filename) at your whim. Thus, noone points to the new &quot;reorganized&quot;<indexterm><primary>reorganized</primary></indexterm> document.<indexterm><primary>document</primary></indexterm> It is rated very low and appears at place...uhmm 1 million something, out of 2,5 million results for &quot;blue widgets&quot;, where nobody will find it and nobody will read it. Remember, the original document <indexterm><primary>document</primary></indexterm>ranked at place 6 out of 2,5 million!</para><para>You might think that, since the label-to-filename <indexterm><primary>label-to-filename</primary></indexterm>connection exists only for the &ldquo;chunked&rdquo; version (the version where openjade <indexterm><primary>openjade</primary></indexterm>is instructed to split the document<indexterm><primary>document</primary></indexterm> into separate HTML <indexterm><primary>HTML</primary></indexterm>files, one per chapter or section, the so-called &ldquo;chunks&rdquo;, as explained in <xref linkend="explain-document-creation-HTML">), the &ldquo;unchunked&rdquo; document <indexterm><primary>document</primary></indexterm>will save you from this disaster. You are correct, the &quot;single chunk <indexterm><primary>chunk</primary></indexterm>documents&quot; (single, big HTML <indexterm><primary>HTML</primary></indexterm>file, TXT,<indexterm><primary>TXT</primary></indexterm> PDF <indexterm><primary>PDF</primary></indexterm>or PS <indexterm><primary>PS</primary></indexterm>versions) will not be affected . </para><para>If you only make the big HTML <indexterm><primary>HTML</primary></indexterm>file, or the TXT,<indexterm><primary>TXT</primary></indexterm> PDF <indexterm><primary>PDF</primary></indexterm>and PS <indexterm><primary>PS</primary></indexterm>versions of your document <indexterm><primary>document</primary></indexterm>available on the web, then you are not affected. But if you also made the chunked <indexterm><primary>chunked</primary></indexterm>HTML <indexterm><primary>HTML</primary></indexterm>version available at some point, the search engines will prefer to return results from this version, than from the others. </para><para>There are various reasons for this, one of them being that search engines don't read a document <indexterm><primary>document</primary></indexterm>that is too long till the end and will thus index small chunks <indexterm><primary>chunks</primary></indexterm>much better than huge textst. Another reason is that you need more links to a PDF <indexterm><primary>PDF</primary></indexterm>document, to force a search engine to consider it important for indexing.<indexterm><primary>indexing</primary></indexterm></para><para>So forget about the huge, one-chunk <indexterm><primary>one-chunk</primary></indexterm>docs as a search engine strategy.<indexterm><primary>strategy</primary></indexterm> If you want to be found by the SEs, you must rely on the chunked <indexterm><primary>chunked</primary></indexterm>versions - and perhaps a little on PDF,<indexterm><primary>PDF</primary></indexterm> but only a little.</para><para>However, my point goes even further: we are not talking about a user who is searching for a unique, multiple keyword <indexterm><primary>keyword</primary></indexterm>phrase that identifies the content of your reorganized <indexterm><primary>reorganized</primary></indexterm>document. We are talking about a user who just searches for, two keywords:<indexterm><primary>keywords</primary></indexterm> &ldquo;blue widgets<indexterm><primary>widgets</primary></indexterm>&rdquo;. If you change the label,<indexterm><primary>label</primary></indexterm> you change the filename of the chunked <indexterm><primary>chunked</primary></indexterm>version. If you do so, the search engine will NOT think &quot;Ahh...the file blue-widgets.<indexterm><primary>blue-widgets</primary></indexterm>html is not there, let's present the huge document <indexterm><primary>document</primary></indexterm>that contains all chapters, including the one on blue widgets <indexterm><primary>widgets</primary></indexterm>- at the same ranking <indexterm><primary>ranking</primary></indexterm>place&quot;! There are three resons that this will not happen - and you should not rely on it:</para><orderedlist><listitem><para>First, the search engine does not know that blue-widgets.<indexterm><primary>blue-widgets</primary></indexterm>html is just a chunk <indexterm><primary>chunk</primary></indexterm>of some &quot;whole&quot; document,<indexterm><primary>document</primary></indexterm> book1.html. There is nothing that a search engine does to find this out - not with today's technology.<indexterm><primary>technology</primary></indexterm> The two documents are different from the search engine point of view.</para></listitem><listitem><para>Second, the big one, book1.html, contains much more text, therefore the importance of the &quot;blue widgets&quot; chapter is &quot;diluted&quot; from the surrounding, irrelevant text (irrelevant to what the user is searching with those keywords,<indexterm><primary>keywords</primary></indexterm> namely &quot;blue widgets&quot;). This has to do with &ldquo; keyword <indexterm><primary>keyword</primary></indexterm>density<indexterm><primary>density</primary></indexterm>&rdquo;, titles, structure and other &ldquo;on-page&rdquo; factors that the search engine calculates and takes into account for each page. Therefore, the document <indexterm><primary>document</primary></indexterm>will rank at a place that is way back - invisible to all but the most determined searchers, practically dead.</para></listitem><listitem><para>Third, if you are a HOWTO author, you may put your document <indexterm><primary>document</primary></indexterm>on <ulink url="http://www.tldp.org">The <productname>Linux</productname> Documentation Project</ulink>, which is a great place with good exposure <indexterm><primary>exposure</primary></indexterm>to the Web,<indexterm><primary>Web</primary></indexterm> but that alone does not guarantee good ranking.<indexterm><primary>ranking</primary></indexterm> What is also important, is that people <emphasis>link</emphasis> to it. But if you change an existing label,<indexterm><primary>label</primary></indexterm> thus changing the filename of the chunked <indexterm><primary>chunked</primary></indexterm>version (which is the most important one from the search engine point of view for the reasons stated above), then you kill all the links to the previous URL.<indexterm><primary>URL</primary></indexterm> You destroy what you were able to gather up to that point in terms <indexterm><primary>terms</primary></indexterm>of search engine visibility.<indexterm><primary>visibility</primary></indexterm> You start anew. </para></listitem></orderedlist><tip>
<title>Use permanent redirects, if you do choose to change the label!</title> 
<para> 
Let me put a preemtive disclaimer here: I know that you can put a "HTML permanent redirect" in your .htaccess file to indicate that the resource is now somewhere else, under a different name. But this makes URL management difficult  for a webmaster. How on earth shall the webmaster  know which labels some author,  whose document he hosts on his website, changed in his last reorganization? Is he supposed to do nothing else a whole day, other than chasing diff outputs and editing .htaccess files? Just because the author wants to keep his freedom of changing labels at his whim? Remember, if it is a free document, it will find its way to other people's websites. People may link to files of those websites containing your document, even more often than they do to yours. When you release a new version with changed labels (and accordingly, filenames), do you send a list of changed labels to all those webmasters who host it, with the request to update their .htaccess files?
</para> 
<para>
Certainly not.
</para>
<para>
Nevertheless, if you are the author and have decided to change the label of some chapter or section, don't let your web server send an "Error 404: not found" for the old URI. Let it send a &ldquo;permanent redirect&rdquo; instead. See <ulink url="http://www.w3.org/QA/Tips/uri-manage">Managing URIs</ulink> and the links therein, for the preferred ways to handle this situation. 
</para>
<para>
But again, a redirect has to be in your .htaccess file (or web conf file) until the last request has been seen in your web logs for the old URI (theoretically, at least, otherwise you loose the visitor). How long is this? One year? Ten years? How big does your .htaccess become if an author starts "reorganizing" his labels(!) every other week? How much of a performance penalty will you have to pay for your web server having to read and process huge .htaccess files on every page request?
</para>
<para>
Thus, every redirect will hurt you, either in terms of visibility in the SERPS, or in terms of complexity, or both. But if you change a label, don't forget the permanent redirect. 
</para>
</tip>
<para>For the above reasons, most of the time, you will not feel the need to change labels while reorganizing, but think doubly about it if you must. Your best bet is to choose a label <indexterm><primary>label</primary></indexterm>wisely (for the same reasons that you would <ulink url="http://www.w3.org/QA/Tips/uri-choose">Choose URIs wisely</ulink>), perhaps with a name that is a bit more general than you might wish, but will still fit if you choose to change content, or even title, later on. </para><para><ulink url="http://www.w3.org/Provider/Style/URI.html">Cool URIs don't change</ulink>. Cool labels don't change either. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_cool.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_cool.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_cool.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_cool.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
</sect2>
</sect1>
<sect1 id="LyX-examples"><title>Examples</title><para>There is no &ldquo;Example&rdquo; environment <indexterm><primary>environment</primary></indexterm>in LyX <indexterm><primary>LyX</primary></indexterm>for document <indexterm><primary>document</primary></indexterm>types of DocBook <indexterm><primary>DocBook</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>book/article. You could certainly &ldquo;simulate&rdquo; it with a pure SGML <indexterm><primary>SGML</primary></indexterm>environment,<indexterm><primary>environment</primary></indexterm> just as we did it for admonitions <indexterm><primary>admonitions</primary></indexterm>(<xref linkend="LyX-admonitions">) and callouts <indexterm><primary>callouts</primary></indexterm>(<xref linkend="LyX-callouts">), but I will not pursue this further here.</para></sect1>
<sect1 id="LyX-Mathematics"><title>Mathematics</title><para>You write Mathematics <indexterm><primary>Mathematics</primary></indexterm>in LyX <indexterm><primary>LyX</primary></indexterm>the usual way (see, for example, the Tutorial and the User's Guide that come with LyX). There is absolutely nothing special you have to take care of. Here is an example:</para><para>
<equation id="eq1"> <title>(eq1)</title>
  <alt>\[
\sum _{n=1}^{\infty }\frac{x^{n}}{n}=\ln \left(\frac{1}{1-x}\right)\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/12208.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/12208.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/12208.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/12208.bmp">
 ]]>

 </equation></para><para>Whatever you type in math,<indexterm><primary>math</primary></indexterm> it will be typeset by <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>and be available in all formats - HTML,<indexterm><primary>HTML</primary></indexterm> PDF,<indexterm><primary>PDF</primary></indexterm> PS <indexterm><primary>PS</primary></indexterm><emphasis>and</emphasis> RTF! Isn't it great? </para><para>You should nevertheless read <xref linkend="DBTeXMath"> to ensure that you installed the necessary software for math <indexterm><primary>math</primary></indexterm>processing<indexterm><primary>processing</primary></indexterm> and <xref linkend="mathematics"> to get an idea of what is going on in the background.<indexterm><primary>background</primary></indexterm> There are more Mathematics <indexterm><primary>Mathematics</primary></indexterm>examples for LyX <indexterm><primary>LyX</primary></indexterm>in <xref linkend="LyX-writing-Mathematics">, where the subject is discussed in more details.</para></sect1>
<sect1 id="LyX-Appendix"><title>Appendix</title><para>LyX <indexterm><primary>LyX</primary></indexterm>offers the possibility to mark <indexterm><primary>mark</primary></indexterm>a part of the document <indexterm><primary>document</primary></indexterm>as being the Appendix: from the top menu, choose Layout -&gt; Start Appendix here. Unfortunately, this will not work when the document <indexterm><primary>document</primary></indexterm>is exported to SGML.<indexterm><primary>SGML</primary></indexterm> We are thus left alone and have to implement a workaround.<indexterm><primary>workaround</primary></indexterm> I have implemented the following solution:</para><itemizedlist><listitem><para>The writer provides an extra LyX <indexterm><primary>LyX</primary></indexterm>file, with the fixed name &ldquo;appendix.lyx&rdquo;, in the same directory as the main document.<indexterm><primary>document</primary></indexterm></para></listitem><listitem><para>The appendix.<indexterm><primary>appendix</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>file must be of type &ldquo; DocBook <indexterm><primary>DocBook</primary></indexterm>article (SGML)&rdquo;, to be chosen from the LyX <indexterm><primary>LyX</primary></indexterm>menu: Layout -&gt; Document. A document <indexterm><primary>document</primary></indexterm>type of &ldquo; DocBook <indexterm><primary>DocBook</primary></indexterm>book (SGML)&rdquo; will NOT work, even if the main document <indexterm><primary>document</primary></indexterm>is of book type! This is because if you set the document <indexterm><primary>document</primary></indexterm>type to book, you will have to start with Chapters (instead of Sections) and then you will get parsing errors from openjade<indexterm><primary>openjade</primary></indexterm> saying that CHAPTER is not allowed by the DTD <indexterm><primary>DTD</primary></indexterm>at that place.</para></listitem><listitem><para>The appendix <indexterm><primary>appendix</primary></indexterm>is marked as such, using LyX' menu: Layout -&gt; Start Appendix here, with the cursor <indexterm><primary>cursor</primary></indexterm>at the very start of the Appendix.</para></listitem></itemizedlist><para>That's all! The <ulink url="lyxtox">lyxtox</ulink> script will check if a file called appendix.<indexterm><primary>appendix</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>is there and will take the aproppriate steps to incorporate it into the document <indexterm><primary>document</primary></indexterm>(see <xref linkend="explain-appendix">).</para><tip>
<title>How to insert cross-references to the Appendix</title> 
<para> 
To insert a cross-reference to the Appendix (more precisely to a section, subsection, subsubsection, table, figure or equation in the Appendix), you use the same mechanism in LyX, as you would do for cross-references to labels that exist in a separate file: from the Insert menu, choose "Label", then, from the drop-down list for "Buffer", choose the appendix.lyx file (which you should have already opened in LyX). LyX will then present you with all available labels from the appendix.lyx file to choose for your cross-reference.
</para> 
</tip>
</sect1>
<sect1 id="LyX-Bibliography"><title>Bibliography</title><para>So you want to use LyX to process citations and include a reference list at the end of your document? And all this in SGML? You are at the right place! <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<para>To begin with, here is just a test citation:<indexterm><primary>citation</primary></indexterm><indexterm><primary>citation:</primary></indexterm> 
<citation role="REFDB"><xref linkend="IDKARAKAS1991X"></citation>
. And another one: 
<citation role="REFDB"><xref linkend="IDKARAKAS1992X"></citation>
. Take the time to examine them and their formatting <indexterm><primary>formatting</primary></indexterm>in the version (HTML, PDF,<indexterm><primary>PDF</primary></indexterm> PS,<indexterm><primary>PS</primary></indexterm> RDF or TXT) you are currently reading.</para><sect2 id="LyX-Bibliography-without-RefDB"><title>Bibliography without RefDB</title><para>As stated in <xref linkend="Refdb">, you are not confined to using <ulink url="http://refdb.sourceforge.net">RefDB</ulink> whith my <ulink url="lyxtox">lyxtox</ulink> script. If you don't feel like building your own bibliographic <indexterm><primary>bibliographic</primary></indexterm>database, you can just supply a bibliography.<indexterm><primary>bibliography</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm> file together with your LyX <indexterm><primary>LyX</primary></indexterm>document. Set the process_RefDB variable in <ulink url="lyxtox">lyxtox</ulink> to &quot;0&quot; and it will use your own bibliography.<indexterm><primary>bibliography</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>to produce a bibliography.<indexterm><primary>bibliography</primary></indexterm>sgml file, instead of trying to create one automatically <indexterm><primary>automatically</primary></indexterm>through RefDB.<indexterm><primary>RefDB</primary></indexterm>  The bibliography.<indexterm><primary>bibliography</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>file should then contain the SGML <indexterm><primary>SGML</primary></indexterm>code for the references list, in the SGML <indexterm><primary>SGML</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>of LyX.<indexterm><primary>LyX</primary></indexterm> The <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/">GNU/Linux Command-Line Tools Summary HOWTO</ulink> uses this approach,<indexterm><primary>approach</primary></indexterm> for example.</para><para>This means that if you don't want to use RefDB,<indexterm><primary>RefDB</primary></indexterm> but still want to have a bibliography, your bibliography.<indexterm><primary>bibliography</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>file should look like:</para><screen><![CDATA[<bibliography id="references" title="References"> 
]]><![CDATA[<bibliodiv>
]]><![CDATA[<biblioentry xreflabel="KARAKAS1992">
]]><![CDATA[<biblioset>
]]><![CDATA[<author>
]]><![CDATA[<surname>Karakas</surname>
]]><![CDATA[<firstname>Chris</firstname>
]]><![CDATA[</author>
]]><![CDATA[<title>]]><ulink url="http://www.amazon.de/exec/obidos/ASIN/3898112330">Neuronale Lernregeln und andere Methoden für lineare Assoziation und Trennung</ulink><![CDATA[</title>
]]><![CDATA[<publisher>
]]><![CDATA[<publishername>BoD GmbH, Norderstedt</publishername>
]]><![CDATA[</publisher>
]]><![CDATA[<abstract>
]]><![CDATA[<para>
]]><![CDATA[An examination of neural network methods and methods from classic optimization theory for solving the problem of linear association and separation. After a formal mathematical definition of neural networks, the linear association problem and some so-called "learning rules" for its solution are considered: 
]]><![CDATA[...more Abstract text here.
]]><![CDATA[</para>
]]><![CDATA[</abstract>
]]><![CDATA[</biblioset>
]]><![CDATA[</biblioentry>
]]><![CDATA[...
]]><![CDATA[more <biblioentry> elements here
]]><![CDATA[...
]]><![CDATA[</bibliodiv>
]]><![CDATA[</bibliography>
]]></screen><para>The whole code should be in the LyX <indexterm><primary>LyX</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>(see <xref linkend="LyX-environments"> for an explanation of LyX <indexterm><primary>LyX</primary></indexterm>environments). You can even insert URLs and cross-references the usual LyX <indexterm><primary>LyX</primary></indexterm>way (from the LyX <indexterm><primary>LyX</primary></indexterm>Insert menu) and they will be correctly exported to SGML.<indexterm><primary>SGML</primary></indexterm> The layout <indexterm><primary>layout</primary></indexterm>of bibliography.<indexterm><primary>bibliography</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>should be &ldquo; DocBook <indexterm><primary>DocBook</primary></indexterm>Chapter <indexterm><primary>Chapter</primary></indexterm>(SGML)&rdquo; (to be set from the LyX <indexterm><primary>LyX</primary></indexterm>Layout menu). You don't need anything in the preample <indexterm><primary>preample</primary></indexterm>or elsewhere. See the <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/bibliography.lyx">bibliography.lyx</ulink> file in the  <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/introduction.html#FORMATS">Formats section of GNU/Linux Command-Line Tools Summary HOWTO</ulink> for an example.</para><para>To cite <indexterm><primary>cite</primary></indexterm>a reference from a reference list created this way, you have to switch to the SGML <indexterm><primary>SGML</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>for the whole paragraph <indexterm><primary>paragraph</primary></indexterm>containing the citation,<indexterm><primary>citation</primary></indexterm> then write as in the following example:</para><screen><![CDATA[<para>
]]><![CDATA[Consult <citation>KARAKAS1992</citation> for more details on
]]><![CDATA[neural learning rules.
]]><![CDATA[</para>
]]></screen><para>Note that we use the value of the xreflabel <indexterm><primary>xreflabel</primary></indexterm>attribute <indexterm><primary>attribute</primary></indexterm>to refer to the reference entry.</para><note>
<title>
Formatting your Reference List.
</title>
<para>
Note that this way of creating a Reference List and citations does NOT cover formatting of either citations or the entries in the Reference List itself. Note also that each journal (or medium) has its own formatting expectations as far as the Bibliogrphy is concerned. You will have to write your own DSSSL driver file to accomodate for this need. RefDB 
<citation role="REFDB"><xref linkend="IDHOENICKA0X"></citation>
 (<xref linkend="LyX-Bibliography-with-RefDB">)  takes this burden out of your work for the slight overhead of setting up a database and installing the RefDB package (<xref linkend="Refdb">).
</para>
</note>
</sect2>
<sect2 id="LyX-Bibliography-with-RefDB"><title>Bibliography with RefDB</title><para>You don't need to care about a bibliography.<indexterm><primary>bibliography</primary></indexterm>sgml file if you use RefDB <indexterm><primary>RefDB</primary></indexterm>- the <ulink url="lyxtox">lyxtox</ulink> file will create it automatically <indexterm><primary>automatically</primary></indexterm>with the help of RefDB,<indexterm><primary>RefDB</primary></indexterm> totally transparently <indexterm><primary>transparently</primary></indexterm>to you. All you need is install and set up RefDB <indexterm><primary>RefDB</primary></indexterm>(see <xref linkend="Refdb"> and <xref linkend="bibliographic-database"> respectively), and set the following variables in <ulink url="lyxtox">lyxtox</ulink>:</para><itemizedlist><listitem><para>Process_RefDB <indexterm><primary>Process_RefDB</primary></indexterm>to &ldquo;1&rdquo;.</para></listitem><listitem><para>RefDB_db <indexterm><primary>RefDB_db</primary></indexterm>to the name of the RefDB <indexterm><primary>RefDB</primary></indexterm>database containing the bibliographic<indexterm><primary>bibliographic</primary></indexterm> entries you plan to cite <indexterm><primary>cite</primary></indexterm>(you created this database <indexterm><primary>database</primary></indexterm>in <xref linkend="Refdb">, the name in the example was &ldquo;ck_refdb&rdquo; and is the default one in <ulink url="lyxtox">lyxtox</ulink> - you should of course change this).</para></listitem><listitem><para>REFDB_style <indexterm><primary>REFDB_style</primary></indexterm>to the style of the journal you want your Bibliography to conform to. </para></listitem></itemizedlist><para>Note that this name must contain a dot at the end, because <ulink url="lyxtox">lyxtox</ulink> will create, the file ${REFDB_style}dsl. </para><para>Example: for REFDB_style=&quot;J.Biol.Chem.&quot;, <ulink url="lyxtox">lyxtox</ulink> will automatically <indexterm><primary>automatically</primary></indexterm>create (through RefDB) the file J.Biol.Chem.dsl,<indexterm><primary>J.Biol.Chem.dsl</primary></indexterm> i.e. the &ldquo;dsl&rdquo; ending is appended without any extra dot. The default value is &ldquo;J.Biol.Chem.&rdquo;, one of the two standard styles shipped with RefDB,<indexterm><primary>RefDB</primary></indexterm> and should get you starting. See <ulink url="http://refdb.sourceforge.net/manual-0.9.4/x3098.html">How to manage bibliography styles</ulink> for more details on bibliography <indexterm><primary>bibliography</primary></indexterm>styles in RefDB.<indexterm><primary>RefDB</primary></indexterm></para><para>The only thing that remains is... cite <indexterm><primary>cite</primary></indexterm>of course!</para><para>Citing with RefDB <indexterm><primary>RefDB</primary></indexterm>in LyX <indexterm><primary>LyX</primary></indexterm>is a bit tricky, since LyX <indexterm><primary>LyX</primary></indexterm>does not allow citing the way RefDB <indexterm><primary>RefDB</primary></indexterm>is expecting it: with a role attribute <indexterm><primary>attribute</primary></indexterm>with the value &ldquo;REFDB&rdquo; in the SGML <indexterm><primary>SGML</primary></indexterm>citation code. Of course, we could use a pure SGML <indexterm><primary>SGML</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>as in <xref linkend="LyX-Bibliography-without-RefDB"> and write:</para><screen><![CDATA[<para>
]]><![CDATA[Consult <citation role="XXXX"><xref linkend="KARAKAS1992"></citation> 
]]><![CDATA[for more details on neural learning rules.
]]><![CDATA[</para>
]]></screen><para>each time we want to cite <indexterm><primary>cite</primary></indexterm>something. But there is a better way: RefDB <indexterm><primary>RefDB</primary></indexterm>can create that SGML <indexterm><primary>SGML</primary></indexterm>code automatically,<indexterm><primary>automatically</primary></indexterm> if it finds something like:</para><screen><![CDATA[<para>
]]><![CDATA[Consult <citation role="XXXX">"KARAKAS1992"</citation> 
]]><![CDATA[for more details on neural learning rules.
]]><![CDATA[</para>
]]></screen><para>in the SGML <indexterm><primary>SGML</primary></indexterm>file. But how can we convince LyX <indexterm><primary>LyX</primary></indexterm>to output something like the above for each citation <indexterm><primary>citation</primary></indexterm>when it exports our file to SGML?<indexterm><primary>SGML</primary></indexterm></para><para>The solution I found to this is:</para><orderedlist><listitem><para>Export all the bibliographic <indexterm><primary>bibliographic</primary></indexterm>entries you plan to use in a file, say refdb.<indexterm><primary>refdb</primary></indexterm>ris (see <xref linkend="bibliographic-database"> on how to do this).</para></listitem><listitem><para>Use the <ulink url="awkscr_cit">awkscr_cit</ulink> AWK <indexterm><primary>AWK</primary></indexterm>script to create a new LyX <indexterm><primary>LyX</primary></indexterm>file from refdb.<indexterm><primary>refdb</primary></indexterm>ris:</para><screen><![CDATA[awkscr_cit refdb.ris > citlabels.lyx
]]></screen><para>The citlabels.lyx <indexterm><primary>citlabels.lyx</primary></indexterm>file is a LyX <indexterm><primary>LyX</primary></indexterm>file containing only labels, one for each bibliographic <indexterm><primary>bibliographic</primary></indexterm>entry in refdb.<indexterm><primary>refdb</primary></indexterm>ris. The labels have the prefix &quot;cit:&quot; to distinguish them from true labels. To stay with the above example, the bibliographic <indexterm><primary>bibliographic</primary></indexterm>entry with <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>&ldquo;KARAKAS1992&rdquo; will produce a label <indexterm><primary>label</primary></indexterm>&ldquo;cit:KARAKAS1992&rdquo; in the citlabels.lyx <indexterm><primary>citlabels.lyx</primary></indexterm>file created by awkscr_cit.<indexterm><primary>awkscr_cit</primary></indexterm></para></listitem><listitem><para>Open the citlabels.lyx <indexterm><primary>citlabels.lyx</primary></indexterm>file in LyX,<indexterm><primary>LyX</primary></indexterm> together with your document.<indexterm><primary>document</primary></indexterm></para></listitem><listitem><para>To cite <indexterm><primary>cite</primary></indexterm>an entry, you (mis)use the &ldquo;Insert Cross-Reference<indexterm><primary>Cross-Reference</primary></indexterm>&rdquo; feature of LyX:<indexterm><primary>LyX</primary></indexterm> from the LyX <indexterm><primary>LyX</primary></indexterm>menu, choose &ldquo;Insert -&gt; Cross Reference&rdquo;. In the upcoming <indexterm><primary>upcoming</primary></indexterm>dialog box there is a drop-down <indexterm><primary>drop-down</primary></indexterm>list field called &ldquo;Buffer&rdquo;. The Buffer <indexterm><primary>Buffer</primary></indexterm>serves as the source of the labels you want to reference. Usually, &ldquo;Buffer&rdquo; is set to the current file. You change this to &ldquo;citlabels.lyx&rdquo; by clicking on the dropdown field and choosing the citlabels.lyx <indexterm><primary>citlabels.lyx</primary></indexterm>file. Now you are presented with all labels of citlabels.lyx.<indexterm><primary>citlabels.lyx</primary></indexterm> Choose the label <indexterm><primary>label</primary></indexterm>containing the <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>of the RefDB <indexterm><primary>RefDB</primary></indexterm>bibliographic <indexterm><primary>bibliographic</primary></indexterm>entry you want to cite.<indexterm><primary>cite</primary></indexterm> In our example, you choose &ldquo;cit:KARAKAS1992&rdquo;, if you want to cite <indexterm><primary>cite</primary></indexterm>the entry with <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>&ldquo;KARAKAS1992&rdquo;. </para></listitem></orderedlist><para>That's all! Don't worry about that &ldquo;cit:&rdquo; prefix, <ulink url="sedscr">sedscr</ulink> takes care about it. For every <emphasis>cross-reference</emphasis> to a label <indexterm><primary>label</primary></indexterm>of the form &ldquo;cit:IDsome&rdquo;, sedscr <indexterm><primary>sedscr</primary></indexterm>will create a <emphasis>citation</emphasis> of the form:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1002;" format="linespecific"><![CDATA[
]]></screen><para>in the exported SGML <indexterm><primary>SGML</primary></indexterm>file. Then, <ulink url="lyxtox">lyxtox</ulink> will call the aproppriate RefDB <indexterm><primary>RefDB</primary></indexterm>tools to transform this citation <indexterm><primary>citation</primary></indexterm>to</para><screen><![CDATA[]]><inlinegraphic fileref="&file1003;" format="linespecific"><![CDATA[
]]></screen><para>or some more complex form according to the bibliographic <indexterm><primary>bibliographic</primary></indexterm>style in use. Again, you don't have to worry about this procedure.<indexterm><primary>procedure</primary></indexterm> Just create the citlabels.lyx <indexterm><primary>citlabels.lyx</primary></indexterm>file as shown above and insert cross-references to its labels in place of your citations.<indexterm><primary>citations</primary></indexterm> You don't have to bother about SGML <indexterm><primary>SGML</primary></indexterm>code and you can't get the ID's wrong since you get a list of all available labels in citlabels.lyx <indexterm><primary>citlabels.lyx</primary></indexterm>to choose from. On the other hand, you can't get anything but &ldquo;simple&rdquo; citations <indexterm><primary>citations</primary></indexterm>this way, but at the moment I can live with that. See <xref linkend="explain-bibliography"> for a detailed explanation of what <ulink url="lyxtox">lyxtox</ulink> and RefDB <indexterm><primary>RefDB</primary></indexterm>do for you in the background <indexterm><primary>background</primary></indexterm>to produce correctly formatted citations<indexterm><primary>citations</primary></indexterm> and a correctly formatted Reference List.</para><para>More elaborate solutions (using a citlabels.lyx file containing two or more labels for each bibliographic ID, each one with a different prefix, serving different citation purposes, "simple" or "complex" ones) are possible, but my hope is that this work will convince the LyX development team to incorporate RefDB directly in LyX in a future version. In the meantime, the method presented works fine - here and now.<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_cool.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_cool.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_cool.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_cool.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
</sect2>
</sect1>
<sect1 id="LyX-Index"><title>Index </title><para>The index will be generated automatically <indexterm><primary>automatically</primary></indexterm>by the <ulink url="lyxtox">lyxtox</ulink> script (which will call the collateindex.<indexterm><primary>collateindex</primary></indexterm>pl <application>Perl</application> script that came with the docbook-dsssl-stylesheets <indexterm><primary>docbook-dsssl-stylesheets</primary></indexterm>package you installed in <xref linkend="DocBook">) as a separate file. You must arrange to have this file incorporated into your document.<indexterm><primary>document</primary></indexterm> The easiest way to do this is by file entity <indexterm><primary>entity</primary></indexterm>reference. In the preample <indexterm><primary>preample</primary></indexterm>of your document,<indexterm><primary>document</primary></indexterm> add an internal subset that defines the index file entity:<indexterm><primary>entity</primary></indexterm></para><screen><![CDATA[<!entity index SYSTEM "index.sgml">
]]></screen><para>We have done this already in <xref linkend="preample">. See <xref linkend="explain-appendix"> for the sed scripts that insert the appendix <indexterm><primary>appendix</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>entity at the end of the SGML <indexterm><primary>SGML</primary></indexterm>file and <xref linkend="explain-index"> for the explanation of the subsequent index generation.</para><para>From the user perspective, all it remains is to enter the words that shall be included in the index. This is done as usual in LyX:<indexterm><primary>LyX</primary></indexterm> from the menu, choose either Insert--&gt;&rdquo;Index entry of preceding word&rdquo; (which I personally find easier), or Insert--&gt;&rdquo;Index entry&rdquo;, then enter the required word.</para><important>
<title>Don't underestimate the importance of an Index!</title> 
<para> 
It is easy to neglect index generation. It is so boring, having to read the whole document again, word for word, and hour for hour  use the menu to "insert index entry of preceding word"! But don't underestimate the importance of a good, complete index for your document, especially if it is of the order of a book! A knowledgeable reader will allways appreciate the possibility to use the Index to arrive at the information he is searching, rather than the usual time-consuming physical, or, even worse, virtual page browsing. Plan a whole working day for index generation of every 100 pages of text.
</para> 
</important>
<sect2 id="LyX-automatic-Index-generation"><title>Automatic Index generation</title><para>LyX <indexterm><primary>LyX</primary></indexterm>provides an easy way to insert an Index entry (see <xref linkend="LyX-Index">): from the menu, choose either Insert--&gt;&rdquo;Index entry of preceding word&rdquo; (which I personally find easier), or Insert--&gt;&rdquo;Index entry&rdquo;, then enter the required word. This method works fine - if you have a small document,<indexterm><primary>document</primary></indexterm> with only a few keywords <indexterm><primary>keywords</primary></indexterm>to insert. But what if your document <indexterm><primary>document</primary></indexterm>has grown to hundreds <indexterm><primary>hundreds</primary></indexterm>of pages, with hundreds (or even thousands) of index entries to insert? See the Index of the <ulink url="http://www.karakas-online.de/EN-Book/">PHP-Nuke HOWTO</ulink> for an example of an Index that cannot be generated manually - unless you want to drive yourself crazy!</para><para>Clearly, for a comprehensive Index of large documents, an automatic procedure<indexterm><primary>procedure</primary></indexterm> is necessary. However, the general problem of automatic Index generation is subject of extensive (and still not conclusive) research <indexterm><primary>research</primary></indexterm>and I am not going to address it in its full generality <indexterm><primary>generality</primary></indexterm>here. For our purposes, even a semi-automatic <indexterm><primary>semi-automatic</primary></indexterm>procedure <indexterm><primary>procedure</primary></indexterm>would be very helpful. To this end, I have created the following 4 scripts:</para><itemizedlist><listitem><para><ulink url="sedscr_list_index_items">sedscr_list_index_items</ulink>: lists all index entries contained in a LyX <indexterm><primary>LyX</primary></indexterm>document.</para></listitem><listitem><para><ulink url="sedscr_delete_index_items">sedscr_delete_index_items</ulink>: deletes all index entries from a LyX <indexterm><primary>LyX</primary></indexterm>document.</para></listitem><listitem><para><ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink>: creates a list of words used in a LyX <indexterm><primary>LyX</primary></indexterm>document. The list can be subsequently edited manually, mostly deleting unwanted or uninteresting words, to yield a list of words that are used in the document<indexterm><primary>document</primary></indexterm> and are interesting enough to be part of its Index.</para></listitem><listitem><para><ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>: uses an externally supplied document <indexterm><primary>document</primary></indexterm>containing a list of index entries to insert an index entry in a LyX <indexterm><primary>LyX</primary></indexterm>document for every word appearing in that list.</para></listitem></itemizedlist><para>They can be used in the following semi-automatic <indexterm><primary>semi-automatic</primary></indexterm>Index generation procedure:<indexterm><primary>procedure</primary></indexterm> </para><orderedlist><listitem><para>Optional: create a list of all existing index entries in your document.<indexterm><primary>document</primary></indexterm> This is useful not only because you are going to eliminate <indexterm><primary>eliminate</primary></indexterm>all index entries from the document <indexterm><primary>document</primary></indexterm>in the next step, but also as a backup of the index entries that were currently in use - you might want to reuse them in some later step.</para><para>To create a list of all existing index entries in your document,<indexterm><primary>document</primary></indexterm> type:</para><screen><![CDATA[sedscr_list_index_items document.lyx > indexitems
]]></screen><para>The generated indexitems <indexterm><primary>indexitems</primary></indexterm>file will contain a list of all index entries in document.<indexterm><primary>document</primary></indexterm>lyx, one index entry per line, with a semicolon at the end of each line. The semicolon will be used later as a record delimiter in the awk <indexterm><primary>awk</primary></indexterm>scripts that follow, so don't let it irritate you.</para><para>To get an alphabetically sorted list of index items, without duplicate entries and with all symbols <indexterm><primary>symbols</primary></indexterm>at the beginning of the list, use the sort and uniq utilities as follows:</para><screen><![CDATA[cat indexitems | sort | uniq > indexitems.sorted
]]><![CDATA[mv indexitems.sorted indexitems
]]></screen></listitem><listitem><para>Remove all previous index entries from the LyX <indexterm><primary>LyX</primary></indexterm>document. You need this preliminary step because, if you forget to remove already existing index entries, a subsequent run of the <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> script may substitute even the existing index terms <indexterm><primary>terms</primary></indexterm>(those already inside the LyX <indexterm><primary>LyX</primary></indexterm>\index commands) with LyX <indexterm><primary>LyX</primary></indexterm>\index commands. This may or may not happen, depending on the regular expressions <indexterm><primary>expressions</primary></indexterm>used in the current implementation <indexterm><primary>implementation</primary></indexterm>of <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>, but it is better to err on the side of caution. What <emphasis>will</emphasis> happen, however, is that repeated invocations <indexterm><primary>invocations</primary></indexterm>of <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> will add index entries besides already existing ones. You will thus end up with a document <indexterm><primary>document</primary></indexterm>that contains double index entries for each index term in your indexitems <indexterm><primary>indexitems</primary></indexterm>file. </para><para>Besides, there is another reason why you might want to remove all index entries from your LyX <indexterm><primary>LyX</primary></indexterm>document: a LyX <indexterm><primary>LyX</primary></indexterm>text cluttered <indexterm><primary>cluttered</primary></indexterm>with index entries may still be a breeze to read for a computer, but quite a headache <indexterm><primary>headache</primary></indexterm>to read for humans.</para><para>To remove all index entries from a LyX <indexterm><primary>LyX</primary></indexterm>document, type:</para><screen><![CDATA[sedscr_delete_index_items document.lyx > document-noindexitems.lyx
]]></screen><para>The generated document-noindexitems. lyx <indexterm><primary>lyx</primary></indexterm>will contain everything from document.<indexterm><primary>document</primary></indexterm>lyx - except the index entries.</para></listitem><listitem><para>Create a list of all index entries to be used in the LyX <indexterm><primary>LyX</primary></indexterm>document. This is the most difficult part: as said above, this problem is not trivial.<indexterm><primary>trivial</primary></indexterm> We will thus content ourselves with a list of all <emphasis>words</emphasis> used in the document.<indexterm><primary>document</primary></indexterm> Once we have all words, we can still edit the list manually and delete all unwanted entries. This is what makes this procedure <indexterm><primary>procedure</primary></indexterm><emphasis>semi-automatic</emphasis> and not automatic. The idea is that it is still better having to delete 10000 lines from a 12000 line document,<indexterm><primary>document</primary></indexterm> than having to insert 2000 index entries from the LyX <indexterm><primary>LyX</primary></indexterm>Insert menu.</para><para>To create a list of all words used in a LyX <indexterm><primary>LyX</primary></indexterm>document, type:</para><screen><![CDATA[awkscr_create_index_items document.lyx > words
]]></screen><para>There is even some code in <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink> that checks whether the current word is in some &ldquo;trivia&rdquo; list of trivial <indexterm><primary>trivial</primary></indexterm>words and discards it. In such a case, you would call the script with two arguments, as follows:</para><screen><![CDATA[awkscr_create_index_items trivia document.lyx > words
]]></screen><para>However, this part of the code is either too slow, or buggy, so it is commented for the moment (feel free to send corrections or suggestions).</para><para>It is a good idea to sort your words alphabetically and delete double entries, so do:</para><screen><![CDATA[cat words | sort | uniq > words-unique
]]><![CDATA[mv words-unique words
]]></screen><para>Once the list of all words of your document <indexterm><primary>document</primary></indexterm>is created, all you have to do is open it with a text editor and delete all unwanted words or correct the ones that are in plural or have some punctuation <indexterm><primary>punctuation</primary></indexterm>at the end and so on. This is still hard if your document <indexterm><primary>document</primary></indexterm>is large, but still a faster alternative than targeting the Insert menu with the mouse 8000 times (I guess each one of my 2000 index entries appears 4 times in my document,<indexterm><primary>document</primary></indexterm> which gives me an estimate <indexterm><primary>estimate</primary></indexterm>of 8000 menu selections with the mouse - unfortunately no keyboard bindings <indexterm><primary>bindings</primary></indexterm>were found to work on my system).</para><para>You should delete all lines containing characters that could be interpreted<indexterm><primary>interpreted</primary></indexterm> as metacharacters of regular expressions:<indexterm><primary>expressions</primary></indexterm> *, +, ?, $, &amp;, ^, \ - and probably many others. Don't try to escape them, it will not work: <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink> will replace the correct, string with the <emphasis>escaped</emphasis> string, adding an index entry for the escaped <indexterm><primary>escaped</primary></indexterm>string too! This is not what you will want. What is rather needed here is a mechanism to search for the escaped <indexterm><primary>escaped</primary></indexterm>string, but replaced it with the verbatim one (i.e. the string without the escaping backslashes). This is still work to be done (FIXME).</para><para>Practically, this restriction means that you will have to add your index entries for symbols <indexterm><primary>symbols</primary></indexterm>like *, +, ?, $, &amp;, ^, \ manually, each time after you run <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink>.</para></listitem><listitem><para>Once you have a file, say indexitems,<indexterm><primary>indexitems</primary></indexterm> with all words that should appear in the Index of a LyX <indexterm><primary>LyX</primary></indexterm>file, type:</para><screen><![CDATA[awkscr_insert_index_items indexitems - < document-noindexitems.lyx > document-indexitems.lyx
]]></screen><para>to create from document-noindexitems. lyx <indexterm><primary>lyx</primary></indexterm>a document <indexterm><primary>document</primary></indexterm>with index entries (document-indexitems.lyx) for all words in indexitems.<indexterm><primary>indexitems</primary></indexterm> </para></listitem></orderedlist><warning>
<title>
Long execution time!
</title>
<para>
The current implementation of <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> takes really long to execute, if the indexitems file is large: For 3000 words in indexitems, producing about 9000 index entries in the final document (of which 3000 are duplicate), the script may well need 1-2 hours on a Pentium 3.4 GHz - go get a cup of coffe! <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject>
</para>
</warning>
<para>Some notes on <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>'s mode of operation: </para><itemizedlist><listitem><para>The &ldquo;-&rdquo; in the above invocation <indexterm><primary>invocation</primary></indexterm>is important: it forces the awk <indexterm><primary>awk</primary></indexterm>script to continue reading from standard input, after it has read indexitems.<indexterm><primary>indexitems</primary></indexterm> This, together with the code</para><screen><![CDATA[FILENAME == "indexitems" {
]]><![CDATA[        n++
]]><![CDATA[        indexentry[$1] = $1
]]><![CDATA[        next
]]><![CDATA[}
]]></screen><para>in <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>, causes the words in indexitems <indexterm><primary>indexitems</primary></indexterm>to be imported into the indexentry[] associative array.</para></listitem><listitem><para>The file separator in <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> is set to the semicolon &ldquo;;&rdquo;, instead of the default, which is space. This makes it possible to enter index entries with more than one words. Accordingly, the <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink> script appends a semicolon at the end of each word it prints - you should leave these untouched!</para></listitem><listitem><para><ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> follows a simple algorithm <indexterm><primary>algorithm</primary></indexterm>to insert the index entries at the right places in the document:<indexterm><primary>document</primary></indexterm> to insert an index entry, we have to know what LyX <indexterm><primary>LyX</primary></indexterm>environment<indexterm><primary>environment</primary></indexterm> (<xref linkend="LyX-environments">) we are in. In essence, this means we have to parse the LyX <indexterm><primary>LyX</primary></indexterm>document. Since the \ layout <indexterm><primary>layout</primary></indexterm>commands in the LyX <indexterm><primary>LyX</primary></indexterm>file do NOT have what we would call &ldquo;closing tags&rdquo; in other markup <indexterm><primary>markup</primary></indexterm>languages, we cannot tell awk <indexterm><primary>awk</primary></indexterm>&ldquo;if you are between the start and the end of the Paragraph environment,<indexterm><primary>environment</primary></indexterm> do the following&rdquo;, or anything like that - there is no easy way to find the &ldquo;end &ldquo; of an environment,<indexterm><primary>environment</primary></indexterm> given all the environment <indexterm><primary>environment</primary></indexterm>nestings that are possible. Luckily, another easy way exists: whenever a \ layout <indexterm><primary>layout</primary></indexterm>command is encountered, we are in the environment <indexterm><primary>environment</primary></indexterm>specified by that \ layout <indexterm><primary>layout</primary></indexterm>command, so we only need to set a variable, call it layout, accordingly:</para><screen><![CDATA[/\\layout SGML/ { layout = "SGML"; print; next }
]]><![CDATA[/\\layout Chapter/ { layout = "Chapter"; print; next }
]]><![CDATA[/\\layout Section/ { layout = "Section"; print; next }
]]><![CDATA[/\\layout Subsection/ { layout = "Subsection"; print; next }
]]><![CDATA[/\\layout Subsubsection/ { layout = "Subsubsection"; print; next }
]]><![CDATA[/\\layout Standard/ { layout = "Standard"; print; next }
]]><![CDATA[
]]></screen><para>...and so on</para></listitem><listitem><para>Clearly, we should not insert index entries everywhere, e.g. in the &ldquo;Code&rdquo; environment.<indexterm><primary>environment</primary></indexterm> That's why we check if we are in the &quot;Standard&quot;, &quot;Itemize&quot;, &ldquo;Enumerate&rdquo;, &quot;Quotation&quot;<indexterm><primary>Quotation</primary></indexterm>, &quot;Description&quot; environment <indexterm><primary>environment</primary></indexterm>(warning: the way <ulink url="sedscr">sedscr</ulink> works currently, you should not insert index entries in the &ldquo;Caption&rdquo; environment) and, if we are (and only then), we substiture every word in the indexentry[] array with the LyX <indexterm><primary>LyX</primary></indexterm>&ldquo;insert index entry&rdquo; command:</para><screen><![CDATA[{
]]><![CDATA[        if ( (  layout == "Standard" ||
]]><![CDATA[                layout == "Itemize" ||
]]><![CDATA[                layout == "Enumerate" ||
]]><![CDATA[                layout == "Quotation" ||
]]><![CDATA[                layout == "Description" ) && ( inset == 0 ) ) {
]]><![CDATA[                for (item in indexentry) {
]]><![CDATA[                        if (gsub(" " item " "," " item " \n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub("^" item " "," " item " \n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " item "$"," " item "\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " item ":"," " item ":\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " item "\\."," " item ".\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " item ","," " item ",\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " item "\\?"," " item "?\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " item ";"," " item ";\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " item "\n"," " item "\n\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                        else if (gsub(" " "\"" item "\""," " "\"" item "\"\n\\begin_inset LatexCommand \\index{" indexentry[item] "}\n\n\\end_inset \n")) { continue }
]]><![CDATA[                }
]]><![CDATA[                { print; next }
]]><![CDATA[        }
]]><![CDATA[}
]]></screen></listitem></itemizedlist><para>Some tips regarding the (necessary) manual <indexterm><primary>manual</primary></indexterm>editing of the words file, the file output by <ulink url="awkscr_create_index_items">awkscr_create_index_items</ulink> above: </para><itemizedlist><listitem><para>Leave the semicolons at the end of each line untouched! They are needed as record separators in the awk <indexterm><primary>awk</primary></indexterm>scripts.</para></listitem><listitem><para>You will see a lot of words (or their declinations) that are not useful. It is one thing to have a lot of words and another to have a set of really useful words and phrases. That's the price we pay for the simplicity of our method.</para></listitem><listitem><para>You may need to supply some extra terms <indexterm><primary>terms</primary></indexterm>you feel are missing from that file. Feel free to do this, <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> does not know how you created the indexitems <indexterm><primary>indexitems</primary></indexterm>file you give it. </para></listitem><listitem><para>Keep backups of your word lists from subsequent runs of the scripts. Combine word lists from other projects. No matter how long your word list, only the terms <indexterm><primary>terms</primary></indexterm>that really appear somewhere, will make it to the Index, so don't worry if your list is too long - given enough computing <indexterm><primary>computing</primary></indexterm>time, that is.</para></listitem><listitem><para>Take care to delete everything in your word list that looks like a regular expression with metacharacters - because it will be interpreted <indexterm><primary>interpreted</primary></indexterm>as such, with unpredictable results (unless you really know what you are doing). I once had &ldquo;.*&rdquo; on one line and I forgot to delete it. I then wondered how come that my document <indexterm><primary>document</primary></indexterm>was full of index entries to &ldquo;.*&rdquo; while the text was almost gone! See <ulink url="http://www.karakas-online.de/EN-Book/regular-expressions.html">regular expressions</ulink>, for a brief introduction to regular expressions.<indexterm><primary>expressions</primary></indexterm></para></listitem><listitem><para>Take out any &ldquo;:&rdquo;, &ldquo;;&rdquo;, &ldquo;?&rdquo; from the end of the words, as well as enclosing double quotes. Those characters are already taken care of when it comes to inserting the entries, i.e. the indexentries file should contain only the &ldquo;pure&rdquo; words, without any punctuation <indexterm><primary>punctuation</primary></indexterm>signs. </para></listitem><listitem><para>Don't leave in &ldquo;config&rdquo; if your LyX <indexterm><primary>LyX</primary></indexterm>file contains &ldquo;config.php&rdquo;. If you do, the latter will look ugly in the LyX <indexterm><primary>LyX</primary></indexterm>editor, as it will contain an index entry for &ldquo;config&rdquo; just in the middle of it. This will not affect the rendered formats, however.</para></listitem><listitem><para>Don't leave in words that might form parts of a LyX <indexterm><primary>LyX</primary></indexterm>command. I once left &ldquo;Enumerate&rdquo; in my word list. The resulting LyX <indexterm><primary>LyX</primary></indexterm>file contained an index entry for &ldquo;Enumerate&rdquo; in front of every item in every enumeration list! Clearly, the awk <indexterm><primary>awk</primary></indexterm>script <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink> &ldquo;sees&rdquo; the LyX <indexterm><primary>LyX</primary></indexterm>commands in the file that are invisible to you. This bug has been fixed in the current version of the script, but there maybe others lurking around.</para></listitem></itemizedlist><para>Finally, there are a few known limitations of the collateindex <indexterm><primary>collateindex</primary></indexterm>script that creates the index (see <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/indexing.html">Automatic Indexing with the DocBook DSSSL Stylesheets</ulink>:</para><itemizedlist><listitem><para>Duplicate page numbers <indexterm><primary>numbers</primary></indexterm>are not suppressed in the index. If the document <indexterm><primary>document</primary></indexterm>contains three indexing <indexterm><primary>indexing</primary></indexterm>hits on page 4, the generated index will contain 4, 4, 4.</para></listitem><listitem><para>Ranges are not automatically <indexterm><primary>automatically</primary></indexterm>constructed. If the document <indexterm><primary>document</primary></indexterm>contains indexing <indexterm><primary>indexing</primary></indexterm>hits on pages 4, 5, 6, and 7, the generated index will contain 4, 5, 6, 7 instead of 4-7.</para></listitem></itemizedlist></sect2>
</sect1>
<sect1 id="lyxtox"><title>The final step: invoking lyxtox </title><para>If you have followed all the above, your working directory should now contain:</para><screen><![CDATA[awkscr_create_index_items
]]><![CDATA[awkscr_insert_index_items
]]><![CDATA[awkscr_math
]]><![CDATA[awkscr_refdb_html
]]><![CDATA[awkscr_refdb_print
]]><![CDATA[ck-style.css
]]><![CDATA[images
]]><![CDATA[jadetex.cfg
]]><![CDATA[lyxtox
]]><![CDATA[lyxtox-html.dsl
]]><![CDATA[lyxtox-onehtml.dsl
]]><![CDATA[lyxtox-print.dsl
]]><![CDATA[lyxtox-print-howto.dsl
]]><![CDATA[lyxtox-print-pdf.dsl
]]><![CDATA[lyxtox-print-ps.dsl
]]><![CDATA[lyxtox-print-rtf.dsl
]]><![CDATA[lyxtox-print-txt.dsl
]]><![CDATA[sedscr
]]><![CDATA[sedscr_abi
]]><![CDATA[sedscr_app
]]><![CDATA[sedscr_bib
]]><![CDATA[sedscr_delete_index_items
]]><![CDATA[sedscr_list_index_items
]]><![CDATA[sedscr_math
]]><![CDATA[sedscr_ris
]]><![CDATA[sedscr_top
]]><![CDATA[sedscr_val
]]></screen><para>Now, to create all the other formats from your LyX <indexterm><primary>LyX</primary></indexterm>source, you just call <ulink url="./lyxtox">lyxtox</ulink> with one argument: the name of your . lyx <indexterm><primary>lyx</primary></indexterm>file <emphasis>without</emphasis> the . lyx <indexterm><primary>lyx</primary></indexterm>ending:</para><screen><![CDATA[lyxtox myTemplate
]]></screen><para>It's time for a cup of coffee now. Relax while your computer is busy creating a whole bunch of nice formatted documents. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_cool.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_cool.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_cool.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_cool.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<para>For a detailed explanation of what is going behind the scenes, see <xref linkend="explain-magic">.</para><para>Now, let's see a more realistic example: the creation of the <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/">GNU/Linux Command-Line Tools Summary HowTo</ulink>. This HowTo is an attempt to provide a comprehensive summary of useful command-line tools <indexterm><primary>tools</primary></indexterm>available to a GNU/Linux based operating <indexterm><primary>operating</primary></indexterm>system, i.e. commands needed by the majority of users. The document <indexterm><primary>document</primary></indexterm>is authored by Gareth Anderson and I assist him in the document conversion process. So, how do I go about such a project?</para><para>Here's how<footnote><para>See also <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=3846">How to correctly invoke the lyxtox script</ulink>.</para></footnote>: </para><para>My home directory is /home/chris. This is not my working directory for a lyxtox <indexterm><primary>lyxtox</primary></indexterm>project. A working directory is, say, myLinuxCommands, beneath my home directory. That is, I create a working directory specific to a project. In our case, let's say this is /home/chris/myLinuxCommands.</para><para>Now, I change to the working directory and make sure I have all files mentioned above. These are at least</para><screen><![CDATA[awkscr_create_index_items
]]><![CDATA[awkscr_insert_index_items
]]><![CDATA[awkscr_math
]]><![CDATA[awkscr_refdb_html
]]><![CDATA[awkscr_refdb_print
]]><![CDATA[ck-style.css
]]><![CDATA[images
]]><![CDATA[jadetex.cfg
]]><![CDATA[lyxtox
]]><![CDATA[lyxtox-html.dsl
]]><![CDATA[lyxtox-onehtml.dsl
]]><![CDATA[lyxtox-print.dsl
]]><![CDATA[lyxtox-print-howto.dsl
]]><![CDATA[lyxtox-print-pdf.dsl
]]><![CDATA[lyxtox-print-ps.dsl
]]><![CDATA[lyxtox-print-rtf.dsl
]]><![CDATA[lyxtox-print-txt.dsl
]]><![CDATA[sedscr
]]><![CDATA[sedscr_abi
]]><![CDATA[sedscr_app
]]><![CDATA[sedscr_bib
]]><![CDATA[sedscr_delete_index_items
]]><![CDATA[sedscr_list_index_items
]]><![CDATA[sedscr_math
]]><![CDATA[sedscr_ris
]]><![CDATA[sedscr_top
]]><![CDATA[sedscr_val
]]><![CDATA[sedscr_ima
]]><![CDATA[sedscr_apa
]]></screen><para>and may well have forgotten others (please tell me if I have). I copy these files from yet another directory in my home, where I have extracted a pristine copy of mySGML.tar.gz.</para><para>So now I have created the files</para><screen><![CDATA[/home/chris/myLinuxCommands/awkscr_create_index_items
]]><![CDATA[/home/chris/myLinuxCommands/awkscr_insert_index_items
]]><![CDATA[/home/chris/myLinuxCommands/awkscr_math
]]><![CDATA[/home/chris/myLinuxCommands/awkscr_refdb_html
]]><![CDATA[/home/chris/myLinuxCommands/awkscr_refdb_print
]]><![CDATA[/home/chris/myLinuxCommands/ck-style.css
]]><![CDATA[/home/chris/myLinuxCommands/images
]]><![CDATA[/home/chris/myLinuxCommands/jadetex.cfg
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-html.dsl
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-onehtml.dsl
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-print.dsl
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-print-howto.dsl
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-print-pdf.dsl
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-print-ps.dsl
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-print-rtf.dsl
]]><![CDATA[/home/chris/myLinuxCommands/lyxtox-print-txt.dsl
]]><![CDATA[/home/chris/myLinuxCommands/sedscr
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_abi
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_app
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_bib
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_delete_index_items
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_list_index_items
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_math
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_ris
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_top
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_val
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_ima
]]><![CDATA[/home/chris/myLinuxCommands/sedscr_apa
]]></screen><para>as exact copies of the original ones (which are, as I said, in some other directory).</para><para>Now, in the /home/chris/myLinuxCommands directory, I create (or copy) the LyX <indexterm><primary>LyX</primary></indexterm>file that I want to process. In our case, this is the gnu-linux-tools-summary.lyx file, together with bibliography.<indexterm><primary>bibliography</primary></indexterm>lyx <indexterm><primary>bibliography.lyx</primary></indexterm>and appendix.<indexterm><primary>appendix</primary></indexterm>lyx. In other cases, the bibliography.<indexterm><primary>bibliography</primary></indexterm>lyx <indexterm><primary>bibliography.lyx</primary></indexterm>and appendix.<indexterm><primary>appendix</primary></indexterm>lyx are not needed, so they are not there.</para><para>I change to the /home/chris/myLinuxCommands directory, which, as I said, is the working directory for the specific project in our example. Since my LyX <indexterm><primary>LyX</primary></indexterm>file is gnu-linux-tools-summary.lyx, I call lyxtox <indexterm><primary>lyxtox</primary></indexterm>with the basename <indexterm><primary>basename</primary></indexterm>of gnu-linux-tools-summary.lyx, i.e. with &quot;gnu-linux-tools-summary&quot;, as its first and only parameter:<indexterm><primary>parameter</primary></indexterm></para><screen><![CDATA[lyxtox gnu-linux-tools-summary
]]></screen><para>The name of the parameter <indexterm><primary>parameter</primary></indexterm>is $1 in the lyxtox <indexterm><primary>lyxtox</primary></indexterm>script.</para><para>(Of cource, I have taken care to adjust all parameters at the start of lyxtox<indexterm><primary>lyxtox</primary></indexterm> to my situation, as described in <xref linkend="required-preliminary-steps">).</para><para>If all goes well, I get another directory inside my working directory, named exactly as the parameter <indexterm><primary>parameter</primary></indexterm>of the script, in our case gnu-linux-tools-summary. Everything I need is there: the one, big HTML <indexterm><primary>HTML</primary></indexterm>file, the many HTML <indexterm><primary>HTML</primary></indexterm>files (&quot;chunks&quot;), the PDF,<indexterm><primary>PDF</primary></indexterm> PS.<indexterm><primary>PS</primary></indexterm>GZ, TXT <indexterm><primary>TXT</primary></indexterm>files, the images directory, the math <indexterm><primary>math</primary></indexterm>directory...simply everything. I can just tar the whole directory, upload it to my web site, extract it and I will have the whole project there! </para><para>Indeed, it is here: <ulink url="http://www.karakas-online.de/gnu-linux-tools-summary/">http://www.karakas-online.de/gnu-linux-tools-summary/</ulink>. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<para>Thus http://www.karakas-online.de/gnu-linux-tools-summary is an exact copy of my local /home/chris/myLinuxCommands/gnu-linux-tools-summary, as created by the lyxtox <indexterm><primary>lyxtox</primary></indexterm>invocation<indexterm><primary>invocation</primary></indexterm></para><screen><![CDATA[lyxtox gnu-linux-tools-summary
]]></screen><note>
<para>
Notice that you are supposed to have an "images" directory inside your working directory. Mine is /home/chris/myLinuxCommands/images. 
When you run lyxtox with "gnu-linux-tools-summary" as parameter, you get another one: /home/chris/myLinuxCommands/gnu-linux-tools-summary/images. This is perfectly OK: it is a copy of the original images directory. It is done this way, so that you only need to copy the gnu-linux-tools-summary to your website and be up and running without needing anything else.
</para>
</note>
</sect1>
</chapter>
<chapter id="errors-and-warnings"><title>Errors and warnings </title><para>There will be some errors and warnings. However, many of them are not crucial (or even avoidable) and can be safely ignored. Some day, in a perfect world, where all involved programs and languages will work perfectly with each other, these errors will disappear. Until then, you must learn to live with them.</para><para>Here are some examples of possible errors:</para><sect1 id="lyx-errors"><title>LyX errors</title><variablelist><varlistentry><term>text&nbsp;class&nbsp;not&nbsp;available:
</term><listitem><para>If you get:</para><screen><![CDATA[The document uses an unknown textclass "docbook-book". LyX wil not be able to format output correctly
]]></screen><para>do &quot;Layout--&gt;Document&quot; on any LyX <indexterm><primary>LyX</primary></indexterm>document you have and then, in the window that will appear, check the classes available under &quot;Class&quot;. You should see all the above classes you listed, especially the &quot;DocBook book (SGML)&quot; class <indexterm><primary>class</primary></indexterm>I use. You should see something like: </para><screen><![CDATA[+checking for docbook class docbook-algo... yes 
]]><![CDATA[+checking for docbook class docbook-book... yes 
]]><![CDATA[+checking for docbook class docbook-chapter... yes 
]]><![CDATA[+checking for docbook class docbook... yes 
]]><![CDATA[+checking for docbook class docbook-section... yes 
]]></screen><para>If not, then somehow the reconfigure <indexterm><primary>reconfigure</primary></indexterm>command above (see <xref linkend="reconfigure-LyX">) did not find all your classes.</para></listitem></varlistentry></variablelist></sect1>
<sect1 id="openjade-errors"><title>Openjade errors</title><variablelist><varlistentry><term>DTDDECL&nbsp;catalog&nbsp;entries&nbsp;are&nbsp;not&nbsp;supported:
</term><listitem><para>Jade <indexterm><primary>Jade</primary></indexterm>does not support the <ulink url="http://docbook.org/tdg/en/html/ch02.html#s-catalog-files">DTDDECL</ulink> catalog <indexterm><primary>catalog</primary></indexterm>directive <indexterm><primary>directive</primary></indexterm>and it complains loudly if it encounters one. You may safely ignore this warning. See <ulink url="http://docbook.org/tdg/en/html/appa.html#d0e279037">here</ulink> for more details.</para></listitem></varlistentry><varlistentry><term>xref&nbsp;to&nbsp;ANCHOR&nbsp;unsupported:
</term><listitem><para>This seems to be a Jade/Docbook problem and not a LyX <indexterm><primary>LyX</primary></indexterm>one. LyX <indexterm><primary>LyX</primary></indexterm>is capable of inserting cross-references to arbitrary positions in a text. For this purpose, it creates an anchor <indexterm><primary>anchor</primary></indexterm>with the id tag aproppriately set in the SGML <indexterm><primary>SGML</primary></indexterm>file:</para><screen><![CDATA[<anchor id="homepage-fig">
]]></screen><para>The cross-reference <indexterm><primary>cross-reference</primary></indexterm>itself is placed with the xref <indexterm><primary>xref</primary></indexterm>element:<indexterm><primary>element</primary></indexterm></para><screen><![CDATA[<xref linkend="homepage-fig">
]]></screen><para>The error means that this mechanism of cross-referencing <indexterm><primary>cross-referencing</primary></indexterm>is unsupported. This is why I change</para><screen><![CDATA[<section><anchor id="homepage-fig">
]]></screen><para>to </para><screen><![CDATA[<section id="homepage-fig">
]]></screen><para>with sed (see <xref linkend="run-sed-awk-scripts">). This way, at least cross-references to sections created by LyX <indexterm><primary>LyX</primary></indexterm>will work in SGML.<indexterm><primary>SGML</primary></indexterm></para></listitem></varlistentry><varlistentry><term>value&nbsp;of&nbsp;attribute&nbsp;&quot;LINKEND&quot;&nbsp;must&nbsp;be&nbsp;a&nbsp;single&nbsp;token:
</term><listitem><para>the label <indexterm><primary>label</primary></indexterm>you used for a section contains spaces. Change spaces to, say, underscores or dashes.</para></listitem></varlistentry><varlistentry><term>value&nbsp;of&nbsp;attribute&nbsp;&quot;ID&quot;&nbsp;must&nbsp;be&nbsp;a&nbsp;single&nbsp;token:
</term><listitem><para>you used a cross-reference <indexterm><primary>cross-reference</primary></indexterm>to a label <indexterm><primary>label</primary></indexterm>that contains spaces. Do not change the cross-reference.<indexterm><primary>cross-reference</primary></indexterm> Change the label:<indexterm><primary>label</primary></indexterm> change spaces to, say, underscores or dashes.</para></listitem></varlistentry><varlistentry><term>end&nbsp;tag&nbsp;for&nbsp;&quot;SECT3&quot;&nbsp;which&nbsp;is&nbsp;not&nbsp;finished:
</term><listitem><para>You probably have an empty subsubsection,<indexterm><primary>subsubsection</primary></indexterm> e.g. you just outlined your documents and some subsubsections have a title but no content (yet). I consider this warning to be a bug. Or is it a feature???</para></listitem></varlistentry><varlistentry><term>end&nbsp;tag&nbsp;for&nbsp;element&nbsp;&quot;LISTITEM&quot;&nbsp;which&nbsp;is&nbsp;not&nbsp;open:
</term><listitem><para>this may be a bug of LyX' SGML<indexterm><primary>SGML</primary></indexterm> generation. It happens when in an itemize <indexterm><primary>itemize</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>you use a higher depth, possibly with nested <indexterm><primary>nested</primary></indexterm>item lists and subsequent paragraphs that you want to be on the same identation <indexterm><primary>identation</primary></indexterm>level as the outer item. Not critical.</para></listitem></varlistentry><varlistentry><term>&quot;keep-with-next:&quot;&nbsp;is&nbsp;not&nbsp;a&nbsp;valid&nbsp;keyword&nbsp;in&nbsp;a&nbsp;make&nbsp;expression&nbsp;for&nbsp;flow&nbsp;object&nbsp;class&nbsp;&quot;paragraph&quot;:
</term><listitem><para>Didn't track <indexterm><primary>track</primary></indexterm>it down, but seems harmless.</para></listitem></varlistentry><varlistentry><term>value&nbsp;of&nbsp;attribute&nbsp;&quot;FORMAT&quot;&nbsp;cannot&nbsp;be&nbsp;&quot;PDF&quot;:
</term><listitem><para>Openjade <indexterm><primary>Openjade</primary></indexterm>tell us:</para><blockquote><para>must be one of &quot;BMP&quot;<indexterm><primary>BMP</primary></indexterm>, &quot;CGM-CHAR&quot;<indexterm><primary>CGM-CHAR</primary></indexterm>, &quot;CGM-BINARY&quot;, &quot;CGM-CLEAR&quot;, &quot;DITROFF&quot;<indexterm><primary>DITROFF</primary></indexterm>, &quot;DVI&quot;<indexterm><primary>DVI</primary></indexterm>, &quot;EPS&quot;<indexterm><primary>EPS</primary></indexterm>, &quot;EQN&quot;<indexterm><primary>EQN</primary></indexterm>, &quot;FAX&quot;<indexterm><primary>FAX</primary></indexterm>, &quot;GIF&quot;<indexterm><primary>GIF</primary></indexterm>, &quot;GIF87A&quot;, &quot;GIF89A&quot;, &quot;JPG&quot;<indexterm><primary>JPG</primary></indexterm>, &quot;JPEG&quot;<indexterm><primary>JPEG</primary></indexterm>, &quot;IGES&quot;, &quot;PCX&quot;<indexterm><primary>PCX</primary></indexterm>, &quot;PIC&quot;, &quot;PNG&quot;<indexterm><primary>PNG</primary></indexterm>, &quot;PS&quot;<indexterm><primary>PS</primary></indexterm>, &quot;SGML&quot;<indexterm><primary>SGML</primary></indexterm>, &quot;TBL&quot;, &quot;TEX&quot;, &quot;TIFF&quot;<indexterm><primary>TIFF</primary></indexterm>, &quot;WMF&quot;, &quot;WPG&quot;<indexterm><primary>WPG</primary></indexterm>, &quot;LINESPECIFIC&quot;</para></blockquote><para>this means that the list of accepted formats does not contain &ldquo;PDF&rdquo;. Such a list appears in the following files:</para><itemizedlist><listitem><para>/usr/share/sgml/db3xml/dbnotnx.mod</para></listitem><listitem><para>/usr/share/sgml/docbk30/docbook.dtd</para></listitem><listitem><para>/usr/share/sgml/docbook_3/dbnotn.mod</para></listitem><listitem><para>/usr/share/sgml/sdb/sdocbook.dtd</para></listitem><listitem><para>/usr/share/sgml/db41xml/dbnotnx.mod</para></listitem><listitem><para>/usr/share/sgml/docbook_4/dbnotn.mod</para></listitem></itemizedlist><para>Given that LyX <indexterm><primary>LyX</primary></indexterm>produces a SGML <indexterm><primary>SGML</primary></indexterm>file containing </para><screen><![CDATA[<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
]]></screen><para>as the first line, meaning that it uses DocBook <indexterm><primary>DocBook</primary></indexterm>V4.1 (1.1.x versions still used DocBook <indexterm><primary>DocBook</primary></indexterm>V3.0), we only need to insert &quot;PDF&quot;<indexterm><primary>PDF</primary></indexterm> in the /usr/share/sgml/docbook_4/dbnotn.mod file:</para><screen><![CDATA[<!ENTITY % notation.class "BMP| CGM-CHAR | CGM-BINARY | CGM-CLEAR | DITROFF | DVI | EPS | EQN | FAX | GIF | GIF87a | GIF89a | JPG | JPEG | IGES | PCX | PDF | PIC | PNG | PS | SGML | TBL | TEX | TIFF | WMF | WPG | linespecific %local.notation.class;"> 
]]></screen><para>If you still use LyX <indexterm><primary>LyX</primary></indexterm>v.1.1.x, you should change /usr/share/sgml/docbook_3/dbnotn.mod to include &ldquo;PDF&rdquo; in the list of accepted file extensions:<indexterm><primary>extensions</primary></indexterm></para><screen><![CDATA[<!ENTITY % notation.class                 "BMP| CGM-CHAR | CGM-BINARY | CGM-CLEAR | DITROFF | DVI                 | EPS | EQN | FAX | GIF | GIF87a | GIF89a                  | JPG | JPEG | IGES | PCX                 | PIC | PS | SGML | TBL | TEX | TIFF | WMF | WPG | PDF | PNG                 | linespecific                 %local.notation.class;"> 
]]></screen><para>Also, in the dbparam.dsl <indexterm><primary>dbparam.dsl</primary></indexterm>file for the print formats (located in /usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/dbparam.dsl on my system), zou would need to add &ldquo;pdf&rdquo; to the list of allowed graphic extensions:<indexterm><primary>extensions</primary></indexterm></para><screen><![CDATA[(define %graphic-extensions%
]]><![CDATA[  ;; REFENTRY graphic-extensions
]]><![CDATA[  ;; PURP List of graphic filename extensions
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; The list of extensions which may appear on a 'fileref'
]]><![CDATA[  ;; on a 'Graphic' which are indicative of graphic formats.
]]><![CDATA[  ;;
]]><![CDATA[  ;; Filenames that end in one of these extensions will not have
]]><![CDATA[  ;; the '%graphic-default-extension%' added to them.
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[  '("eps" "epsf" "gif" "tif" "tiff" "jpg" "jpeg" "png" "pdf" "tex"))
]]><![CDATA[
]]></screen><para>However, this is not necessary, since we use the technique of &ldquo; customization <indexterm><primary>customization</primary></indexterm>layers&rdquo; (see <xref linkend="explain-DSSSL-stylesheets">) and define %graphic-extensions% <indexterm><primary>%graphic-extensions%</primary></indexterm>in <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink> as shown above. Due to the nature of the DSSSL <indexterm><primary>DSSSL</primary></indexterm>language (which bears similarities to Scheme), our change takes precedence over the definition in the standard files and we don't need to change standard code.</para></listitem></varlistentry><varlistentry><term>Reference&nbsp;`4'&nbsp;on&nbsp;page&nbsp;1&nbsp;undefined&nbsp;on&nbsp;input&nbsp;line&nbsp;180:
</term><listitem><para>Some cross-refernce <indexterm><primary>cross-refernce</primary></indexterm>you use is probably misspelled.<indexterm><primary>misspelled</primary></indexterm> But this is somewhat difficult to achieve with LyX,<indexterm><primary>LyX</primary></indexterm> since LyX <indexterm><primary>LyX</primary></indexterm>provides you with a list of all the labels currently available for cross-referencing.<indexterm><primary>cross-referencing</primary></indexterm> The other occasion where you will see this error is in the first (or even second?) invocation <indexterm><primary>invocation</primary></indexterm>of <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>for a particular format. You need at least 3 <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>passes for the table of contents and the cross-references to be worked out and if you are currently on the first pass, you will see this error for every cross-reference.<indexterm><primary>cross-reference</primary></indexterm> </para></listitem></varlistentry><varlistentry><term>LaTeX_Font_Warning:&nbsp;Some&nbsp;font&nbsp;shapes&nbsp;were&nbsp;not&nbsp;available,&nbsp;defaults&nbsp;substituted:
</term><listitem><para>If you installed the Computern Modern fonts,<indexterm><primary>fonts</primary></indexterm> you probably don't need to worry about this error. If you check the fonts <indexterm><primary>fonts</primary></indexterm>used in the PDF <indexterm><primary>PDF</primary></indexterm>file (File--&gt;Documet Info--&gt;Fonts--&gt;List all fonts), you will probably find out that only some seldomly used characters were not rendered with CM fonts.<indexterm><primary>fonts</primary></indexterm> That's O.K. for me.</para></listitem></varlistentry><varlistentry><term>Overfull&nbsp;\hbox&nbsp;(30.17416pt&nbsp;too&nbsp;wide)&nbsp;in&nbsp;paragraph&nbsp;at&nbsp;lines&nbsp;5425--5425:
</term><listitem><para>You will get dozens of this. It is a typical <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>warning informing you that a line got some points too wide (mostly because there was some word that <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>could not hyphenate). Read the <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>documentation for this (but only if you want to produce a really perfect PDF <indexterm><primary>PDF</primary></indexterm>document).</para></listitem></varlistentry><varlistentry><term>/usr/share/sgml/stylesheets/sgmltools/print.dsl:53:6:E:&nbsp;3rd&nbsp;argument&nbsp;for&nbsp;primitive&nbsp;&quot;string-append&quot;&nbsp;of&nbsp;wrong&nbsp;type:&nbsp;&quot;#f&quot;&nbsp;not&nbsp;a&nbsp;string:
</term><listitem><para>This is probably caused because %graphic-default-extension% <indexterm><primary>%graphic-default-extension%</primary></indexterm>is set to &ldquo;false&rdquo; (&ldquo;#f&rdquo;), while in <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink> we try to concatenate the %admon-graphics-path%,<indexterm><primary>%admon-graphics-path%</primary></indexterm> the name of the admonition <indexterm><primary>admonition</primary></indexterm>and %graphic-default-extension% <indexterm><primary>%graphic-default-extension%</primary></indexterm>to a full name of the admonition <indexterm><primary>admonition</primary></indexterm>graphic. It is harmless, due to the way we use the graphics (see <xref linkend="explain-figures">).</para></listitem></varlistentry><varlistentry><term>Warning:&nbsp;Version&nbsp;of&nbsp;thumbpdf.tex'&nbsp;does&nbsp;not&nbsp;match&nbsp;with&nbsp;perl&nbsp;script!:
</term><listitem><para>thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>complains even if the version is a newer one:</para><screen><![CDATA[*** make `thumbpdf.pdf' / run pdfTeX ***
]]><![CDATA[!!! Warning: Version of `thumbpdf.tex' does not match with perl script!
]]><![CDATA[Current `thumbpdf.tex': 2002/05/26 v3.2
]]><![CDATA[Please install version: 2001/01/12 v2.8
]]></screen><para>But if you have the newest version, as in the above case, there is no need to worry about this error. </para></listitem></varlistentry><varlistentry><term>end&nbsp;tag&nbsp;for&nbsp;&quot;SECT1&quot;&nbsp;which&nbsp;is&nbsp;not&nbsp;finished:
</term><listitem><para>You may see this openjade <indexterm><primary>openjade</primary></indexterm>error also for &ldquo;SECT2&rdquo;, &ldquo;SECT3&rdquo; and so forth. This may come up if you have written just the title of the section, subsection<indexterm><primary>subsection</primary></indexterm> or subsubsection <indexterm><primary>subsubsection</primary></indexterm>respectively, but you did not enter any text there. Just enter something, even a single word like &ldquo;FIXME&rdquo; (author's note to himself: this is a literal FIXME,<indexterm><primary>FIXME</primary></indexterm> not a meta-FIXME!), to remind you of the missing text, and the error should go away.</para></listitem></varlistentry><varlistentry><term>document&nbsp;type&nbsp;does&nbsp;not&nbsp;allow&nbsp;element&nbsp;&quot;SECT2&quot;&nbsp;here:
</term><listitem><para>This is a similar error to the previous one. You most probably created a subsection <indexterm><primary>subsection</primary></indexterm>which is not contained in a section, but is dircetly contained in a chapter. Similar errors will occur if you ommit environment <indexterm><primary>environment</primary></indexterm>levels that are &ldquo;in between&rdquo; the current one and its parent.</para></listitem></varlistentry><varlistentry><term>length&nbsp;of&nbsp;name&nbsp;token&nbsp;must&nbsp;not&nbsp;exceed&nbsp;NAMELEN&nbsp;(44):
</term><listitem><para>You have an <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>on the line where this error comes up - and this <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>is too long, longer than NAMELEN, which is 44 in my case. Use a shorter <acronym>ID</acronym>.<indexterm><primary>ID</primary></indexterm> What in SGL comes as the <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>of a chapter, section, figure or table, in LyX <indexterm><primary>LyX</primary></indexterm>it is a label.<indexterm><primary>label</primary></indexterm> Thus you should check your labels and make sure they are not longer than 44 characters.</para><para>Alternatively, change the value of NAMELEN in the file pointed to by the SGMDCL directive <indexterm><primary>directive</primary></indexterm>in your catalog <indexterm><primary>catalog</primary></indexterm>files: The <ulink url="lyxtox">lyxtox</ulink> script uses, among others, the following catalog:<indexterm><primary>catalog</primary></indexterm> /usr/share/sgml/CATALOG.docbook-dsssl-stylesheets. You can see this in the line: </para><screen><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES: /usr/share/sgml/CATALOG.docbook-dsssl-stylesheets" 
]]></screen><para>In this catalog,<indexterm><primary>catalog</primary></indexterm> I have changed the SGMLDECL line from:</para><screen><![CDATA[-- SGMLDECL "dtds/decls/docbook.dcl" --
]]></screen><para>to</para><screen><![CDATA[SGMLDECL "/usr/share/sgml/docbook/docbook-dsssl-stylesheets/dtds/decls/docbook.dcl"
]]></screen><para>to reflect the correct path <indexterm><primary>path</primary></indexterm>to the DocBook <indexterm><primary>DocBook</primary></indexterm>declaration file in my system. You must thus change the value of the NAMELEN variable in the file where the SGMLDECL points to, i.e.<footnote><para>Note that this may be specific to <productname>SuSE</productname> 9.0. Other distributions may have corrected it.</para></footnote> docbook/docbook-dsssl-stylesheets/dtds/decls/docbook.dcl. There, change </para><screen><![CDATA[        QUANTITY SGMLREF
]]><![CDATA[                ATTCNT    256
]]><![CDATA[                GRPCNT    253
]]><![CDATA[                GRPGTCNT  253
]]><![CDATA[                LITLEN   8092
]]><![CDATA[                NAMELEN    44
]]><![CDATA[                TAGLVL    100
]]></screen><para>to, for example: </para><screen><![CDATA[        QUANTITY SGMLREF
]]><![CDATA[                ATTCNT    256
]]><![CDATA[                GRPCNT    253
]]><![CDATA[                GRPGTCNT  253
]]><![CDATA[                LITLEN   8092
]]><![CDATA[                NAMELEN    64
]]><![CDATA[                TAGLVL    100
]]><![CDATA[
]]></screen><para>See the error 'character&nbsp;&quot;_&quot;&nbsp;is_not&nbsp;allowed&nbsp;in&nbsp;the&nbsp;value&nbsp;of&nbsp;attribute&nbsp;&quot;ID&quot;' below for more changes you might need to make in the DocBook <indexterm><primary>DocBook</primary></indexterm>declaration file.</para></listitem></varlistentry><varlistentry><term>character&nbsp;&quot;:&quot;&nbsp;is_not&nbsp;allowed&nbsp;in&nbsp;the&nbsp;value&nbsp;of&nbsp;attribute&nbsp;&quot;ID&quot;:
</term><listitem><para>You have a LyX <indexterm><primary>LyX</primary></indexterm>label<indexterm><primary>label</primary></indexterm> that contains &ldquo;:&rdquo;. Delete the &ldquo;:&rdquo; , as the label <indexterm><primary>label</primary></indexterm>of a chapter, section, figure, table etc. is going to be the <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>of that element <indexterm><primary>element</primary></indexterm>and &ldquo;:&rdquo; is not allowed in IDs. However, this only the short answer. For an in-depth explanation, see the next item.</para></listitem></varlistentry><varlistentry><term>character&nbsp;&quot;_&quot;&nbsp;is_not&nbsp;allowed&nbsp;in&nbsp;the&nbsp;value&nbsp;of&nbsp;attribute&nbsp;&quot;ID&quot;:
</term><listitem><para>You have a LyX <indexterm><primary>LyX</primary></indexterm>label<indexterm><primary>label</primary></indexterm> that contains &ldquo;_&rdquo;. Delete the &ldquo;_&rdquo; , as the label <indexterm><primary>label</primary></indexterm>of a chapter, section, figure, table etc. is going to be the <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>of that element <indexterm><primary>element</primary></indexterm>and &ldquo;_&rdquo; is not allowed in IDs. However, as said in the previous item, this is only the tip of the iceberg. A tip of the hat to Tony Graham for the following detailed information in <ulink url="http://www.biglist.com/lists/dssslist/archives/199804/msg00175.html">Allowed characters in element id's</ulink>!</para><para>The characters allowed in an <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>are those allowed in an SGML <indexterm><primary>SGML</primary></indexterm>&quot;NAME&quot;. The characters that are allowed to appear in &ldquo;names&rdquo; in SGML <indexterm><primary>SGML</primary></indexterm>(the id attribute <indexterm><primary>attribute</primary></indexterm>is defined in SGML <indexterm><primary>SGML</primary></indexterm>as such a &ldquo;NAME&rdquo;) are set in what is known as the &ldquo; SGML <indexterm><primary>SGML</primary></indexterm>declaration<ulink url="http://home.chello.no/~mgrsby/sgmlintr/sgmldec.htm">SGML declaration</ulink>&rdquo; of your document.<indexterm><primary>document</primary></indexterm> By default, the first character must be a letter, and any other characters may be a letter or a digit.</para><para>You can add to this by specifying the additional characters in your SGML<indexterm><primary>SGML</primary></indexterm> Declaration (and you can't take any characters away). The convention in widest use is that of the &quot;Reference concrete syntax&quot; included in the SGML <indexterm><primary>SGML</primary></indexterm>standard itself that adds &quot;.&quot; and &quot;-&quot; as &quot;name&quot; characters (but not as &quot;name start&quot; characters). This is what's used in the DocBook <indexterm><primary>DocBook</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>Declaration, docbook.dcl.</para><para>The specific portion of the SGML <indexterm><primary>SGML</primary></indexterm>Declaration of interest here is the &quot;naming rules&quot;. Jade's default inferred SGML <indexterm><primary>SGML</primary></indexterm>Declaration uses the same naming rules<indexterm><primary>rules</primary></indexterm> as SGML's &quot;Reference Concrete Syntax&quot;. To allow underscores in entity <indexterm><primary>entity</primary></indexterm>names (and other SGML <indexterm><primary>SGML</primary></indexterm>names), you need to supply an SGML <indexterm><primary>SGML</primary></indexterm>Declaration that includes the underscore character. Using the DocBook <indexterm><primary>DocBook</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>Declaration as an example, you need to add &quot;_&quot; to the LCNMSTRT and UCNMSTRT parameters:</para><screen><![CDATA[        NAMING
]]><![CDATA[                LCNMSTRT ""
]]><![CDATA[                UCNMSTRT ""
]]><![CDATA[                LCNMCHAR ".-"
]]><![CDATA[                UCNMCHAR ".-"
]]><![CDATA[                NAMECASE
]]><![CDATA[                        GENERAL YES
]]><![CDATA[                        ENTITY  NO
]]></screen><para>The NAMING portion specifies both uppercase and lowercase forms of the additional &quot;name start&quot; and &quot;name&quot; characters (since names are folded to uppercase when the &quot;GENERAL&quot; parameter <indexterm><primary>parameter</primary></indexterm>has the value YES&quot;). You need to add it in two places because you are declaring the uppercase and lowercase forms, which just happen to be the same.</para><para>You can reference your SGML <indexterm><primary>SGML</primary></indexterm>Declaration by including it in the Jade<indexterm><primary>Jade</primary></indexterm> command line before the filename for your SGML <indexterm><primary>SGML</primary></indexterm>file (or before your DTD <indexterm><primary>DTD</primary></indexterm>if also including the DTD<indexterm><primary>DTD</primary></indexterm> filename in the command line). You can also reference an SGML <indexterm><primary>SGML</primary></indexterm>Declaration to infer by using the &quot;SGMLDECL&quot; keyword <indexterm><primary>keyword</primary></indexterm>in your catalog <indexterm><primary>catalog</primary></indexterm>file. (See &quot;charset.htm&quot; from the nsgmls distribution <indexterm><primary>distribution</primary></indexterm>for more information on the catalog <indexterm><primary>catalog</primary></indexterm>format. FIXME:<indexterm><primary>FIXME</primary></indexterm> URL!)</para><para>Now, what does all that mean for our specific situation?</para><para>The <ulink url="lyxtox">lyxtox</ulink> script uses, among others, the following catalog:<indexterm><primary>catalog</primary></indexterm> /usr/share/sgml/CATALOG.docbook-dsssl-stylesheets. You can see this in the line: </para><screen><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES: /usr/share/sgml/CATALOG.docbook-dsssl-stylesheets" 
]]></screen><para>In this catalog,<indexterm><primary>catalog</primary></indexterm> change the SGMLDECL line from:</para><screen><![CDATA[-- SGMLDECL "dtds/decls/docbook.dcl" --
]]></screen><para>to</para><screen><![CDATA[SGMLDECL "/usr/share/sgml/docbook/docbook-dsssl-stylesheets/dtds/decls/docbook.dcl"
]]></screen><para>Note that we have taken away the comments and corrected the path <indexterm><primary>path</primary></indexterm>to the declaration.</para><para>But that's NOT enough!</para><para>You must also change the file where the SGMLDECL points to, i.e.<footnote><para>Note that this may be specific to <productname>SuSE</productname> 9.0. Other distributions may have corrected it.</para></footnote> docbook/docbook-dsssl-stylesheets/dtds/decls/docbook.dcl. There, change </para><screen><![CDATA[        NAMING
]]><![CDATA[                LCNMSTRT ""
]]><![CDATA[                UCNMSTRT ""
]]><![CDATA[                LCNMCHAR ".-"
]]><![CDATA[                UCNMCHAR ".-"
]]><![CDATA[                NAMECASE
]]><![CDATA[                        GENERAL YES
]]><![CDATA[                        ENTITY  NO
]]></screen><para>to:</para><screen><![CDATA[        NAMING
]]><![CDATA[                LCNMSTRT ""
]]><![CDATA[                UCNMSTRT ""
]]><![CDATA[                LCNMCHAR ".-_"
]]><![CDATA[                UCNMCHAR ".-_"
]]><![CDATA[                NAMECASE
]]><![CDATA[                        GENERAL YES
]]><![CDATA[                        ENTITY  NO
]]></screen><para>i.e. add the underscore to LCNMCHAR and UCNMCHAR.</para><para>This solves the problem at its root! See also <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=872">character "_" not allowed in value of attribute ID</ulink>.</para></listitem></varlistentry><varlistentry><term>general_entity_&quot;d_op&quot;_not_defined_and_no_default_entity:
</term><listitem><para>When you enter an URL <indexterm><primary>URL</primary></indexterm>in LyX,<indexterm><primary>LyX</primary></indexterm> you are asked to enter the URL <indexterm><primary>URL</primary></indexterm>and the Name of the link in a window that pops up. Whatever you enter in the URL <indexterm><primary>URL</primary></indexterm>field, will be automatically <indexterm><primary>automatically</primary></indexterm>taken care by LyX:<indexterm><primary>LyX</primary></indexterm> if it contains special characters, like ampersands,<indexterm><primary>ampersands</primary></indexterm> they are replaced with their SGML <indexterm><primary>SGML</primary></indexterm>equivalent (see <ulink url="http://www.ncbi.nlm.nih.gov/entrez/query/static/entities.html">SGML entities</ulink>). But whatever you enter in the Name field, it will passed &ldquo;as is&rdquo; to SGML.<indexterm><primary>SGML</primary></indexterm> If you feel lazy and just copy the URL <indexterm><primary>URL</primary></indexterm>in the Name field, you must take care to replace special characters with their SGML <indexterm><primary>SGML</primary></indexterm>entities yourself. Dynamic URLs are a classic example and are going to flood you with this error, if you do not do your homework. For example, if you feel you have to write something like</para><screen><![CDATA[http://www.karakas-online.de/forum/viewtopic.php?t=14&f=3
]]></screen><para>instead of </para><screen><![CDATA[Welcome to the <productname>Linux</productname> Forum of Chris
]]></screen><para>then you should write it as</para><screen><![CDATA[http://www.karakas-online.de/forum/viewtopic.php?t=14&amp;f=3
]]></screen><para>i.e. replace &ldquo;&amp;&rdquo; with its SGML <indexterm><primary>SGML</primary></indexterm>entity &ldquo;&amp;amp;&rdquo;.</para></listitem></varlistentry><varlistentry><term>element&nbsp;&quot;BODY&quot;&nbsp;undefined:
</term><listitem><para>BODY? Which body?<indexterm><primary>body</primary></indexterm> You don't remember to have entered anything like this in you text? Well, check for &ldquo;&lt;body&gt;&rdquo; somewhere in the text (not the code environments,<indexterm><primary>environments</primary></indexterm> as those have been taken care already by LyX). You have to replace the &ldquo;&lt;&rdquo; and &ldquo;&gt;&rdquo; with their SGML <indexterm><primary>SGML</primary></indexterm>entities &ldquo;&amp;lt;&rdquo; and &ldquo;&amp;gt&rdquo; respectively. When you correct it, the other two errors</para><screen><![CDATA[end tag for "BODY" omitted, but OMITTAG NO was specified
]]><![CDATA[start tag was here
]]></screen><para>will disappear too, since they are just follow-ups of the first one.</para></listitem></varlistentry><varlistentry><term>character&nbsp;data&nbsp;is&nbsp;not&nbsp;allowed&nbsp;here:
</term><listitem><para>This simply means that you did not replace some special character with its SGML <indexterm><primary>SGML</primary></indexterm>entity. Have a look at the tables in <ulink url="http://www.ncbi.nlm.nih.gov/entrez/query/static/entities.html">SGML entities</ulink>, try to guess which character is meant in the error (the SGML <indexterm><primary>SGML</primary></indexterm>lines produced by LyX <indexterm><primary>LyX</primary></indexterm>can become longer than Proust's), and replace it.</para><para>But the reason for this error may also lie in the fact that you forgot to change the LyX <indexterm><primary>LyX</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>(see <xref linkend="LyX-environments">) from SGML <indexterm><primary>SGML</primary></indexterm>to Standard and the text contains some special characters, like dashes. In this case, the text is interpreted <indexterm><primary>interpreted</primary></indexterm>in the SGML <indexterm><primary>SGML</primary></indexterm>context and the special characters give rise to misunderstandings and errors in th parser.<indexterm><primary>parser</primary></indexterm> Just change the environment <indexterm><primary>environment</primary></indexterm>from SGML <indexterm><primary>SGML</primary></indexterm>back to Standard (or whatever else it should be) and the error will disappear.</para></listitem></varlistentry><varlistentry><term>document&nbsp;type&nbsp;does&nbsp;not&nbsp;allow&nbsp;element&nbsp;&quot;MEDIAOBJECT&quot;&nbsp;here:
</term><listitem><para>This error happens because sed (more precisely, the sed commands in <ulink url="sedscr">sedscr</ulink>) did not manage to change the SGML <indexterm><primary>SGML</primary></indexterm>that LyX <indexterm><primary>LyX</primary></indexterm>produced for a figure. The reason <ulink url="sedscr">sedscr</ulink> failed lies probably in some strange arrangement of the starting SGML <indexterm><primary>SGML</primary></indexterm>tags for the figure. The best cure is to enter a &ldquo;forced new line&rdquo; by pressing Strg+Enter at the end of the line that precedes the offending figure. This will force the whole SGML <indexterm><primary>SGML</primary></indexterm>code to start on a new line and will make identification <indexterm><primary>identification</primary></indexterm>by <ulink url="sedscr">sedscr</ulink> easier. The next time you run <ulink url="lyxtox">lyxtox</ulink>, the correct SGML <indexterm><primary>SGML</primary></indexterm>commands for the figure will be generated and the error will disappear.</para></listitem></varlistentry><varlistentry><term>an&nbsp;attribute&nbsp;value&nbsp;must&nbsp;be&nbsp;a&nbsp;literal&nbsp;unless&nbsp;it&nbsp;contains&nbsp;only&nbsp;name&nbsp;characters:
</term><listitem><para>How on earth could this happen? Well, if you are like me and always try new possibilities with LyX <indexterm><primary>LyX</primary></indexterm>and SGML,<indexterm><primary>SGML</primary></indexterm> then you will encounter this error if you enter an URL <indexterm><primary>URL</primary></indexterm>while in the SGML<indexterm><primary>SGML</primary></indexterm> environment.<indexterm><primary>environment</primary></indexterm> There, of course, you cannot just use LyX' menu Insert-&gt;URL - you have to write the SGML <indexterm><primary>SGML</primary></indexterm>code for an URL <indexterm><primary>URL</primary></indexterm>&amp;lt;ulink url=&rdquo;http://www.somesite.com&rdquo;&amp;gt;. Now, if you forget to enclose the URL <indexterm><primary>URL</primary></indexterm>(the &ldquo; attribute <indexterm><primary>attribute</primary></indexterm>value&rdquo;, as the error says, of the &ldquo;url&rdquo; attribute <indexterm><primary>attribute</primary></indexterm>in the ulink element) in double quotes, then you will get that error.</para></listitem></varlistentry><varlistentry><term>document&nbsp;type&nbsp;does&nbsp;not&nbsp;allow&nbsp;element&nbsp;&lt;para&gt;&nbsp;(after&nbsp;&lt;entry&gt;&nbsp;in&nbsp;a&nbsp;table):
</term><listitem><para>You shouldn't get this error when you use the scripts desribed here - simply because the <ulink url="sedscr&amp;lowbar;tidy2">sedscr_tidy2</ulink> script takes care that it does not occur. However, if you do get it, it is nice to know why:</para><para>Due to the way the SGML <indexterm><primary>SGML</primary></indexterm>parser works, the following piece of code describing an informal table will produce a &ldquo; document <indexterm><primary>document</primary></indexterm>type does not allow element<indexterm><primary>element</primary></indexterm> &lt;para&gt;&rdquo; error:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1004;" format="linespecific"><![CDATA[
]]></screen><para>The reason is the so-called &ldquo;Pernicious Mixed Content Problem&rdquo;. From the <ulink url="http://www.docbook.org/tdg/en/html/entry.html">Definitive Guide to DocBook on the &lt;entry&gt; element</ulink>:</para><blockquote><para>The content model of the Entry element <indexterm><primary>element</primary></indexterm>exhibits a nasty peculiarity that we call pernicious mixed content.[18]</para><para>Every other element <indexterm><primary>element</primary></indexterm>in DocBook<indexterm><primary>DocBook</primary></indexterm> contains either block elements or inline <indexterm><primary>inline</primary></indexterm>elements (including #PCDATA) unambiguously. In these cases, the meaning of line breaks and spaces are well understood; they are insignificant between block elements and significant (to the SGML <indexterm><primary>SGML</primary></indexterm>parser, anyway) where inline<indexterm><primary>inline</primary></indexterm> markup<indexterm><primary>markup</primary></indexterm> can occur.</para><para>Table entries are different; they can contain either block or inline <indexterm><primary>inline</primary></indexterm>elements, but not both at the same time. In other words, one Entry in a table might contain a paragraph <indexterm><primary>paragraph</primary></indexterm>or a list while another contains simply #PCDATA or another inline <indexterm><primary>inline</primary></indexterm>markup,<indexterm><primary>markup</primary></indexterm> but no single Entry can contain both.</para><para>Because the content model of an Entry allows both kinds of markup,<indexterm><primary>markup</primary></indexterm> each time the SGML <indexterm><primary>SGML</primary></indexterm>parser encounters an Entry, it has to decide what variety of markup <indexterm><primary>markup</primary></indexterm>it contains. SGML <indexterm><primary>SGML</primary></indexterm>parsers are forbidden to use more than a single token<indexterm><primary>token</primary></indexterm> of lookahead to reach this decision. In practical terms,<indexterm><primary>terms</primary></indexterm> what this means is that a line feed or space after an Entry start tag causes the parser <indexterm><primary>parser</primary></indexterm>to decide that the cell contains inline<indexterm><primary>inline</primary></indexterm> markup.<indexterm><primary>markup</primary></indexterm> Subsequent discovery of a paragraph <indexterm><primary>paragraph</primary></indexterm>or another block element <indexterm><primary>element</primary></indexterm>causes a parsing error.</para><para>All of these are legal:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1005;" format="linespecific"><![CDATA[
]]></screen><para>However, each of these is an error:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1006;" format="linespecific"><![CDATA[
]]></screen></blockquote><para>Thus, the informal table example above must be corrected to:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1007;" format="linespecific"><![CDATA[
]]></screen><para>This is done in <ulink url="lyxtox">lyxtox</ulink> with a call to <ulink url="runsed">runsed</ulink> using <ulink url="sedscr&amp;lowbar;tidy2">sedscr_tidy2</ulink> as the sed script. See also <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=965">Openjade error: &lt;para&gt; not allowed after &lt;entry&gt;</ulink>.</para></listitem></varlistentry></variablelist></sect1>
<sect1 id="tex-errors"><title>TeX errors</title><para>The material in this section (up to <xref linkend="structure-of-TeX-errors">) is taken from the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>FAQ <indexterm><primary>FAQ</primary></indexterm>item on <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=erroradvice">How to approach errors</ulink>.</para><para>Since <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>is a macroprocessor,<indexterm><primary>macroprocessor</primary></indexterm> its error messages are often difficult to understand; this is a (seemingly invariant) property of macroprocessors.<indexterm><primary>macroprocessors</primary></indexterm> Knuth<indexterm><primary>Knuth</primary></indexterm> makes light of the problem in the TeXbook,<indexterm><primary>TeXbook</primary></indexterm> suggesting that you acquire the sleuthing skills <indexterm><primary>skills</primary></indexterm>of a latter-day Sherlock Holmes;<indexterm><primary>Holmes</primary></indexterm> while this approach<indexterm><primary>approach</primary></indexterm> has a certain romantic charm to it, it's not good for the 'production' user of (La)TeX. The following (derived, in part, from an article by Sebastian Rahtz<indexterm><primary>Rahtz</primary></indexterm> in TUGboat 16(4)) offers some general guidance in dealing with TeX<indexterm><primary>TeX</primary></indexterm> error reports, and other answers in this section deal with common (but perplexing) errors that you may encounter. There's a long list of &quot;hints&quot; in Sebastian's article, including the following:</para><itemizedlist><listitem><para>Look at <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>errors; those messages may seem cryptic at first, but they often contain a straightforward clue to the problem. See <xref linkend="structure-of-TeX-errors"> for further details. </para></listitem><listitem><para>Read the .log file; it contains hints to things you may not understand, often things that have not even presented as error messages. </para></listitem><listitem><para>Be aware of the amount of context that <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>gives you. The error messages gives you some bits of <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code (or of the document<indexterm><primary>document</primary></indexterm> itself), that show where the error &quot;actually happened&quot;; it's possible to control how much of this 'context' <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>actually gives you. LaTeX<indexterm><primary>LaTeX</primary></indexterm> (nowadays) instructs <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>only to give you one line of context, but you may tell it otherwise by saying</para><screen><![CDATA[\setcounter{errorcontextlines}{999}
]]></screen><para>in the preamble<indexterm><primary>preamble</primary></indexterm> of your document.<indexterm><primary>document</primary></indexterm> (If you're not a confident macro <indexterm><primary>macro</primary></indexterm>programmer, don't be ashamed of cutting that 999 down a bit; some errors will go on and on, and spotting the differences between those lines can be a significant challenge.) </para></listitem><listitem><para>As a last resort, tracing can be a useful tool; reading a full (La)TeX trace<indexterm><primary>trace</primary></indexterm> takes a strong constitution,<indexterm><primary>constitution</primary></indexterm> but once you know how, the trace <indexterm><primary>trace</primary></indexterm>can lead you quickly to the source of a problem. You need to have read the TeXbook <indexterm><primary>TeXbook</primary></indexterm>(see <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=books">books about TeX</ulink>) in some detail, fully to understand the trace.<indexterm><primary>trace</primary></indexterm></para><para>The command </para><screen><![CDATA[\tracingall 
]]></screen><para>sets up maximum tracing. <indexterm><primary>tracing.</primary></indexterm>it also sets the output to come to the interactive terminal, which is somewhat of a mixed blessing (since the output tends to be so vast - all but the simplest traces are best examined in a text editor after the event).</para><para>The <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>trace package (first distributed with the 2001 release of LaTeX) provides more manageable tracing.<indexterm><primary>tracing.</primary></indexterm> Its \ traceon <indexterm><primary>traceon</primary></indexterm>command gives you what \tracingall offers, but suppresses tracing around some of the truly verbose parts of <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>itself. The package also provides a \traceoff command (there's no &quot;off&quot; command for \tracingall), and a package option (logonly) allows you to suppress output to the terminal. </para></listitem></itemizedlist><para>The best advice to those faced with <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>errors is not to panic: most of the common errors are plain to the eye when you go back to the source line that <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>tells you of. If that approach <indexterm><primary>approach</primary></indexterm>doesn't work, the remaining answers in this section deal with some of the most common error messages you may encounter using LyX<indexterm><primary>LyX</primary></indexterm> and a <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>system provided  by a common <productname>Linux</productname> distribution <indexterm><primary>distribution</primary></indexterm>as your starting point. For more on <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>errors, consult the &ldquo;Joy of <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>errors&rdquo; section of the <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes">TeX FAQ</ulink>. You should not ordinarily need to appeal to the wider public for assistance (see <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=maillists">TeX mailing lists</ulink>), but if you do, be sure to report full backtraces (see errorcontextlines<indexterm><primary>errorcontextlines</primary></indexterm> above) and so on.</para><sect2 id="structure-of-TeX-errors"><title>The structure of <application>TeX</application> errors</title><para>The material in this section is taken from <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=errstruct">the structure of <application>TeX</application> errors</ulink>.</para><para>TeX's error messages are reminiscent of the time when <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>itself was conceived (the 1970s): they're not terribly user-friendly, though they do contain all the information that <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>can offer, usually in a pretty concise way.</para><para>TeX's error reports all have the same structure:</para><itemizedlist><listitem><para>An error message</para></listitem><listitem><para>Some 'context'</para></listitem><listitem><para>An error prompt</para></listitem></itemizedlist><para>The error message will relate to the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>condition that is causing a problem. Sadly, in the case of complex macro <indexterm><primary>macro</primary></indexterm>packages <indexterm><primary>packages</primary></indexterm>such as LaTeX,<indexterm><primary>LaTeX</primary></indexterm> the underlying <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>problem may be superficially difficult to relate to the actual problem in the &quot;higher-level&quot; macros. Many LaTeX-detected problems manifest themselves as 'generic' errors, with error text provided by <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>itself (or by a <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>class or package).</para><para>The context of the error is a stylised representation <indexterm><primary>representation</primary></indexterm>of what <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>was doing at the point that it detected the error. As noted in approaching errors, a macro <indexterm><primary>macro</primary></indexterm>package can tell <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>how much context to display, and the user may need to undo what the package has done. Each line of context is split at the point of the error; if the error actually occurred in a macro <indexterm><primary>macro</primary></indexterm>called from the present line, the break is at the point of the call. (If the called object is defined with arguments, the &quot;point of call&quot; is after all the arguments have been scanned.) For example:</para><screen><![CDATA[\blah and so on
]]></screen><para>produces the error report</para><screen><![CDATA[! Undefined control sequence.
]]><![CDATA[l.4 \blah
]]><![CDATA[          and so on
]]></screen><para>while:</para><screen><![CDATA[\newcommand{\blah}[1]{\bleah #1}
]]><![CDATA[\blah{to you}, folks
]]></screen><para>produces the error report</para><screen><![CDATA[! Undefined control sequence.
]]><![CDATA[\blah #1->\bleah
]]><![CDATA[                 #1
]]><![CDATA[l.5 \blah{to you}
]]><![CDATA[                 , folks
]]></screen><para>If the argument itself is in error, we will see things such as</para><screen><![CDATA[\newcommand{\blah}[1]{#1 to you}
]]><![CDATA[\blah{\bleah}, folks
]]></screen><para>producing</para><screen><![CDATA[! Undefined control sequence.
]]><![CDATA[<argument> \bleah
]]><![CDATA[l.5 \blah{\bleah}
]]><![CDATA[                 , folks
]]></screen><para>The prompt accepts single-character <indexterm><primary>single-character</primary></indexterm>commands: the list of what's available may be had by typing <indexterm><primary>typing</primary></indexterm>?. One immediately valuable command is h, which gives you an expansion of TeXs original prcis message, sometimes accompanied by a hint on what to do to work round the problem in the short term. If you simply type 'return' (or whatever else your system uses to signal the end of a line) at the prompt, <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>will attempt to carry on (often with rather little success).</para></sect2>
<sect2 id="LaTeX-errors"><title>LaTeX errors</title><para>LaTeX <indexterm><primary>LaTeX</primary></indexterm>output can be very verbose. Just for your reference, here is a (rather long) example of output (taken from the .log file that is created each time anew from every program involved in the process that uses <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>in the background)<footnote><para>The example is from the processing of <ulink url="http://www.karakas-online.de/EN-Book/EN-Book.lyx">the LyX file for the <application>PHP-Nuke</application> HOWTO</ulink>. Visit the <ulink url="http://www.karakas-online.de/EN-Book/">Homepage of the <application>PHP-Nuke</application> HOWTO</ulink> to see the result. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
</footnote>:</para><screen><![CDATA[This is TeX, Version 3.14159 (Web2C 7.3.1) (format=jadetex 2001.10.25)  7 JAN 2004 07:26
]]><![CDATA[**EN-Book.tex
]]><![CDATA[(EN-Book.tex
]]><![CDATA[JadeTeX 2001/07/19: 3.11
]]><![CDATA[LaTeX Font Info:    Try loading font information for T1+ptm on input line 1.
]]><![CDATA[(/usr/share/texmf/tex/latex/psnfss/t1ptm.fd
]]><![CDATA[File: t1ptm.fd 2000/01/12 PSNFSS-v8.1 font definitions for T1/ptm. 
]]><![CDATA[)
]]><![CDATA[(jadetex.cfg (/usr/share/texmf/tex/generic/babel/babel.sty
]]><![CDATA[Package: babel 2001/03/01 v3.7h The Babel package
]]><![CDATA[(/usr/share/texmf/tex/generic/babel/english.ldf
]]><![CDATA[Language: english 2001/02/07 v3.3k English support from the babel system
]]><![CDATA[(/usr/share/texmf/tex/generic/babel/babel.def
]]><![CDATA[File: babel.def 2001/03/01 v3.7h Babel common definitions
]]><![CDATA[\babel@savecnt=\count114
]]><![CDATA[\U@D=\dimen131
]]><![CDATA[)
]]><![CDATA[\l@canadian = a dialect from \language\l@english 
]]><![CDATA[))
]]><![CDATA[(/usr/share/texmf/tex/generic/thumbpdf/thumbpdf.sty
]]><![CDATA[Package: thumbpdf 2001/04/02 v2.10 Inclusion of thumbnails (HO)
]]><![CDATA[Package thumbpdf Warning: You need pdfTeX in PDF mode for driver `pdftex'. 
]]><![CDATA[) (/usr/share/texmf/tex/latex/ae/ae.sty
]]><![CDATA[Package: ae 1998/11/17 1.0 Almost European Computer Modern
]]><![CDATA[(/usr/share/texmf/tex/latex/base/fontenc.sty
]]><![CDATA[Package: fontenc 2000/08/30 v1.91 Standard <application>LaTeX</application> package
]]><![CDATA[(/usr/share/texmf/tex/latex/base/t1enc.def
]]><![CDATA[File: t1enc.def 2000/08/30 v1.91 Standard <application>LaTeX</application> file
]]><![CDATA[LaTeX Font Info:    Redeclaring font encoding T1 on input line 38. 
]]><![CDATA[)
]]><![CDATA[LaTeX Font Info:    Try loading font information for T1+aer on input line 96.
]]><![CDATA[(/usr/share/texmf/tex/latex/ae/t1aer.fd
]]><![CDATA[File: t1aer.fd 1997/11/16 Font definitions for T1/aer.
]]><![CDATA[)))
]]><![CDATA[(/usr/share/texmf/tex/latex/ae/aecompl.sty 
]]><![CDATA[Package: aecompl 1998/07/23 0.9 T1 Complements for AE fonts (D. Roegel) 
]]><![CDATA[)
]]><![CDATA[Package hyperref Info: Option `plainpages' set `false' on input line 128.
]]><![CDATA[Package hyperref Info: Option `colorlinks' set `true' on input line 128.
]]><![CDATA[Package hyperref Info: Option `bookmarksopen' set `true' on input line 128.
]]><![CDATA[Package hyperref Info: Option `colorlinks' set `true' on input line 128.
]]><![CDATA[Package hyperref Info: Option `breaklinks' set `true' on input line 128.
]]><![CDATA[Package hyperref Warning: Option `pagebackref' has already been used,
]]><![CDATA[(hyperref)                setting the option has no effect on input line 128.
]]><![CDATA[)
]]><![CDATA[Elements will be labelled
]]><![CDATA[Jade begin document sequence at 19
]]></screen><para>As you can see from the last line, Jade just started its work. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<para>It goes on with font checking as follows:</para><screen><![CDATA[(EN-Book.aux)
]]><![CDATA[\openout1 = `EN-Book.aux'.
]]><![CDATA[LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for PD1/pdf/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for T2A/cmr/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    Try loading font information for T2A+cmr on input line 19.
]]><![CDATA[ (/usr/share/texmf/tex/latex/cyrillic/t2acmr.fd
]]><![CDATA[File: t2acmr.fd 1999/01/07 v1.0 Computer Modern Cyrillic font definitions
]]><![CDATA[)
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    Try loading font information for TS1+cmr on input line 19.
]]><![CDATA[(/usr/share/texmf/tex/latex/base/ts1cmr.fd
]]><![CDATA[File: ts1cmr.fd 1999/05/25 v2.5h Standard <application>LaTeX</application> font definitions
]]><![CDATA[)
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LECO/omseco/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LECX/omsecx/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LECY/omsecy/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LEGR/omsegr/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LEHA/omseha/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LEIP/omseip/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LELA/omsela/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[LaTeX Font Info:    Checking defaults for LETI/omseti/m/n on input line 19.
]]><![CDATA[LaTeX Font Info:    ... okay on input line 19.
]]><![CDATA[Package hyperref Info: Link coloring ON on input line 19.
]]><![CDATA[(/usr/share/texmf/tex/latex/hyperref/nameref.sty
]]><![CDATA[Package: nameref 2000/05/08 v2.18 Cross-referencing by name of section
]]><![CDATA[\c@section@level=\count115
]]><![CDATA[)
]]><![CDATA[LaTeX Info: Redefining \ref on input line 19.
]]><![CDATA[LaTeX Info: Redefining \pageref on input line 19.
]]><![CDATA[LaTeX Font Info:    Try loading font information for T1+aess on input line 99.
]]><![CDATA[(/usr/share/texmf/tex/latex/ae/t1aess.fd
]]><![CDATA[File: t1aess.fd 1997/11/16 Font definitions for T1/aess.
]]><![CDATA[) [1.0.37]
]]><![CDATA[File: logo1.eps Graphic file (type eps)
]]><![CDATA[ <logo1.eps>
]]><![CDATA[File: logo2.eps Graphic file (type eps)
]]><![CDATA[ <logo2.eps>
]]><![CDATA[Overfull \hbox (2655.0092pt too wide) in alignment at lines 610--899
]]></screen><para>Somewhere from this point on, you will start seeing <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>the pages of your document <indexterm><primary>document</primary></indexterm>one after the other - and outputting errors and warnings like the &ldquo; Overfull <indexterm><primary>Overfull</primary></indexterm>\hbox&rdquo; above. </para><para>There are some fairly common error messages and warnings. I'll cover those here using material from the chapter on &ldquo; LyX <indexterm><primary>LyX</primary></indexterm>and <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>errors&rdquo; of the Extended Features manual <indexterm><primary>manual</primary></indexterm>for LyX,<indexterm><primary>LyX</primary></indexterm> available from LyX' Help menu. You should look at a good <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>book for a complete listing.</para><itemizedlist><listitem><para>&ldquo;<indexterm><primary>typewriter</primary></indexterm> <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>Warning:&ldquo;</para><para>Anything beginning with these word is a warning message for the purpose of &ldquo;debugging&rdquo; the <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>code itself. You'll get messages like this if you added or changed cross-references or bibliography <indexterm><primary>bibliography</primary></indexterm>entries, in which case, <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>is trying to tell you that you need to make another run.</para><para>You can by-and-large ignore these.</para></listitem><listitem><para>&ldquo;<indexterm><primary>typewriter</primary></indexterm> <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>Font Warning:&rdquo;</para><para>Another warning message, this time about fonts <indexterm><primary>fonts</primary></indexterm>which <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>couldn't find. The rest of the message will often say something about a replacement font that <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>used.</para><para>You can safely ignore these.</para></listitem><listitem><para>&ldquo;<indexterm><primary>typewriter</primary></indexterm> Overfull <indexterm><primary>Overfull</primary></indexterm>\hbox&rdquo;</para><para>LaTeX <indexterm><primary>LaTeX</primary></indexterm>absolutely <emphasis>loves</emphasis> to spew these out. They are warning you about lines that were too long and run past the right margin. Almost always, this is unnoticeable in the final output. Or, only one or two characters extend past the margin. <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>seems to generate at least one of these messages for just about any document <indexterm><primary>document</primary></indexterm>you write.</para><para>You can ignore these stupid messages. Your eyes will tell you if there's a problem with something that's too wide; just look at the output.</para></listitem><listitem><para>&ldquo;<indexterm><primary>typewriter</primary></indexterm> Underfull <indexterm><primary>Underfull</primary></indexterm>\hbox&rdquo;</para><para>Not quite as common as its cousin. <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>seems to like to print lines that are a bit too wide as opposed to ones that are a bit too narrow. We have no idea why.</para><para>You can ignore these, too.</para></listitem><listitem><para>&ldquo;<indexterm><primary>typewriter</primary></indexterm> Overfull <indexterm><primary>Overfull</primary></indexterm>\vbox&rdquo; and &ldquo;<indexterm><primary>typewriter</primary></indexterm> Underfull <indexterm><primary>Underfull</primary></indexterm>\vbox&rdquo;</para><para>Warnings about troubles breaking the page. Once again, just look at the output. Your eyes will tell you where something has gone wrong.</para></listitem><listitem><para>&ldquo; <indexterm><primary>typewriter</primary></indexterm> <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>Error: File &lsquo;Xxxx&rsquo; not found&rdquo; </para><para>The file &ldquo;Xxxx&rdquo; isn't installed on this system. This usually appears because some package your document <indexterm><primary>document</primary></indexterm>needs isn't installed. If you didn't touch the preamble <indexterm><primary>preamble</primary></indexterm>or didn't use the <indexterm><primary>typewriter</primary></indexterm>\usepackage{} command, then one of the packages <indexterm><primary>packages</primary></indexterm>LyX <indexterm><primary>LyX</primary></indexterm>tried to load is missing. Use Help&lyxarrow;La <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>Configuration, to get a list of packages <indexterm><primary>packages</primary></indexterm>that LyX <indexterm><primary>LyX</primary></indexterm>knows about. This file is updated whenever you reconfigure <indexterm><primary>reconfigure</primary></indexterm>LyX (using Edit&lyxarrow;Reconfigure) and tells you which packages <indexterm><primary>packages</primary></indexterm>have been detected and what they do.</para><para>If you <emphasis>did</emphasis> use the <indexterm><primary>typewriter</primary></indexterm>\usepackage{} command, and the package in question isn't installed, you'll need to install it yourself.</para></listitem><listitem><para>&ldquo;<indexterm><primary>typewriter</primary></indexterm> <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>Error: Unknown option&rdquo;</para><para>Error messages beginning with this are trying to tell you that you specified a bad or undefined option to a package. Check the package's documentation.</para></listitem><listitem><para>&ldquo;<indexterm><primary>typewriter</primary></indexterm>Undefined control sequence&rdquo;</para><para>If you've inserted <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>code into your document,<indexterm><primary>document</primary></indexterm> but made a typo, you'll get one of these. You may have forgotten to load a package. In any case, this error message usually means that you used an undefined command.</para></listitem><listitem><para>LaTeX <indexterm><primary>LaTeX</primary></indexterm>Error: Undefined color `rtlred'</para><para>Theoretically, you can define your own colours in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg.<indexterm><primary>jadetex.cfg</primary></indexterm> For example, the following block of code defines three new colours, rtlred, rtlblue and rtlgreen (the green being a bit darker than usual):</para><screen><![CDATA[\usepackage{color}
]]><![CDATA[\definecolor{rltred}{rgb}{0.75,0,0}
]]><![CDATA[\definecolor{rltgreen}{rgb}{0,0.5,0}
]]><![CDATA[\definecolor{rltblue}{rgb}{0,0,0.75}
]]></screen><para>However, no matter where I position this code in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg <indexterm><primary>jadetex.cfg</primary></indexterm>(i.e. either before or after the call to hypersetup), I get the above error. For the time being, my remedy is to stick to the standard colours. Please inform me if you find a better solution.</para><para>Andreas Ekenbäck (private communication) has found that by having double declarations of a colour:</para><screen><![CDATA[\newcmykcolor{abstractYellow}{0.02 0.02 0.35 0.0}
]]><![CDATA[\definecolor{abstractYellow}{cmyk}{0.02,0.02,0.35,0.0}
]]></screen><para>in jadetex.cfg, it works. On his Fedora Core 4 workstation, he says, it is even enough to have the first declaration.</para></listitem></itemizedlist><para>Further reading: see the chapter on &ldquo; LyX <indexterm><primary>LyX</primary></indexterm>and <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>errors&rdquo; of the Extended Features manual <indexterm><primary>manual</primary></indexterm>for LyX <indexterm><primary>LyX</primary></indexterm>for tips on how to handle LaTeX<indexterm><primary>LaTeX</primary></indexterm> errors and warnings.</para></sect2>
<sect2 id="TeX-capacity-exceeded"><title>TeX capacity exceeded</title><para>If you encounter <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>errors, especially </para><screen><![CDATA[TeX capacity exceeded, sorry [main memory size=384000]
]]></screen><para>you may have to set in texmf.cnf <indexterm><primary>texmf.cnf</primary></indexterm>(usually located in /etc/texmf, or where the TEXMFCNF <indexterm><primary>TEXMFCNF</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>variable (see<xref linkend="explain-environment-variables">) shows):</para><screen><![CDATA[main_memory = 3839999
]]><![CDATA[main_memory.jadetex = 4999999
]]><![CDATA[hash_extra.jadetex = 25000
]]><![CDATA[pool_size.jadetex = 500000
]]><![CDATA[save_size.jadetex = 15000
]]><![CDATA[save_size = 8000
]]></screen><para>FYI, here's how much memory <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>used for this document <indexterm><primary>document</primary></indexterm>(you may see such information in the .log file created by pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>which is deleted by default in <ulink url="lyxtox">lyxtox</ulink>):</para><screen><![CDATA[Here is how much of TeX's memory you used:
]]><![CDATA[ 4847 strings out of 15997
]]><![CDATA[ 36267 string characters out of 99016
]]><![CDATA[ 163640 words of memory out of 384000
]]><![CDATA[ 15827 multiletter control sequences out of 10000+15000
]]><![CDATA[ 68666 words of font info for 129 fonts, out of 400000 for 1000
]]><![CDATA[ 14 hyphenation exceptions out of 1000
]]><![CDATA[ 31i,12n,40p,1588b,3161s stack positions out of 300i,100n,500p,50000b,8000s
]]></screen><para>See <ulink url="http://www.karakas-online.de/myJade/">my Jade Odyssey</ulink> for more details and ideas on this and other related errors.</para></sect2>
<sect2 id="fatal-format-file-error"><title>Fatal format file error; I'm stymied</title><para>Well...me too.<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_frown.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_frown.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_frown.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_frown.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<para>This what the <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=formatstymy">TeX FAQ</ulink> says about this error:</para><para>(La)TeX applications often fail with this error when you've been playing with the configuration, or have just installed a new version.</para><para>The format file contains the macros that define the system you want to use: anything from the simplest (Plain TeX) all the way to the most complicated, such as <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>or ConTeXt.<indexterm><primary>ConTeXt.</primary></indexterm> From the command you issue, <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>knows which format you want.</para><para>The error message</para><screen><![CDATA[Fatal format file error; I'm stymied
]]></screen><para>means that <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>itself can't understand the format you want. Obviously, this could happen if the format file had got corrupted,<indexterm><primary>corrupted</primary></indexterm> but it usually doesn't. The commonest cause of the message, is that a new binary has been installed in the system: no two <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>binaries on the same machine can understand each other's formats. So the new version of <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>you have just installed, won't understand the format generated by the one you installed last year.</para><para>Resolve the problem by regenerating the format; of course, this depends on which system you are using. On a teTeX-based <indexterm><primary>teTeX-based</primary></indexterm>system, run</para><screen><![CDATA[fmtutil --all
]]></screen><para>or</para><screen><![CDATA[fmtutil --byfmt=<format name>
]]></screen><para>to build only the format that you are interested in.</para><para>I got this error during the PDF <indexterm><primary>PDF</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>(<xref linkend="explain-document-creation-PDF">). Since pdftex <indexterm><primary>pdftex</primary></indexterm>is the program that was running at this stage, I tried both </para><screen><![CDATA[fmtutil --all
]]></screen><para>or</para><screen><![CDATA[fmtutil --byfmt=pdftex
]]></screen><para>but the problem remained.I had NOT upgraded to any new version for any of the programs involved. What I had done, was to add hundreds <indexterm><primary>hundreds</primary></indexterm>of cross-references (probably more than 500) in just one section (see it in <ulink url="http://www.karakas-online.de/EN-Book/credits-version-2.0.html">Credits for version 2.0 of the <application>PHP-Nuke</application> HOWTO</ulink>). </para><para>The solution was to upgrade <indexterm><primary>upgrade</primary></indexterm>pdftex from 0.13d to 1.11b (pdfTeX (Web2C 7.5.2) 3.141592-1.11b) <emphasis>and</emphasis> jadetex <indexterm><primary>jadetex</primary></indexterm>from 1.3 to 3.13. Note that upgrading pdftex <indexterm><primary>pdftex</primary></indexterm>was not enough, jadetex <indexterm><primary>jadetex</primary></indexterm>had to be upgraded too. Of course, you would still have to use fmtutil <indexterm><primary>fmtutil</primary></indexterm>as above. After the upgrades, the error disappeared. As a nice by-product, document <indexterm><primary>document</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>seems to be much faster now, although I didn't conduct any benchmarks.<indexterm><primary>benchmarks</primary></indexterm></para></sect2>
<sect2 id="corrupted-NFSS-tables"><title>Corrupted NFSS tables</title><screen><![CDATA[(/usr/share/texmf/tex/latex/base/ts1cmr.fd)
]]><![CDATA[! Corrupted NFSS tables.
]]><![CDATA[wrong@fontshape ...message {Corrupted NFSS tables}
]]><![CDATA[                                                  error@fontshape else let f...
]]></screen><para>I got this error after I used the RefDB <indexterm><primary>RefDB</primary></indexterm>(<xref linkend="Refdb">, <xref linkend="LyX-Bibliography">, <xref linkend="explain-bibliography">) DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet modifications in the local DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets (<xref linkend="DSSSL-stylesheets">, <xref linkend="explain-DSSSL-stylesheets">) that control the output.</para></sect2>
<sect2 id="Missing-dollar-inserted"><title>Missing $ inserted</title><para>You will probably get tons warnings like this one:</para><screen><![CDATA[! Missing $ inserted.
]]><![CDATA[<inserted text> 
]]><![CDATA[                $
]]><![CDATA[l.17245 ...b/a/bsd/2000/09/06/FreeBSD_Basics.html}
]]><![CDATA[                                                  \endNode{}\endSeq{}\endNod...
]]><![CDATA[I've inserted something that you may have forgotten.
]]><![CDATA[(See the <inserted text> above.)
]]></screen><para>You can see them in the standard output, as well as in the .log file that is created automatically <indexterm><primary>automatically</primary></indexterm>(if you don't see any .log file, maybe <ulink url="lyxtox">lyxtox</ulink> currently deletes it - check the code). They mean that <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>tried to correct you , because it saw some character that is used in the mathematics <indexterm><primary>mathematics</primary></indexterm>mode and thought you might have forgotten to switch. So it inserts a $, which toggles math <indexterm><primary>math</primary></indexterm>mode. If this is not what you intended (it will most probably not, if your .tex file is created through the procedure <indexterm><primary>procedure</primary></indexterm>described here), then your only salvation is to escape the character that triggered this behaviour.<indexterm><primary>behaviour</primary></indexterm> This means that you may have to escape</para><itemizedlist><listitem><para>Slashes (/) in URLs, at least when they separate two numbers <indexterm><primary>numbers</primary></indexterm>(not tested)</para></listitem><listitem><para>Underscores (_)</para></listitem><listitem><para>Carets (^) </para></listitem><listitem><para>and generally everything that may have a math <indexterm><primary>math</primary></indexterm>interpretation in TeX/LaTeX/LyX</para></listitem></itemizedlist><para>FIXME: This needs testing! Till now, I didn't resort to escaping - and stil things work remarkably well...</para></sect2>
<sect2 id="unprintable-characters"><title>Unprintable characters</title><para>Inevitably, sooner or later, you will hit a very nasty problem in document<indexterm><primary>document</primary></indexterm> processing:<indexterm><primary>processing</primary></indexterm> some characters in your file will be unprintable! They may appear in the PDF<indexterm><primary>PDF</primary></indexterm> as black boxes<indexterm><primary>boxes</primary></indexterm> (for example 
 <inlineequation>
  <alt>$
 &gt;  &gt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/16508.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/16508.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/16508.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/16508.bmp">
 ]]>

 </inlineequation>, in the OT1 <indexterm><primary>OT1</primary></indexterm>font encoding), or simply wrong. Here is what you can do to solve this problem:</para><para>If you are using the OT1<indexterm><primary>OT1</primary></indexterm> font encoding<indexterm><primary>encoding</primary></indexterm><footnote><para>There are various reasons why you may want to use the Old <application>TeX</application> (OT1) font encoding: you want to use the original Computern Modern fonts (which are available only in OT1) and/or have Mathematics (for which the original CM fonts are still a good choice), or you don't have other fonts, or you just find CM irresistible. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
</footnote>, i.e. if your <ulink url="jadetex.cfg">jadetex.cfg</ulink> file contains the line</para><screen><![CDATA[\usepackage[OT1]{fontenc}
]]></screen><para>then you have to enter the following characters in math <indexterm><primary>math</primary></indexterm>mode:</para><itemizedlist><listitem><para>
 <inlineequation>
  <alt>$
\backslash $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/16426.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/16426.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/16426.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/16426.bmp">
 ]]>

 </inlineequation> (backslash)</para></listitem><listitem><para>FIXME</para></listitem></itemizedlist><para>If you are using the T1<indexterm><primary>T1</primary></indexterm> font encoding,<indexterm><primary>encoding</primary></indexterm> i.e. if your <ulink url="jadetex.cfg">jadetex.cfg</ulink> file contains the line</para><screen><![CDATA[\usepackage[T1]{fontenc}
]]></screen><para>then you can use the ae<indexterm><primary>ae</primary></indexterm> and aecompl<indexterm><primary>aecompl</primary></indexterm> packages <indexterm><primary>packages</primary></indexterm>in order to be able to write almost every european<indexterm><primary>european</primary></indexterm> character:</para><screen><![CDATA[\usepackage{ae,aecompl}
]]></screen><para>You will not, however, manage to get the two 
 <inlineequation>
  <alt>$
 &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/14090.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/14090.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/14090.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/14090.bmp">
 ]]>

 </inlineequation> symbols,<indexterm><primary>symbols</primary></indexterm> 
 <inlineequation>
  <alt>$
 &lt;  &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/11935.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/11935.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/11935.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/11935.bmp">
 ]]>

 </inlineequation>, printed correctly. If your purpose was to get the french quote characters (the &ldquo;guillemets&rdquo;), then you could replace the ae <indexterm><primary>ae</primary></indexterm>and aecompl <indexterm><primary>aecompl</primary></indexterm>packages <indexterm><primary>packages</primary></indexterm>with the aeguill<indexterm><primary>aeguill</primary></indexterm> package, i.e. replace the above line in <ulink url="jadetex.cfg">jadetex.cfg</ulink> with:</para><screen><![CDATA[\usepackage{aeguill}
]]></screen><para>If your purpose was to get two 
 <inlineequation>
  <alt>$
 &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/10612.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/10612.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/10612.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/10612.bmp">
 ]]>

 </inlineequation>signs, one after another, just as if you were describing the effect of the &ldquo;append&rdquo; operator in</para><screen><![CDATA[cat file1 >> file2
]]></screen><para>then you <emphasis>must</emphasis> enter the 
 <inlineequation>
  <alt>$
 &lt;  &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/18770.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/18770.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/18770.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/18770.bmp">
 ]]>

 </inlineequation>in math <indexterm><primary>math</primary></indexterm>mode.</para><note>
<para>
Note that the above holds for the standard LyX environment (see <xref linkend="LyX-environments">) and probably all other environments where you use the same font as in the body text. You don't need to worry about characters in the code environment, probably because programming code is usually written in the <acronym>ASCII</acronym> encoding and LyX uses CDATA in &lt;screen&gt; or &lt;programlisting&gt; environments, where <acronym>ASCII</acronym> (or, maybe the value of the SP_ENCODING environment variable) is the expected input encoding for Openjade.
</para>
</note>
<para>For more information on fonts <indexterm><primary>fonts</primary></indexterm>and their encodings, see FIXME.<indexterm><primary>FIXME</primary></indexterm></para></sect2>
</sect1>
<sect1 id="other-errors"><title>Other errors</title><sect2 id="keywords"><title>Keywords not present in HTML </title><para>If you don't see the keywords <indexterm><primary>keywords</primary></indexterm>in the HTML <indexterm><primary>HTML</primary></indexterm>file, then this may be a bug in your stylesheets. There seems to be a bug in dbcommon.dsl <indexterm><primary>dbcommon.dsl</primary></indexterm>(DocBook DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets 1.73) that prevents this from happening for an article, where the &lt;keywordset&gt; in within &lt;articleinfo&gt;. The definition of &quot;info-element&quot;<indexterm><primary>info-element</primary></indexterm> in dbcommon.dsl <indexterm><primary>dbcommon.dsl</primary></indexterm>contains</para><screen><![CDATA[((equal? (gi nd) (normalize "article")) 
]]><![CDATA[  (select-elements (children nd) (normalize "artheader")))
]]></screen><para>but no reference to &quot;articleinfo&quot;<indexterm><primary>articleinfo</primary></indexterm>.</para><para>In dbcommon.dsl,<indexterm><primary>dbcommon.dsl</primary></indexterm> which in my system resides in /usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/common/dbcommon.dsl and belongs to packet docbook-dsssl-style<indexterm><primary>docbook-dsssl-style</primary></indexterm>sheets-1.72-34, replace the definition of info-element <indexterm><primary>info-element</primary></indexterm>with:</para><screen><![CDATA[;; ======================================================================
]]><![CDATA[(define (info-element #!optional (nd (current-node)))
]]><![CDATA[  ;; Returns the *INFO element for the nd or (empty-node-list) if no
]]><![CDATA[  ;; such node exists...
]]><![CDATA[  (cond
]]><![CDATA[   ((equal? (gi nd) (normalize "set"))
]]><![CDATA[    (select-elements (children nd) (normalize "setinfo")))
]]><![CDATA[   ((equal? (gi nd) (normalize "book"))
]]><![CDATA[    (select-elements (children nd) (normalize "bookinfo")))
]]><![CDATA[   ((equal? (gi nd) (normalize "section"))
]]><![CDATA[    (select-elements (children nd) (normalize "sectioninfo")))
]]><![CDATA[   ((equal? (gi nd) (normalize "sect1"))
]]><![CDATA[    (select-elements (children nd) (normalize "sect1info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "sect2"))
]]><![CDATA[    (select-elements (children nd) (normalize "sect2info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "sect3"))
]]><![CDATA[    (select-elements (children nd) (normalize "sect3info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "sect4"))
]]><![CDATA[    (select-elements (children nd) (normalize "sect4info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "sect5"))
]]><![CDATA[    (select-elements (children nd) (normalize "sect5info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "refsect1")) 
]]><![CDATA[    (select-elements (children nd) (normalize "refsect1info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "refsect2")) 
]]><![CDATA[    (select-elements (children nd) (normalize "refsect2info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "refsect3")) 
]]><![CDATA[    (select-elements (children nd) (normalize "refsect3info")))
]]><![CDATA[   ((equal? (gi nd) (normalize "refsynopsisdiv"))
]]><![CDATA[    (select-elements (children nd) (normalize "refsynopsisdivinfo")))
]]><![CDATA[   ((equal? (gi nd) (normalize "article"))
]]><![CDATA[   ;; Changed by root.
]]><![CDATA[   ;; node-list-filter-by-gi and articleinfo inserted. 
]]><![CDATA[   ;; Otherwise no keywords are created in articles.
]]><![CDATA[    (node-list-filter-by-gi (children nd) (list
]]><![CDATA[                                          (normalize "artheader")
]]><![CDATA[                                          (normalize "articleinfo"))))
]]><![CDATA[   (else ;; BIBLIODIV, GLOSSDIV, INDEXDIV, PARTINTRO, SIMPLESECT
]]><![CDATA[    (select-elements (children nd) (normalize "docinfo")))))
]]><![CDATA[;; ======================================================================
]]></screen></sect2>
<sect2 id="thumbpdf-fails"><title>thumbpdf fails </title><para>Perhaps the most accurate indicator of a serious error in your document<indexterm><primary>document</primary></indexterm> or settings is the failing of thumbpdf:<indexterm><primary>thumbpdf</primary></indexterm></para><screen><![CDATA[THUMBPDF 2.8, 2001/01/12 - Copyright (c) 1999-2001 by Heiko Oberdiek.
]]><![CDATA[*** make png files / run Ghostscript ***
]]><![CDATA[   **** This file has a corrupted %%EOF marker, or garbage after the %%EOF.
]]><![CDATA[GNU Ghostscript 6.51: Unrecoverable error, exit code 1
]]><![CDATA[!!! Error: Closing Ghostscript (exit status: 1)!
]]></screen><para>Although document <indexterm><primary>document</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>will continue (and you might even get a quite usable document), I strongly recommend you to investigate the source of this failing and to either eliminate <indexterm><primary>eliminate</primary></indexterm>it, or revert to a configuration that is known to work.</para><para>However, there is an exception to this rule of thumb: if you see the error</para><screen><![CDATA[Ghostscript internal error
]]></screen><para>the very first time you run lyxtox, don't panic. Let it finish. It is probably missing the pk fonts for the resolution of your standard printer and must generate them on the fly. This will be done later, while creating the postscript (PS) version of the document. After this is done once, you will never see this error again. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
</sect2>
<sect2 id="sed-segmentation-fault"><title>sed segmentation fault</title><para>On one occasion, I got the following very disturbing error:</para><screen><![CDATA[/usr/local/bin/runsed: line 54: 27611 Segmentation fault sed -f $SEDSCR $x >/tmp/$y$$
]]></screen><para>Output of the corrected SGML <indexterm><primary>SGML</primary></indexterm>file broke at a line for no apparent reason. Openjade <indexterm><primary>Openjade</primary></indexterm>complained (of course) with some errors, but processed the file. I noticed that something went wrong from the output of thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>(see <xref linkend="thumbpdf-fails">): thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>prints the page number for each page it processes - and this time it only printed half that many. I was not able to find the reason for the segmentation <indexterm><primary>segmentation</primary></indexterm>fault. I guess it has to do with the exceptionally long line that sed had to process: LyX <indexterm><primary>LyX</primary></indexterm>produces very long SGML <indexterm><primary>SGML</primary></indexterm>lines. It does not break the lines at SGML <indexterm><primary>SGML</primary></indexterm>tags and clutters them on one line for reasons unknown to me. That particular line was thus more than 3400 characters<footnote><para>of SGML text, original text was certainly less than that.</para></footnote> long when it was output without the error. As soon as I added some innocent <indexterm><primary>innocent</primary></indexterm>text that made it a little longer, it would cause the segmentation <indexterm><primary>segmentation</primary></indexterm>fault above. I guess this breaks some input line length limitation in sed. However, this is denied to be the case in the <ulink url="http://www.gnu.org/software/sed/manual/html_node/sed_11.html#SEC11">sed manual on the (non-)limitations on line length</ulink>:</para><blockquote><para>For those who want to write portable SED scripts, be aware that some implementations have been known to limit line lengths (for the pattern and hold spaces) to be no more than 4000 bytes. The <acronym>POSIX</acronym>.2 standard specifies that conforming SED implementations shall support at least 8192 byte line lengths. <acronym>GNU</acronym> <indexterm><primary>GNU</primary></indexterm>SED has no built-in limit on line length; as long as SED can malloc() more (virtual) memory, it will allow lines as long as you care to feed it (or construct within it).</para></blockquote><para>The only remedy if this limit does exist (as it seems to be in my case), is to shorten your text, or introduce a paragraph,<indexterm><primary>paragraph</primary></indexterm> admonition <indexterm><primary>admonition</primary></indexterm>(see <xref linkend="admonitions">, <xref linkend="LyX-admonitions">), code or other environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) that may persuade LyX <indexterm><primary>LyX</primary></indexterm>to start a new SGML <indexterm><primary>SGML</primary></indexterm>line in the exported SGML <indexterm><primary>SGML</primary></indexterm>text.</para></sect2>
<sect2 id="no-thumbnails-in-acrobat-reader-5"><title>Acrobat <application>Reader</application> 5 does not show thumbnails in Linux</title><para>The thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>script creates thumbnails <indexterm><primary>thumbnails</primary></indexterm>for the PDF <indexterm><primary>PDF</primary></indexterm>document just fine (see <xref linkend="explain-thumbnails">). Things work fine even with a thumbpdf.tex <indexterm><primary>thumbpdf.tex</primary></indexterm>of version 3.2 and a thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>of version 2.8, i.e. even if the versions of these two files differ (in which case thumbpdf<indexterm><primary>thumbpdf</primary></indexterm> will issue a warning, see <xref linkend="openjade-errors">). </para><para>Yet, one day, I recomputed the PDF <indexterm><primary>PDF</primary></indexterm>version of a document,<indexterm><primary>document</primary></indexterm> only to discover that the thumbnails <indexterm><primary>thumbnails</primary></indexterm>were appearing intermittently in the document:<indexterm><primary>document</primary></indexterm> some (few) appeared, the rest showed just a blank thumbnail. After an extensive Internet search (with very few results on the subject...) and a check with both <productname>Acrobat</productname> <application>Reader</application> 5 for <productname>Linux</productname> and <productname>Acrobat</productname> <application>Reader</application> 7 for Windows,<indexterm><primary>Windows</primary></indexterm> it became clear that this is a problem of <productname>Acrobat</productname> <application>Reader</application> 5 for <productname>Linux</productname> and large thumbnails <indexterm><primary>thumbnails</primary></indexterm>(small thumbnails <indexterm><primary>thumbnails</primary></indexterm>are displayed fine).</para><para>I guess there is nothing you can do about this problem, other than switch to small thumbnails <indexterm><primary>thumbnails</primary></indexterm>(right-click on the thumbnail area to see the context menu that will allow you to choose this), or upgrade <indexterm><primary>upgrade</primary></indexterm>to a version of <productname>Acrobat</productname> <application>Reader</application> that does not suffer from this bug.</para></sect2>
<sect2 id="URLs-with-underscore"><title>URLs with underscore display '&amp;lowbar;' instead of '_'</title><para>Any URL <indexterm><primary>URL</primary></indexterm>that has an underscore in it (like the link to <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>) shows '&amp;lowbar' in place of '_'. To correct this, you must check the checkbox &ldquo; HTML <indexterm><primary>HTML</primary></indexterm>type&rdquo; when you insert the URL <indexterm><primary>URL</primary></indexterm>in LyX,<indexterm><primary>LyX</primary></indexterm> see <xref linkend="fig-insert-url">.</para><para>
<figure id="fig-insert-url" float="1">
   <title>
   Insert URL with underscores in LyX.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1003;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1003;.pdf" format="PDF">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1003;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1003;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>Insert URL with underscores in LyX.</phrase>
      </textobject>
      <caption>
         <para>Insert URL with underscores in LyX.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>When you do this, you should NOT write underscores as '&amp;lowbar;'. You should write an underscore as is, i.e. as '_', in both the URL and the Name fields <xref linkend="fig-insert-url">. </para><para>FIXME: This still does not solve the problem in PDFs: there, the underscore is interpreted mathematically, making the character following the underscore to appear as a subscript. Moreover, if the link does not have an ending, it gets the standard ending for PDFs, namely &ldquo;.pdf&rdquo; attached to it, which is definitely wrong. Try this link: <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>, in HTML and in PDF to see the difference!</para></sect2>
<sect2 id="unknown-option-to-s-in-sedscr_img"><title>sed: file sedscr_img line 2: Unknown option to `s'</title><para>You get the error:</para><screen><![CDATA[editing mySGML.html
]]><![CDATA[sed: file sedscr_img line 2: Unknown option to `s'
]]><![CDATA[Output written to /tmp/mySGML.html_1402221460
]]><![CDATA[Sed produced an empty file
]]><![CDATA[- check your sedscript.
]]><![CDATA[all done
]]></screen><para>When you check the offending line 2 of sedscr_img (remember that sedscr_img is dynamically generated each time you run lyxtox), you see:</para><screen><![CDATA[s/<img src="\.\/images\/paper-sizes\.png">/<img src=".\/images\/paper-sizes.png" alt="ISO/DIN paper sizes." title="ISO/DIN paper sizes.">/g
]]></screen><para>Now it's clear what the error is: the caption to a figure contains a backslash (in &quot;ISO/DIN&quot;), which is used by sed as a regular expression delimiter. </para><para>The easiest solution to this seems to be: just avoid using backslash in figure captions! You cannot have everything in this world, it seems...<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
<para>See <xref linkend="fig-ISO-DIN-paper-sizes"> for the corrected caption of this specific example.</para></sect2>
</sect1>
</chapter>
<chapter id="explain-magic"><title>Explaining the magic: the details </title><epigraph>
<attribution><ulink url="http://www.bartleby.com/65/e-/E-SafireWll.html">William Safire</ulink></attribution>
<para>
Knowing how things work is the basis for appreciation, and is thus a source of civilized delight.
</para>
</epigraph>
<para>What makes the procedure <indexterm><primary>procedure</primary></indexterm>described here appear to be &ldquo;magic&rdquo; is not only the &ldquo;high-tecness&rdquo; of the tools <indexterm><primary>tools</primary></indexterm>involved, but also the highly frustrating fact that each one of the tools <indexterm><primary>tools</primary></indexterm>involved expects its input in different directories and/or formats, making it really difficult for interfaces or pipes <indexterm><primary>pipes</primary></indexterm>to match the output of one tool to the expected input of another. In this chapter I will explain the inner working of the involved scripts that, ultimately, do one thing: ensure that what is expected will be found in its expected place, in the expected format.</para><tip>
<title>Tip:</title> 
<para> 
You don't need to read this chapter if you are not interested in the gory details. For getting things to work, the <xref linkend="required-software">, <xref linkend="required-preliminary-steps">,  <xref linkend="writing-in-LyX"> and <xref linkend="lyxtox"> should suffice. But if you want to understand how things work, then go on!
</para> 
</tip>
<sect1 id="explain-document-processing"><title>Document processing</title><para>What happens when you type &ldquo; lyxtox <indexterm><primary>lyxtox</primary></indexterm>myTemplate&rdquo;? A lot! Let's inspect it step by step:</para><para>The name of the parameter <indexterm><primary>parameter</primary></indexterm>given to the <ulink url="lyxtox">lyxtox</ulink> script, myTemplate,<indexterm><primary>myTemplate</primary></indexterm> becomes $1. Whenever you see $1 in the code examples below, just replace it mentally with the name you supplied to lyxtox.<indexterm><primary>lyxtox</primary></indexterm></para><sect2 id="explain-check-number-of-parameters"><title>Check number of parameters</title><para>As in every good script, a rudimentary parameter <indexterm><primary>parameter</primary></indexterm>number check is the very first thing to do:</para><screen><![CDATA[# Check arguments and issue a help statement, if wrong
]]><![CDATA[#
]]><![CDATA[if [ $# -eq 0 -o $# -gt 1 ]; then
]]><![CDATA[  help 
]]><![CDATA[  exit 1
]]><![CDATA[elif [ $1 = "-h" -o $1 = "--help" ]; then
]]><![CDATA[  help 
]]><![CDATA[  exit 0
]]><![CDATA[fi
]]></screen><para>If the number of parameters is not exactly 1, the output of the help() function is printed, which looks like this:</para><screen><![CDATA[Usage: lyxtox [-h] [FILENAME_WITHOUT_.lyx_ENDING]
]]><![CDATA[Creates HTML, PDF, RTF, TXT and PS output 
]]><![CDATA[from a single LYX source.
]]><![CDATA[Needs: lyx, runsed, sed, sedscr, jadetex.cfg, perl, openjade,
]]><![CDATA[pdfjadetex, DocBook, TeX, LaTeX, thumbpdf, gzip, tar 
]]><![CDATA[and all packages required from these.
]]><![CDATA[See http://www.karakas-online.de/mySGML/ for a detailed 
]]><![CDATA[description.
]]><![CDATA[EXAMPLE
]]><![CDATA[=======
]]><![CDATA[If your file is myfile.lyx, then do
]]><![CDATA[lyxtox myfile
]]><![CDATA[go get a cup of coffee and be happy :-)
]]><![CDATA[-h, --help    Display this help text
]]></screen></sect2>
<sect2 id="explain-program-locations"><title>Set program locations</title><para>If the parameter <indexterm><primary>parameter</primary></indexterm>number check is passed, some program locations are set (adapt them to our situation!):</para><screen><![CDATA[# Program locations
]]><![CDATA[
]]><![CDATA[# Adapt to your situation.
]]><![CDATA[LYX="/usr/X11R6/bin/lyx"
]]><![CDATA[SED="/usr/bin/sed"
]]><![CDATA[AWK="/usr/bin/awk"
]]><![CDATA[RUNSED="/usr/local/bin/runsed"
]]><![CDATA[SEDSCR="sedscr"
]]><![CDATA[SEDSCRMATH="sedscr_math"
]]><![CDATA[SEDSCRABI="sedscr_abi"
]]><![CDATA[SEDSCRAPP="sedscr_app"
]]><![CDATA[SEDSCRBIB="sedscr_bib"
]]><![CDATA[AWKSCRMATH="awkscr_math"
]]><![CDATA[PERL="/usr/bin/perl"
]]><![CDATA[COLLATEINDEX="/usr/share/sgml/docbook/docbook-dsssl-stylesheets/bin/collateindex.pl"
]]><![CDATA[UNESCAPEMATH="/usr/local/bin/unescape_math.pl"
]]><![CDATA[TEXMATH2PNGBMP="/usr/local/bin/texmath2pngbmp.pl"
]]><![CDATA[THUMB_PDF="/usr/local/bin/thumbpdf"
]]><![CDATA[OPENJADE="/usr/bin/openjade"
]]><![CDATA[PDFJADETEX="/usr/bin/pdfjadetex"
]]><![CDATA[JADETEX="/usr/bin/jadetex"
]]><![CDATA[DVIPS="/usr/bin/dvips"
]]><![CDATA[GZIP="/usr/bin/gzip"
]]><![CDATA[TAR="/bin/tar"
]]><![CDATA[TIDY="/usr/bin/tidy"
]]><![CDATA[HTMLSPLIT="/usr/local/bin/htmlsplit.awk"
]]><![CDATA[REFDBXP="/usr/bin/refdbxp"
]]><![CDATA[RUNBIB="/usr/bin/runbib"
]]><![CDATA[DATADIR="../"
]]><![CDATA[DOMAIN="www.karakas-online.de"
]]></screen><para>Further, the stylesheet <indexterm><primary>stylesheet</primary></indexterm>locations are set (adapt them to your situation too):</para><screen><![CDATA[  HTML_CHUNKS_DSL="lyxtox-html.dsl"
]]><![CDATA[  HTML_NOCHUNKS_DSL="lyxtox-onehtml.dsl"
]]><![CDATA[  PRINT_PDF_DSL="lyxtox-print-pdf.dsl"
]]><![CDATA[  PRINT_PS_DSL="lyxtox-print-ps.dsl"
]]><![CDATA[  PRINT_RTF_DSL="lyxtox-print-rtf.dsl"
]]><![CDATA[  PRINT_TXT_DSL="lyxtox-print-txt.dsl"
]]></screen><para>You only need to change this part, if at all. The RefDB <indexterm><primary>RefDB</primary></indexterm>part:</para><screen><![CDATA[  HTML_DSL="refdb-html.dsl"
]]><![CDATA[  HTML_CHUNKS_DSL="$HTML_DSL#html"
]]><![CDATA[  HTML_NOCHUNKS_DSL="$HTML_DSL#onehtml"
]]><![CDATA[  PRINT_DSL="refdb-print.dsl"
]]><![CDATA[  PRINT_PDF_DSL="$PRINT_DSL#print-pdf"
]]><![CDATA[  PRINT_PS_DSL="$PRINT_DSL#print-ps"
]]><![CDATA[  PRINT_RTF_DSL="$PRINT_DSL#print-rtf"
]]><![CDATA[  PRINT_TXT_DSL="$PRINT_DSL#print-txt"
]]></screen><para>works automatically <indexterm><primary>automatically</primary></indexterm>and it is does not play any role how you name (or where you place) the HTML_DSL <indexterm><primary>HTML_DSL</primary></indexterm>and PRINT_DSL files in this case - they will be automatically <indexterm><primary>automatically</primary></indexterm>created through <ulink url="awkscr&amp;lowbar;refdb&amp;lowbar;html">awkscr_refdb_html</ulink> and <ulink url="awkscr&amp;lowbar;refdb&amp;lowbar;print">awkscr_refdb_print</ulink> with whatever filename you pass to them for their output respectively, see the source code of <ulink url="lyxtox">lyxtox</ulink>.</para></sect2>
<sect2 id="explain-environment-variables"><title>Set environment variables</title><para>It's time to set some environment <indexterm><primary>environment</primary></indexterm>variables. This is where quite a lot of the &ldquo;magic&rdquo; is hidden! Although they <emphasis>are</emphasis> mentioned somewhere in the respective manpages,<indexterm><primary>manpages</primary></indexterm> a newcomer will have probably never heard of them. The result: images cannot be found, no matter how &ldquo;right&rdquo; you did it, as well as some other annoyances regarding font mappings. This is because different tools <indexterm><primary>tools</primary></indexterm>read different environment <indexterm><primary>environment</primary></indexterm>variables for the same information, ignoring all the others! There is probably no way to accomodate this - other than write all relevant variables down correctly - since TeX/LaTeX were created in a different time, for different needs than SGML <indexterm><primary>SGML</primary></indexterm>parsers or PDF <indexterm><primary>PDF</primary></indexterm>software. </para><para>Since we entered the names of images without any path <indexterm><primary>path</primary></indexterm>information in LyX,<indexterm><primary>LyX</primary></indexterm> openjade <indexterm><primary>openjade</primary></indexterm>needs to be informed of their location with the environment <indexterm><primary>environment</primary></indexterm>variable SGML_SEARCH_PATH:<indexterm><primary>SGML_SEARCH_PATH</primary></indexterm></para><screen><![CDATA[# Environment variables
]]><![CDATA[# openjade needs this!
]]><![CDATA[# Both absolute and relative paths work!
]]><![CDATA[# SGML_SEARCH_PATH="$PWD/images"
]]><![CDATA[SGML_SEARCH_PATH="./images"
]]><![CDATA[export SGML_SEARCH_PATH
]]></screen><para>pdftex <indexterm><primary>pdftex</primary></indexterm>(and pdfjadetex) will look at a different environment <indexterm><primary>environment</primary></indexterm>variable for the location of the image files: TEXPSHEADERS.<indexterm><primary>TEXPSHEADERS</primary></indexterm> For some reason which I don't fully understand, \ includegraphics <indexterm><primary>includegraphics</primary></indexterm>with pdftex <indexterm><primary>pdftex</primary></indexterm>uses the TEXPSHEADERS <indexterm><primary>TEXPSHEADERS</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>variable for the additional paths <indexterm><primary>paths</primary></indexterm>to search. Also: TEXPSHEADERS <indexterm><primary>TEXPSHEADERS</primary></indexterm>contains the search path <indexterm><primary>path</primary></indexterm>where pdftex <indexterm><primary>pdftex</primary></indexterm>looks up for font mapping file (pdftex.map) and encoding <indexterm><primary>encoding</primary></indexterm>files (*.enc):</para><screen><![CDATA[# pdftex (and pdfjadetex) need this.
]]><![CDATA[# In my system pdftex.map is located in /var/lib/texmf/dvips/config/,
]]><![CDATA[# while the .enc files are under /usr/share/texmf/dvips/base/.
]]><![CDATA[# TEXPSHEADERS=":${PWD}/images//:/var/lib/texmf/dvips/config/:/usr/share/texmf/dvips/base/"
]]><![CDATA[TEXPSHEADERS=":${PWD}/images//"
]]><![CDATA[export TEXPSHEADERS
]]></screen><para>LaTeX, on the other side, will look at still another variable for the path<indexterm><primary>path</primary></indexterm> to images: TEXINPUTS <indexterm><primary>TEXINPUTS</primary></indexterm>(TEXINPUTS is also defined in the texmf.cnf <indexterm><primary>texmf.cnf</primary></indexterm>file, usually located in the directory pointed to by the TEXMFCNF <indexterm><primary>TEXMFCNF</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>variable):</para><screen><![CDATA[# <application>LaTeX</application> & Co. need this!
]]><![CDATA[# A relative path does NOT work!
]]><![CDATA[# TEXINPUTS="$PWD/images:$TEXINPUTS"
]]><![CDATA[TEXINPUTS=":${PWD}/images//"
]]><![CDATA[export TEXINPUTS
]]></screen><para>The TEXMFCNF <indexterm><primary>TEXMFCNF</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>variable points to the directory that contains the configuration files for TeX:<indexterm><primary>TeX</primary></indexterm></para><screen><![CDATA[TEXMFCNF="/etc/texmf/"
]]><![CDATA[export TEXMFCNF
]]></screen><para>In /etc/texmf/texmf.cnf we read:</para><screen><![CDATA[% pdfjadetex: Search path for font metric (.tfm) files.
]]><![CDATA[TEXFONTS = .;$TEXMF/fonts/tfm//
]]></screen><para>The next environment <indexterm><primary>environment</primary></indexterm>variable we will have to set, is the one that passes options to thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>(see <xref linkend="thumbpdf">), for the case that you wish to do so:</para><screen><![CDATA[# You can pass options to thumbpdf through this environment variable
]]><![CDATA[THUMBPDF=""
]]><![CDATA[export THUMBPDF
]]></screen><para>Last but not least, openjade <indexterm><primary>openjade</primary></indexterm>needs to know the locations of the SGML <indexterm><primary>SGML</primary></indexterm>catalog files (see <xref linkend="catalog-paths">):</para><screen><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.iso_ent"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.docbook-dsssl-stylesheets"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.mathml-2.0"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.svg-1.1"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.docbook_4"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/openjade/catalog"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/refdb/refdb.cat"
]]><![CDATA[export SGML_CATALOG_FILES
]]></screen><para>The SP_ENCODING<indexterm><primary>SP_ENCODING</primary></indexterm> environment <indexterm><primary>environment</primary></indexterm>variable tells Openjade<indexterm><primary>Openjade</primary></indexterm> in which encoding <indexterm><primary>encoding</primary></indexterm>the input file is written in:</para><screen><![CDATA[SP_ENCODING="ISO-8859-1" 
]]><![CDATA[export SP_ENCODING
]]></screen><para>Encoding names are case insensitive. The following named encodings are available (see <ulink url="http://openjade.sourceforge.net/doc-1.5.1/charset.htm">Handling of character sets in OpenSP</ulink>):</para><variablelist><varlistentry><term>utf-8
</term><listitem><para><indexterm><primary>utf-8</primary></indexterm>Each character is represented by a variable number of bytes according to UCS<indexterm><primary>UCS</primary></indexterm> Transformation Format 8 defined in Annex P to be added by the first proposed drafted amendment (PDAM 1) to ISO/IEC 10646-1:1993.</para></listitem></varlistentry><varlistentry><term>utf-16
</term><listitem><para><indexterm><primary>utf-16</primary></indexterm>Each character is represented by a variable number of bytes according to UCS <indexterm><primary>UCS</primary></indexterm>Transformation Format 16 defined in Annex O to be added by the first proposed drafted amendment (PDAM 1) to ISO/IEC 10646-1:1993.</para></listitem></varlistentry><varlistentry><term>ucs-2&nbsp;
</term><listitem><para>iso-10646-ucs-2 <indexterm><primary>iso-10646-ucs-2</primary></indexterm>This is ISO/IEC 10646 with the UCS-2 transformation format. Each character is represented by 2 bytes. No special treatment is given to the byte order mark <indexterm><primary>mark</primary></indexterm>character.</para></listitem></varlistentry><varlistentry><term>ucs-4&nbsp;iso-10646-ucs-4&nbsp;
</term><listitem><para>utf-32 <indexterm><primary>utf-32</primary></indexterm>This is ISO/IEC 10646 with the UCS-4 transformation format. Each character is represented by 4 bytes.</para></listitem></varlistentry><varlistentry><term>unicode
</term><listitem><para><indexterm><primary>unicode</primary></indexterm>Each character is represented according to the utf-16 <indexterm><primary>utf-16</primary></indexterm>encoding. The bytes representing the entire storage object may be preceded by a pair of bytes representing the byte order mark <indexterm><primary>mark</primary></indexterm>character (0xFEFF). The bytes representing each character are in the system byte order, unless the byte order mark <indexterm><primary>mark</primary></indexterm>character is present, in which case the order of its bytes determines the byte order. When the storage object is read, any byte order mark <indexterm><primary>mark</primary></indexterm>character is discarded.</para></listitem></varlistentry><varlistentry><term>euc-jp
</term><listitem><para><indexterm><primary>euc-jp</primary></indexterm>This is equivalent to the Extended_UNIX_Code_Packed_Format_for_Japanese Internet charset. Each character is encoded by a variable length sequence of octets.</para></listitem></varlistentry><varlistentry><term>euc-kr
</term><listitem><para><indexterm><primary>euc-kr</primary></indexterm>This is <acronym>ASCII</acronym> <indexterm><primary>ASCII</primary></indexterm>and KSC 5601 encoded with the EUC encoding <indexterm><primary>encoding</primary></indexterm>as defined by KS C 5861-1992.</para></listitem></varlistentry><varlistentry><term>euc-cn&nbsp;cn-gb&nbsp;
</term><listitem><para>gb2312 <indexterm><primary>gb2312</primary></indexterm>This is <acronym>ASCII</acronym> <indexterm><primary>ASCII</primary></indexterm>and GB 2312-80 encoded with the EUC encoding.<indexterm><primary>encoding</primary></indexterm> It is equivalent to the CN-GB MIME<indexterm><primary>MIME</primary></indexterm> charset defined in RFC 1922.</para></listitem></varlistentry><varlistentry><term>sjis&nbsp;
</term><listitem><para>shift_jis <indexterm><primary>shift_jis</primary></indexterm>This is equivalent to the Shift_JIS Internet charset. Each character is encoded by a variable length sequence of octets. This is Microsoft's standard encoding <indexterm><primary>encoding</primary></indexterm>for Japanese.<indexterm><primary>Japanese</primary></indexterm></para></listitem></varlistentry><varlistentry><term>big5&nbsp;cn-big5
</term><listitem><para>This is equivalent to the CN-Big5 MIME <indexterm><primary>MIME</primary></indexterm>charset defined in RFC 1922.</para></listitem></varlistentry><varlistentry><term>is8859-n&nbsp;iso-8859-n
</term><listitem><para>n can be any single digit other than 0. Each character in the repertoire of ISO <indexterm><primary>ISO</primary></indexterm>8859-n is represented by a single byte.</para></listitem></varlistentry><varlistentry><term>koi8-r&nbsp;
</term><listitem><para>koi8 <indexterm><primary>koi8</primary></indexterm>The koi8-r <indexterm><primary>koi8-r</primary></indexterm>encoding as defined in RFC 1489.</para></listitem></varlistentry><varlistentry><term>xml
</term><listitem><para><indexterm><primary>xml</primary></indexterm>On input, this uses XML's rules <indexterm><primary>rules</primary></indexterm>to determine the encoding.<indexterm><primary>encoding</primary></indexterm> On output, this uses UTF-8.</para></listitem></varlistentry><varlistentry><term>windows
</term><listitem><para><indexterm><primary>windows</primary></indexterm>Specify this encoding <indexterm><primary>encoding</primary></indexterm>when a storage object is encoded using your system's default <productname>Windows</productname> <indexterm><primary>Windows</primary></indexterm>character set. This uses the so-called ANSI code page.</para></listitem></varlistentry><varlistentry><term>wunicode
</term><listitem><para><indexterm><primary>wunicode</primary></indexterm>This uses the unicode <indexterm><primary>unicode</primary></indexterm>encoding if the storage object starts with a byte order mark <indexterm><primary>mark</primary></indexterm>and otherwise the windows <indexterm><primary>windows</primary></indexterm>encoding.<indexterm><primary>encoding</primary></indexterm> If you are working with Unicode, this is probably the best value for SP_ENCODING.</para></listitem></varlistentry><varlistentry><term>ms-dos
</term><listitem><para><indexterm><primary>ms-dos</primary></indexterm>Specify this encoding <indexterm><primary>encoding</primary></indexterm>when a storage object (file) uses the OEM<indexterm><primary>OEM</primary></indexterm> code page. The OEM <indexterm><primary>OEM</primary></indexterm>code-page for a particular machine is the code-page used by FAT<indexterm><primary>FAT</primary></indexterm> file-systems on that machine and is the default code-page for MS-DOS consoles.</para></listitem></varlistentry></variablelist><para>For OpenSP,<indexterm><primary>OpenSP</primary></indexterm> a suite of SGML/XML processing <indexterm><primary>processing</primary></indexterm>tools related to Openjade,<indexterm><primary>Openjade</primary></indexterm> there are two other environment <indexterm><primary>environment</primary></indexterm>variables that are related to SP_ENCODING <indexterm><primary>SP_ENCODING</primary></indexterm>(see <ulink url="http://openjade.sourceforge.net/doc-1.5.1/charset.htm">Handling of character sets in OpenSP</ulink>):</para><variablelist><varlistentry><term>SP_CHARSET_FIXED
</term><listitem><para><indexterm><primary>SP_CHARSET_FIXED</primary></indexterm>If this variable is 1 or YES, then OpenSP <indexterm><primary>OpenSP</primary></indexterm>will operate in fixed character set mode.</para></listitem></varlistentry><varlistentry><term>SP_SYSTEM_CHARSET
</term><listitem><para><indexterm><primary>SP_SYSTEM_CHARSET</primary></indexterm>This identifies the system character set. When in fixed character set mode, this character set is used as the internal character set. When not in fixed character set mode this character set is used as the internal character set until the document <indexterm><primary>document</primary></indexterm>character set has been read, at which point the document <indexterm><primary>document</primary></indexterm>character set is used as the internal character set. The only currently recognized value for this is JIS. This refers to a character set which combines JIS X 0201, JIS X 0208 and JIS X 0212 by adding 0x8080 to the codes of characters in JIS X 0208 and 0x8000 to the codes of characters in JIS X 0212. The default system character set is Unicode 2.0.</para></listitem></varlistentry></variablelist><para>But since lyxtox <indexterm><primary>lyxtox</primary></indexterm>does not use OpenSP,<indexterm><primary>OpenSP</primary></indexterm> we don't need to care about these two, as the manual <indexterm><primary>manual</primary></indexterm>page of Openjade <indexterm><primary>Openjade</primary></indexterm>asserts:</para><note>
<title>
Openjade does not use SP_CHARSET_FIXED and SP_SYSTEM_CHARSET
</title>
<para>
OpenJade ignores the SP_CHARSET_FIXED and SP_SYSTEM_CHARSET environment variables and always uses Unicode as its internal character set, as  if SP_CHARSET_FIXED  was  1 and SP_SYSTEM_CHARSET was unset. Thus only the SP_ENCODING environment variable is relevant to OpenJades handling  of character sets.
</para>
</note>
</sect2>
<sect2 id="explain-main-part"><title>Main part</title><para>In the main part, the hard work (for your computer) begins:</para><para>The document <indexterm><primary>document</primary></indexterm>is exported from LyX <indexterm><primary>LyX</primary></indexterm>to DocBook <indexterm><primary>DocBook</primary></indexterm>SGML:<indexterm><primary>SGML</primary></indexterm></para><screen><![CDATA[$LYX -e docbook $1.lyx
]]></screen><para>The SGML <indexterm><primary>SGML</primary></indexterm>that is produced by LyX <indexterm><primary>LyX</primary></indexterm>has several shortcomings.<indexterm><primary>shortcomings</primary></indexterm> They have to be corrected. This is done by calling <ulink url="runsed">runsed</ulink>:</para><screen><![CDATA[$RUNSED $SEDSCR $1.sgml
]]></screen><para>which is the subject of the next subsection.<indexterm><primary>subsection</primary></indexterm></para><note>
<title>
Alternative commands
</title>
<para>
There are quite a few alternative invocations of the various tools at appropriate places in the <ulink url="lyxtox">lyxtox</ulink> script, in the form of comments. These are there in order to show you how you can achieve an equivalent result through other tools.
</para>
</note>
<sect3 id="explain-runsed-sed-sedscr"><title>Runsed, sed and sedscr</title><para>Runsed <indexterm><primary>Runsed</primary></indexterm>takes as argument the sedscript <indexterm><primary>sedscript</primary></indexterm>to run and the file against which to run it. It calls sed with <ulink url="sedscr">sedscr</ulink> as the &ldquo;sed command file&rdquo;. In the sedscr <indexterm><primary>sedscr</primary></indexterm>file itself there is another bunch of &ldquo;magic&rdquo; going on:</para><important>
<title>Important note:</title> 
<para> 
The changes in LyX' SGML code presented here pertain strictly to LyX version 1.2.0! The 1.1.x  versions needed slightly (and subtly) different changes and the same may be true for future versions of LyX. Examples of sed commands for previous LyX versions are presented in the sedscr file in comments. Use (or construct) the right sed commands for the right changes for your LyX version! The success of this method depends crucially on this.
</para>
</important>
<para>The code</para><screen><![CDATA[s/<\(sect[^>]*\)>\(<title>[^<]*\)<anchor \([^>]*\)>/<\1 \3>\2/g
]]><![CDATA[s/<\(chapter\)>\(<title>[^<]*\)<anchor \([^>]*\)>/<\1 \3>\2/g
]]></screen><para>tells sed to substitute<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[< sect1 >< title > some title < anchor id="some label" >
]]></screen><para>with</para><screen><![CDATA[<sect1 id="some label" ><title>some title
]]></screen><para>and</para><screen><![CDATA[< chapter >< title > some title < anchor id="some label" >
]]></screen><para>with</para><screen><![CDATA[<chapter id="somelabel"><title> some title
]]></screen><para>The code</para><screen><![CDATA[/^.*<figure><title><graphic/{
]]><![CDATA[s/<figure><title><graphic fileref="\([^"]*\)">[ ]*<anchor id="\([^"]*\)">\([^<]*\)<\/title>[ ]*<\/figure>/\
]]><![CDATA[<figure id="\2">\
]]><![CDATA[   <title>\
]]><![CDATA[   \3\
]]><![CDATA[   <\/title>\
]]><![CDATA[   <mediaobject>\
]]><![CDATA[      <\!\[ \%output\.print\.png; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\.\/images\/\1.png" format="PNG">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[      \]\]>\
]]><![CDATA[      <\!\[ \%output\.print\.pdf; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\1.pdf" format="PDF" scale="65">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[      \]\]>\
]]><![CDATA[      <\!\[ \%output\.print\.eps; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\1.eps" format="EPS">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[       \]\]>\
]]><![CDATA[      <\!\[ \%output\.print\.bmp; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\1.bmp" format="BMP">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[       \]\]>\
]]><![CDATA[      <textobject>\
]]><![CDATA[         <phrase>\3<\/phrase>\
]]><![CDATA[      <\/textobject>\
]]><![CDATA[      <caption>\
]]><![CDATA[         <para>\3<\/para>\
]]><![CDATA[      <\/caption>\
]]><![CDATA[   <\/mediaobject>\
]]><![CDATA[<\/figure>\
]]><![CDATA[/g
]]><![CDATA[}
]]></screen><para>tells sed to substitute<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[< figure >< title >< graphic fileref="imagename" > some blanks < anchor id="some id" >some title< /title >
]]></screen><para>with the more elaborate combination of figure and mediaobject <indexterm><primary>mediaobject</primary></indexterm>elements:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1008;" format="linespecific"><![CDATA[
]]></screen><para>There are some remarks due here:</para><itemizedlist><listitem><para>The title of the original SGML <indexterm><primary>SGML</primary></indexterm>appears in three places of the new SGML: the title, the phrase for the alternative text and the caption.<indexterm><primary>caption</primary></indexterm> LyX <indexterm><primary>LyX</primary></indexterm>uses the figure caption <indexterm><primary>caption</primary></indexterm>for the title and there is no way we can derive three different texts for the three different uses in the new SGML.<indexterm><primary>SGML</primary></indexterm> That is why in the output document <indexterm><primary>document</primary></indexterm>the figure title, the alternative text and the figure caption <indexterm><primary>caption</primary></indexterm>are identical.</para></listitem><listitem><para>For the PNG <indexterm><primary>PNG</primary></indexterm>format we must prefix the image file name, imagename.png, with the relative path <indexterm><primary>path</primary></indexterm>(./images) to it, even though we set all environment <indexterm><primary>environment</primary></indexterm>variables correctly (see <xref linkend="explain-environment-variables">). This is not necesary for the other formats. </para></listitem><listitem><para>We scale the PDF <indexterm><primary>PDF</primary></indexterm>images to 100%. I used to scale them down to 65%,<indexterm><primary>65%</primary></indexterm> but this is no longer necessary, after some experimentation with various scale factors that seem to compensate for this need in the <ulink url="addd">addd</ulink> utility.<indexterm><primary>utility</primary></indexterm> See also <xref linkend="add-density">.</para></listitem><listitem><para>We make use of external SGML <indexterm><primary>SGML</primary></indexterm>entities like %output.print.png; This is a topic of its own which is explained in detail in <xref linkend="explain-figures">.</para></listitem></itemizedlist><para>A mediaobject <indexterm><primary>mediaobject</primary></indexterm>similar to the above (but without figure id and caption) is inserted whenever a &ldquo;simple&rdquo; image, i.e. one without the float element <indexterm><primary>element</primary></indexterm>with caption,<indexterm><primary>caption</primary></indexterm> is encountered in LyX' SGML.<indexterm><primary>SGML</primary></indexterm> It substitutes a line like<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[< graphic fileref="imagename" >
]]></screen><para>with a mediaobject <indexterm><primary>mediaobject</primary></indexterm>like</para><screen><![CDATA[]]><inlinegraphic fileref="&file1009;" format="linespecific"><![CDATA[
]]></screen><para>Notice that the text is now simply &quot;Figure&quot;, since there was no caption.<indexterm><primary>caption</primary></indexterm> You may change it to something else. There is also no id available for this mediaobject,<indexterm><primary>mediaobject</primary></indexterm> therefore you cannot cross-reference <indexterm><primary>cross-reference</primary></indexterm>it. That's why I suggested floats <indexterm><primary>floats</primary></indexterm>in <xref linkend="LyX-images">.</para><para>The following sed code</para><screen><![CDATA[]]><inlinegraphic fileref="&file1010;" format="linespecific"><![CDATA[
]]></screen><para>will substitute &lt;programmlisting&gt; with &lt;screen&gt;, while this one:</para><screen><![CDATA[# Delete the <para> before the <tgroup> tag.
]]><![CDATA[s/<tgroup/<tgroup/g
]]><![CDATA[# Delete the </para> after the </tgroup> tag.
]]><![CDATA[s/<\/tgroup><\/para>/<\/tgroup>/g
]]></screen><para>will delete &lt;para&gt; before &lt;tgroup&gt; and &lt;/para&gt; before &lt;/tgroup&gt;.</para><para>For table captions <indexterm><primary>captions</primary></indexterm>and titles to be output correctly, you have to eliminate<indexterm><primary>eliminate</primary></indexterm> the &lt;para&gt; from any sequence &lt;/title&gt;&lt;para&gt;&lt;tgroup&gt; AND you have to write a table float (see <xref linkend="LyX-tables">, in the inside of which you will have to set the title and the caption<indexterm><primary>caption</primary></indexterm> environment <indexterm><primary>environment</primary></indexterm>on one line, then press &lt;enter&gt;, set the environment <indexterm><primary>environment</primary></indexterm>to &quot;Standard&quot; (this will produce the &lt;para&gt; element <indexterm><primary>element</primary></indexterm>we eliminate <indexterm><primary>eliminate</primary></indexterm>here) and continue with the table normally. A warning about an &quot;end tag for element <indexterm><primary>element</primary></indexterm>&quot;TABLE&quot; which is not open&quot; is the less evil we can get and is harmless (a LyX <indexterm><primary>LyX</primary></indexterm>bug in 1.2.0, not openjade's):</para><screen><![CDATA[/<\/title><tgroup/s/<\/title><tgroup/<\/title><tgroup/
]]></screen><para>Further, for the cross-references to tables to work, we have to substitute<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[< table >< title >< anchor id="some id" >
]]></screen><para>with </para><screen><![CDATA[<table id="some id"><title>
]]></screen><para>This is done with the following sed code:</para><screen><![CDATA[s/<table>[ ]*<title>[ ]*<anchor \([^>]*\)>/<table \1><title>/g
]]></screen><para>Some minor issues still remain:</para><para>Substitute 'ldquo' with 'quot' and 'rdquo' with 'quot':</para><screen><![CDATA[s/\&ldquo;/\&quot;/g
]]><![CDATA[s/\&rdquo;/\&quot;/g
]]></screen><para>But we are not done with the quots yet: In &lt;othercredit&gt; we have to substitute<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[& quot ;
]]></screen><para>with &quot; :</para><screen><![CDATA[/<othercredit/s/\&quot;/"/g
]]></screen><para>And: substitute<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[& amp ; copy ; 
]]></screen><para>with &amp;copy. This will produce a Copyright <indexterm><primary>Copyright</primary></indexterm>symbol, instead of &quot;&amp;copy&quot;:</para><screen><![CDATA[s/\&copy;/\&copy/g
]]></screen><para>Also, substitute &amp;xxxx; with the character it representes - somehow these entities <indexterm><primary>entities</primary></indexterm>do not work:</para><screen><![CDATA[s/[/[/g
]]><![CDATA[s/]/]/g
]]><![CDATA[s/{/{/g
]]><![CDATA[s/}/}/g
]]><![CDATA[s/$/$/g
]]><![CDATA[s/%/%/g
]]><![CDATA[s/#/#/g
]]><![CDATA[s/|/|/g
]]><![CDATA[s/£/£/g
]]><![CDATA[s/_/_/g
]]><![CDATA[s/\/\\/g
]]><![CDATA[s/~/~/g
]]></screen><para>Finally, for the index to be created, we have to insert the index creation command. Comment this if you don't want an index: to substitute<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[< /book >
]]></screen><para>with<footnote><para>I have inserted some blanks in the code snippet in order to prevent my own scripts (sedscr!) from matching and changing a code that was meant to be an example ;-)</para></footnote> </para><screen><![CDATA[&index;
]]><![CDATA[< /book >
]]></screen><para>the following sed code is needed:</para><screen><![CDATA[/<\/book>/s/<\/book>/\&index;\
]]><![CDATA[<\/book>/
]]></screen><para>A similar sed code is there for the article document <indexterm><primary>document</primary></indexterm>type. Currently, this part has been commented and transfered to the <ulink url="sedscr_abi">sedscr_abi</ulink> script which inserts the entities <indexterm><primary>entities</primary></indexterm>for the Appendix, the Bibliography and the Index at once at the end of the document,<indexterm><primary>document</primary></indexterm> before the closing &lt;/book&gt; or &lt;/article&gt; tags.</para></sect3>
<sect3 id="tidying-up-the-SGML-code"><title>Tidying up the SGML code</title><para>Finally, two calls to <ulink url="runsed">runsed</ulink> with <ulink url="sedscr_tidy">sedscr_tidy</ulink> and <ulink url="sedscr_tidy2">sedscr_tidy2</ulink> as the script files will &ldquo; tidy <indexterm><primary>tidy</primary></indexterm>up&rdquo; the SGML <indexterm><primary>SGML</primary></indexterm>file:</para><screen><![CDATA[$RUNSED $SEDSCRTIDY $1.sgml
]]><![CDATA[$RUNSED $SEDSCRTIDY2 $1.sgml
]]></screen><para><ulink url="sedscr_tidy">sedscr_tidy</ulink> consists simply of the following lines:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1011;" format="linespecific"><![CDATA[
]]></screen><para>It does practically nothing else than insert a newline <indexterm><primary>newline</primary></indexterm>before an opening bracket (a &quot;&lt;&quot;) or a closing one (a &quot;&gt;&quot;). After this transformation has taken place for the whole document,<indexterm><primary>document</primary></indexterm> <ulink url="runsed">runsed</ulink> is called with <ulink url="sedscr_tidy2">sedscr_tidy2</ulink> as the sed script:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1012;" format="linespecific"><![CDATA[
]]></screen><para><ulink url="sedscr_tidy2">sedscr_tidy2</ulink> will do some corrections, because the changes of <ulink url="sedscr_tidy">sedscr_tidy</ulink> went a bit too far: </para><itemizedlist><listitem><para>It will delete any newline <indexterm><primary>newline</primary></indexterm>before the closing &quot;]]&gt;&quot; of CDATA <indexterm><primary>CDATA</primary></indexterm>elements</para></listitem><listitem><para>and it will bring &lt;entry&gt; and &lt;para&gt; elements on the same line, i.e. it will delete any newlines between them. It will do the same for the closing &lt;/para&gt; and &lt;/entry&gt; pairs. Both pairs occur inside tables and due to the <ulink url="http://www.docbook.org/tdg/en/html/entry.html">Pernicious Mixed Content Problem</ulink> they should not contain any line feed or space in-between, or the parser<indexterm><primary>parser</primary></indexterm> will think that the table cell contains inline <indexterm><primary>inline</primary></indexterm>markup <indexterm><primary>markup</primary></indexterm>and issue the warning that the &ldquo; document <indexterm><primary>document</primary></indexterm>type does not allow element <indexterm><primary>element</primary></indexterm>&lt;para&gt;&rdquo; at that place. See the discussion of the &ldquo; document <indexterm><primary>document</primary></indexterm>type does not allow element <indexterm><primary>element</primary></indexterm>&lt;para&gt;&rdquo; error in <xref linkend="openjade-errors">, as well as in <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=965">Openjade error: &lt;para&gt; not allowed after &lt;entry&gt;</ulink>.</para></listitem></itemizedlist><warning>
<title>
Tidy scripts mess up code snippets
</title>
<para>
The tidy scripts will mess up any part of your file that contains the &lt; and &gt; brackets. Especially code that is included verbatim (i.e. without the use of some external entity) and contains such brackets will look awkward. Callouts will also be affected. I have deactivated the call to the scripts in the lyxtox file until I find a better solution (BTW, nsgmls will break with errors so it does not lend itself to SGML code tidying either). If potentially affected code is included with the help of an external entity though, then the tidy scripts might work fine for you.
</para>
</warning>
</sect3>
<sect3 id="key-combinations"><title>Key combinations</title><para>The sedscr file also contains code that will add markup for key<indexterm><primary>keycombos</primary></indexterm> combinations<indexterm><primary>combinations, key</primary></indexterm>:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1013;" format="linespecific"><![CDATA[
]]></screen><para>The above code, for example, will substitute every occurence of the string &ldquo;
<keycombo>
    <keycap>CTRL</keycap>
    <keycap>X</keycap>
    <keycap>Y</keycap>
</keycombo>
<indexterm>
    <primary>CTRL-X-Y</primary>
</indexterm>
&rdquo; with:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1014;" format="linespecific"><![CDATA[
]]></screen><para>thus adding the right DocBook markup for the key combination <emphasis>and</emphasis> also an index entry for it too. There is also code for &ldquo;
<keycombo>
    <keycap>CTRL</keycap>
    <keycap>X</keycap>
</keycombo>
<indexterm>
    <primary>CTRL-X</primary>
</indexterm>
&rdquo; or only &ldquo;CTRL&rdquo;. Instead of &ldquo;CTRL&rdquo;, you can also have &ldquo;ESC&rdquo; or &ldquo;ALT&rdquo; - there is code for them too. The user can thus just write &ldquo;
<keycombo>
    <keycap>CTRL</keycap>
    <keycap>ALT</keycap>
    <keycap>DEL</keycap>
</keycombo>
<indexterm>
    <primary>CTRL-ALT-DEL</primary>
</indexterm>
&rdquo; or &ldquo;ESC&rdquo; or &ldquo;
<keycombo>
    <keycap>ALT</keycap>
    <keycap>F4</keycap>
</keycombo>
<indexterm>
    <primary>ALT-F4</primary>
</indexterm>
&rdquo; and the scripts will take care of markup and indexing.</para></sect3>
<sect3 id="acronyms-product-names-applications"><title>Acronyms, product names, applications</title><para>There is also automatic markup insertion for acronyms<indexterm><primary>acronyms</primary></indexterm>, product names<indexterm><primary>product names</primary></indexterm> and applications<indexterm><primary>applications</primary></indexterm>:</para><para>For acronyms:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1015;" format="linespecific"><![CDATA[
]]></screen><para>For product names:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1016;" format="linespecific"><![CDATA[
]]></screen><para>For applications:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1017;" format="linespecific"><![CDATA[
]]></screen><para>The principle is the same for all three: substitute any occurence of the acronym, product name or application with the appropriate DocBook markup<indexterm><primary>markup</primary></indexterm>. For example, an string &ldquo;GNU&rdquo; is replaced by:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1018;" format="linespecific"><![CDATA[
]]></screen><para>(GNU is an acronym), while a &ldquo;Linux&rdquo; is replaced by:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1019;" format="linespecific"><![CDATA[
]]></screen><para>(Linux is a product name in this case) and &ldquo;TeX&rdquo; (an application) is replaced by</para><screen><![CDATA[]]><inlinegraphic fileref="&file1020;" format="linespecific"><![CDATA[
]]></screen><para>It is up to you which acronyms, product names or applications you want to have automatically marked up this way (they will appear in small caps if you didn't change anything in the standard stylesheets), so feel free to add or remove your favourites from the code in sedscr.</para><para>This concludes the transformation of LyX' SGML <indexterm><primary>SGML</primary></indexterm>(specific parts were not covered here - for the Mathematics <indexterm><primary>Mathematics</primary></indexterm>part, see <xref linkend="explain-SGML-math-code-correction">, for the citations <indexterm><primary>citations</primary></indexterm>part, see <xref linkend="explain-RefDB">). <ulink url="runsed">runsed</ulink> copies the original SGML <indexterm><primary>SGML</primary></indexterm>file to a backup file with the .bak ending, then writes the output of sed to a temporary file with a random name, compares the two files and, if something has changed, replaces the original file with the temporary one, otherwise outputs a warning that the file did not change.</para></sect3>
<sect3 id="alt-attributes-for-images"><title>Alt attributes for images</title><para>Before we continue, we have to take care of a problem that seems to be caused by a bug in the DSSSL stylesheets<indexterm><primary>stylesheets</primary></indexterm> used: although we add a &lt;phrase&gt; element to the &lt;textobject&gt;'s (see the code in <ulink url="sedscr">sedscr</ulink>), it seems that it is not used for alt attributes<indexterm><primary>alt attribute</primary></indexterm> in the resulting images during HTML creation. This makes the resulting HTML documents fail the HTML validation<indexterm><primary>validation, HTML</primary></indexterm> test of the W3C (see <xref linkend="HTML-validation">).</para><para>I have decided to resolve this problem with another sed script, this time a dynamic one! First, the SGML file of the document is passed to sed using <ulink url="sedscr_ima">sedscr_ima</ulink>:</para><screen><![CDATA[${SED} -n -f ${SEDSCRIMA} $1.sgml > ${SEDSCRIMG}
]]></screen><para>This produces a sed script (${SEDSCRIMG) called sedscr_img. We create a second sed script, ${SEDSCRGRA}, which we will use in order to substitute &quot;graphXXXX&quot; with the real name of the graphic file in ${SEDSCRIMG:</para><screen><![CDATA[${SED} -n -e '/<\!ENTITY/s/.*graph\([^ ]*\) "\([^>]*\)".*>/s\/graph\1\/\2\/g/p' $1.sgml > ${SEDSCRGRA}
]]></screen><para>We now use the sed script ${SEDSCRGRA} (sedscr_gra) to substitute &quot;graphXXXX&quot; with the real name of the graphic file in ${SEDSCRIMG}<footnote><para>Yup, we use a sed script to change another sed script...</para></footnote>:</para><screen><![CDATA[${RUNSED} ${SEDSCRGRA} ${SEDSCRIMG}
]]></screen><para>This last step transforms sedscr_img, but it stil contains &lt;acronym&gt;, &lt;productname&gt; and &lt;application&gt; tags. To erase them from the alt and title texts in the sed script ${SEDSCRIMG}, we use the sed script <ulink url="sedscr_apa">sedscr_apa</ulink>:</para><screen><![CDATA[${RUNSED} ${SEDSCRAPA} ${SEDSCRIMG}
]]></screen><para>Finally, we add the necessary sed commands for the alt and title texts of smilies.</para><screen><![CDATA[echo 's/"\.\/images\/icon_smile\.png">/".\/images\/icon_smile.png" alt="smile" title="smile">/g' 
]]><![CDATA[>> ${SEDSCRIMG}
]]><![CDATA[echo 's/"\.\/images\/icon_wink\.png">/".\/images\/icon_wink.png" alt="wink" title="wink">/g' 
]]><![CDATA[>> ${SEDSCRIMG}
]]><![CDATA[echo 's/"\.\/images\/icon_cool\.png">/".\/images\/icon_cool.png" alt="cool" title="cool">/g' 
]]><![CDATA[>> ${SEDSCRIMG}
]]><![CDATA[echo 's/"\.\/images\/icon_eek\.png">/".\/images\/icon_eek.png" alt="shock" title="shock">/g' 
]]><![CDATA[>> ${SEDSCRIMG}
]]><![CDATA[echo 's/"\.\/images\/icon_frown\.png">/".\/images\/icon_frown.png" alt="frown" title="frown">/g' 
]]><![CDATA[>> ${SEDSCRIMG}
]]></screen><para>Now we have computed a sed script, ${SEDSCRIMG}, that adds alt and title tags<indexterm><primary>tag, alt</primary></indexterm><indexterm><primary>tag, title</primary></indexterm> to the images in every HTML file that is applied on. </para><para>Here's how it looks like for this document:</para><screen><![CDATA[s/<img src="\.\/images\/general-info\.png">/<img src=".\/images\/general-info.png" 
]]><![CDATA[alt="General document info." title="General document info.">/g
]]><![CDATA[s/<img src="\.\/images\/paper-sizes\.png">/<img src=".\/images\/paper-sizes.png" 
]]><![CDATA[alt="ISO-DIN paper sizes." title="ISO-DIN paper sizes.">/g
]]><![CDATA[s/<img src="\.\/images\/insert-url\.png">/<img src=".\/images\/insert-url.png" 
]]><![CDATA[alt="Insert URL with underscores in LyX." title="Insert URL with underscores in LyX.">/g
]]><![CDATA[s/<img src="\.\/images\/page-area-model\.png">/<img src=".\/images\/page-area-model.png" 
]]><![CDATA[alt="CSS page area model." title="CSS page area model.">/g
]]><![CDATA[s/<img src="\.\/images\/fonts\.png">/<img src=".\/images\/fonts.png" 
]]><![CDATA[alt="Document Info: Fonts." title="Document Info: Fonts.">/g
]]><![CDATA[s/"\.\/images\/icon_smile\.png">/".\/images\/icon_smile.png" alt="smile" title="smile">/g
]]><![CDATA[s/"\.\/images\/icon_wink\.png">/".\/images\/icon_wink.png" alt="wink" title="wink">/g
]]><![CDATA[s/"\.\/images\/icon_cool\.png">/".\/images\/icon_cool.png" alt="cool" title="cool">/g
]]><![CDATA[s/"\.\/images\/icon_eek\.png">/".\/images\/icon_eek.png" alt="shock" title="shock">/g
]]><![CDATA[s/"\.\/images\/icon_frown\.png">/".\/images\/icon_frown.png" alt="frown" title="frown">/g
]]></screen><para>We will use it in a moment...</para></sect3>
<sect3 id="explain-document-creation-HTML"><title>Document creation: HTML</title><para>After some cleaning</para><screen><![CDATA[# Clean previous HTML files.
]]><![CDATA[rm $1/*.html
]]><![CDATA[# Clean previous image files.
]]><![CDATA[rm -rf $1/images
]]><![CDATA[# Clean rsync backup copies.
]]><![CDATA[rm -rf $1/*~
]]></screen><para>the document <indexterm><primary>document</primary></indexterm>creation begins:</para><para>For the one HTML <indexterm><primary>HTML</primary></indexterm>file, the steps are:</para><itemizedlist><listitem><para>Index initialization (-N option):</para><screen><![CDATA[$PERL $COLLATEINDEX -N -o index.sgml
]]></screen></listitem><listitem><para>Create one HTML <indexterm><primary>HTML</primary></indexterm>file. We use openjade <indexterm><primary>openjade</primary></indexterm>for that. Older versions used sgmltools <indexterm><primary>sgmltools</primary></indexterm>as follows:</para><screen><![CDATA[$SGMLTOOLS -b onehtml -s $HTML_NOCHUNKS_DSL -j "-i output.print.png 
]]><![CDATA[-V nochunks -V html-index" $1.sgml
]]></screen><para>Notice that we pass &quot;-i output.print.png <indexterm><primary>output.print.png</primary></indexterm>-V nochunks <indexterm><primary>nochunks</primary></indexterm>-V html-index&quot; <indexterm><primary>html-index"</primary></indexterm>to openjade<indexterm><primary>openjade</primary></indexterm> through the -j option. Current versions use openjade <indexterm><primary>openjade</primary></indexterm>directly:</para><screen><![CDATA[${OPENJADE} -t sgml -d $HTML_NOCHUNKS_DSL -i output.print.png -V nochunks -V html-index $1.sgml > $1.html
]]></screen><para>The -i option to openjade <indexterm><primary>openjade</primary></indexterm>tells it to include the output.print.png <indexterm><primary>output.print.png</primary></indexterm>entity (see the structure of the mediaobjects <indexterm><primary>mediaobjects</primary></indexterm>put in place by runsed <indexterm><primary>runsed</primary></indexterm>above), while the preample <indexterm><primary>preample</primary></indexterm>(see <xref linkend="preample">) tells it to ignore all such entities.<indexterm><primary>entities</primary></indexterm> Since the command line option overrides all others, the output.print.png<indexterm><primary>output.print.png</primary></indexterm> entity <indexterm><primary>entity</primary></indexterm>is included for the HTML <indexterm><primary>HTML</primary></indexterm>output, while the othe ones are ignored (see also <xref linkend="explain-figures">).</para></listitem><listitem><para>Index creation:</para><screen><![CDATA[$PERL $COLLATEINDEX -g -o index.sgml HTML.index
]]></screen></listitem><listitem><para>Generation of one HTML <indexterm><primary>HTML</primary></indexterm>file (the index will be included). Again, older versions used sgmltools:<indexterm><primary>sgmltools</primary></indexterm></para><screen><![CDATA[$SGMLTOOLS -b onehtml -s $HTML_NOCHUNKS_DSL -j "-i output.print.png" $1.sgml
]]></screen><para>but newer ones use openjade:<indexterm><primary>openjade</primary></indexterm></para><screen><![CDATA[${OPENJADE} -t sgml -d $HTML_NOCHUNKS_DSL -i output.print.png -V nochunks $1.sgml > $1.html
]]></screen></listitem><listitem><para>Tidy <indexterm><primary>Tidy</primary></indexterm>the HTML <indexterm><primary>HTML</primary></indexterm>code:</para><screen><![CDATA[$TIDY -ascii -c -wrap 200 -f /dev/null -m $1.html
]]></screen></listitem><listitem><para>Correct header and footer. First, split the HTML <indexterm><primary>HTML</primary></indexterm>document in title and body <indexterm><primary>body</primary></indexterm>parts. The title will be put in title.tmp, the body <indexterm><primary>body</primary></indexterm>in body.tmp:<indexterm><primary>body.tmp</primary></indexterm></para><screen><![CDATA[$HTMLSPLIT < $1.html
]]></screen></listitem><listitem><para>Second, put the right header and footer in the file (see <xref linkend="HTML-validation">):</para><screen><![CDATA[HTMLFILE=$1.html
]]><![CDATA[BASENAME=`basename $HTMLFILE`
]]><![CDATA[cat ${DATADIR}/part1 > ${HTMLFILE}
]]><![CDATA[cat title.tmp >> ${HTMLFILE}
]]><![CDATA[echo '</title>' >> ${HTMLFILE}
]]><![CDATA[cat meta.tmp >> ${HTMLFILE}
]]></screen></listitem><listitem><para>Substitute the placeholders <indexterm><primary>placeholders</primary></indexterm>DOMAIN, DIRNAME, FILENAME etc. in the header (part2) and footer file (part3) with the current values:</para><screen><![CDATA[# Header
]]><![CDATA[${SED} -e "s/_DOMAIN_/${DOMAIN}/g" ${DATADIR}/part2 > part2_1.tmp
]]><![CDATA[${SED} -e "s/_DIRNAME_/$1/g" part2_1.tmp > part2_2.tmp
]]><![CDATA[${SED} -e "s/_FILENAME_/${BASENAME}/g" part2_2.tmp > part2_3.tmp
]]><![CDATA[${SED} -e "s/_TITLE_/${TITLE}/g" part2_3.tmp > part2_4.tmp
]]><![CDATA[${SED} -e "s/_FORMATSFILE_/${FORMATSFILE}/g" part2_4.tmp > part2_5.tmp
]]><![CDATA[${SED} -e "s/_COPYRIGHT_/${COPYRIGHT}/g" part2_5.tmp > part2_6.tmp
]]><![CDATA[${SED} -e "s/_HOMEFILE_/${HOMEFILE}/g" part2_6.tmp > part2_7.tmp
]]><![CDATA[${SED} -e "s/_DATE_/${TODAY}/g" part2_7.tmp > part2.tmp
]]><![CDATA[cat part2.tmp >> ${HTMLFILE}
]]><![CDATA[# Body
]]><![CDATA[cat body.tmp >> ${HTMLFILE}
]]><![CDATA[# Footer
]]><![CDATA[${SED} -e "s/_DOMAIN_/${DOMAIN}/g" ${DATADIR}/part3 > part3_1.tmp
]]><![CDATA[${SED} -e "s/_DIRNAME_/$1/g" part3_1.tmp > part3_2.tmp
]]><![CDATA[${SED} -e "s/_FILENAME_/${HTMLFILE}/g" part3_2.tmp > part3_3.tmp
]]><![CDATA[${SED} -e "s/_TITLE_/${TITLE}/g" part3_3.tmp > part3_4.tmp
]]><![CDATA[${SED} -e "s/_FORMATSFILE_/${FORMATSFILE}/g" part3_4.tmp > part3_5.tmp
]]><![CDATA[${SED} -e "s/_COPYRIGHT_/${COPYRIGHT}/g" part3_5.tmp > part3_6.tmp
]]><![CDATA[${SED} -e "s/_HOMEFILE_/${HOMEFILE}/g" part3_6.tmp > part3_7.tmp
]]><![CDATA[${SED} -e "s/_DATE_/${TODAY}/g" part3_7.tmp > part3.tmp
]]><![CDATA[cat part3.tmp >> ${HTMLFILE}
]]></screen><para>If you have set the values of TITLE, FORMATFILE, HOMEFILE etc. in your .start file (see <xref linkend="start-and-end-scripts">) and you use them somewhere in your part* files, they will be replaced with those values too. The same is true for DATE: you can use it in your headers and footers to produce the timestamp automatically.</para></listitem><listitem><para>Add alt and title attributes to images. We use the sed script sedscr_img, that we computed in <xref linkend="alt-attributes-for-images">:</para><screen><![CDATA[# Add alt and title tags to the images.
]]><![CDATA[${RUNSED} ${SEDSCRIMG} ${HTMLFILE}
]]></screen></listitem><listitem><para>Finally, do some housekeeping, removing all intermediate files:</para><screen><![CDATA[# Housekeeping
]]><![CDATA[rm -f body.tmp title.tmp meta.tmp part2*.tmp part3*.tmp
]]></screen></listitem></itemizedlist><para>For the HTML <indexterm><primary>HTML</primary></indexterm>output with many files (chunks), the procedure <indexterm><primary>procedure</primary></indexterm>is analogous to the above, so I will not repeat it here.</para></sect3>
<sect3 id="explain-document-creation-PDF"><title>Document creation: PDF</title><para>For the print formats, the index is recreated (we need page numbers <indexterm><primary>numbers</primary></indexterm>instead of HTML <indexterm><primary>HTML</primary></indexterm>links). Notice the -p option to collateindex <indexterm><primary>collateindex</primary></indexterm>and the use of the saved copy of HTML.<indexterm><primary>HTML</primary></indexterm>index in the current directory - this is because the raw index data are generated with the HTML <indexterm><primary>HTML</primary></indexterm>stylesheet,<indexterm><primary>stylesheet</primary></indexterm> even for the print formats (see <xref linkend="explain-index">):</para><screen><![CDATA[rm index.sgml
]]><![CDATA[$PERL $COLLATEINDEX -p -g -o index.sgml HTML.index
]]></screen><para>and the images directory is copied under $1 (the myTemplate <indexterm><primary>myTemplate</primary></indexterm>directory, in our example):</para><screen><![CDATA[cp -av images $1/
]]></screen><para>For the PDF <indexterm><primary>PDF</primary></indexterm>output, the steps are:</para><itemizedlist><listitem><para>Generate the PDF <indexterm><primary>PDF</primary></indexterm>document in a first pass:</para><screen><![CDATA[$OPENJADE -t tex -d $PRINT_PDF_DSL -o $1.tex -i "output.print.pdf" $1.sgml
]]></screen><para>Notice that now only the output.print.pdf <indexterm><primary>output.print.pdf</primary></indexterm>entities <indexterm><primary>entities</primary></indexterm>in the mediaobjects <indexterm><primary>mediaobjects</primary></indexterm>are included (see the discussion of this for the HTML <indexterm><primary>HTML</primary></indexterm>output above, as well as in <xref linkend="explain-figures">).</para></listitem><listitem><para>The generated PDF <indexterm><primary>PDF</primary></indexterm>in the 1st pass does not have thumbnails <indexterm><primary>thumbnails</primary></indexterm>yet. Generate thumbnails <indexterm><primary>thumbnails</primary></indexterm>now (do not confuse the script THUMB_PDF <indexterm><primary>THUMB_PDF</primary></indexterm>(thumbpdf) with the environment <indexterm><primary>environment</primary></indexterm>variable THUMBPDF,<indexterm><primary>THUMBPDF</primary></indexterm> which passes additional options to the THUMB_PDF <indexterm><primary>THUMB_PDF</primary></indexterm>script ):</para><screen><![CDATA[$THUMB_PDF $1
]]></screen></listitem><listitem><para>Generate PDF <indexterm><primary>PDF</primary></indexterm>again (2nd pass), to incorporate the thumbnails.<indexterm><primary>thumbnails</primary></indexterm> The following two commands are equivalent to</para><screen><![CDATA[$SGMLTOOLS -b pdf -s sgmltools-pdf -j "-i output.print.pdf" $1.sgml
]]></screen><para>(up to the use of the stylesheet,<indexterm><primary>stylesheet</primary></indexterm> that is), but we have to run them separately, because otherwise we cannot process the file produced by thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>- sgmltools<indexterm><primary>sgmltools</primary></indexterm> will always want a filename of the form @jobname.tpt, where jobname is its PID (process id)  (difficult to guess...). On the other side, thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>will produce $1.ptp. So we have to &quot;simulate&quot;<indexterm><primary>simulate</primary></indexterm> sgmltools <indexterm><primary>sgmltools</primary></indexterm>with the following two commands:</para><itemizedlist><listitem><para>This will produce a tex file from the SGML <indexterm><primary>SGML</primary></indexterm>source:</para><screen><![CDATA[$OPENJADE -t tex -d $PRINT_PDF_DSL -o $1.tex -i "output.print.pdf" $1.sgml
]]></screen></listitem><listitem><para>This will produce a PDF <indexterm><primary>PDF</primary></indexterm>file from the tex file. This PDF <indexterm><primary>PDF</primary></indexterm>file <emphasis>will</emphasis> have thumbnails!</para><screen><![CDATA[$PDFJADETEX $1.tex
]]></screen></listitem><listitem><para>We must call pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>a second time, because the first time there was no .aux file and the bookmarks <indexterm><primary>bookmarks</primary></indexterm>were not created:</para><screen><![CDATA[$PDFJADETEX $1.tex
]]></screen></listitem><listitem><para>A third pass of pdflatex <indexterm><primary>pdflatex</primary></indexterm>is needed, in order to get the page numbers <indexterm><primary>numbers</primary></indexterm>in the Table of Contents computed. See the PRINT_PDF_DSL <indexterm><primary>PRINT_PDF_DSL</primary></indexterm>used above for the parameters that control printing and placement of ToC:</para><screen><![CDATA[$PDFJADETEX $1.tex
]]></screen></listitem></itemizedlist></listitem></itemizedlist><para>Our PDF <indexterm><primary>PDF</primary></indexterm>document, with all its bells <indexterm><primary>bells</primary></indexterm>and whistles, is now ready!</para></sect3>
<sect3 id="explain-document-creation-RTF-TXT"><title>Document creation: RTF and TXT</title><para>The RTF <indexterm><primary>RTF</primary></indexterm>and TXT <indexterm><primary>TXT</primary></indexterm>outputs are easy. For the RTF,<indexterm><primary>RTF</primary></indexterm> we just have to do:</para><screen><![CDATA[$OPENJADE -t rtf -d $PRINT_RTF_DSL  -i "output.print.bmp" $1.sgml
]]></screen><para>and for the TXT:<indexterm><primary>TXT</primary></indexterm></para><screen><![CDATA[$LYNX -dump -nolist $1.html > $1.txt
]]></screen><para>i.e. we use the Lynx <indexterm><primary>Lynx</primary></indexterm>text browser <indexterm><primary>browser</primary></indexterm>with the -dump option to create a text version from the one, big HTML <indexterm><primary>HTML</primary></indexterm>file we created previously.</para></sect3>
<sect3 id="explain-document-creation-PS"><title>Document creation: PS</title><para>For the PS <indexterm><primary>PS</primary></indexterm>output, we have a little more work: we have to set the printer to &quot;cmz&quot;<indexterm><primary>cmz</primary></indexterm>, so that dvips <indexterm><primary>dvips</primary></indexterm>(which will be called either through sgmltools,<indexterm><primary>sgmltools</primary></indexterm> as in older versions of the script, or directly, as in newer ones) will search for the file config.cm (located in /var/lib/texmf/dvips/config/config.cm on my system), which contains the mappings for the &quot;Computer-Modern&quot;<indexterm><primary>Computer-Modern</primary></indexterm> fonts.<indexterm><primary>fonts</primary></indexterm> We use &quot;cmz&quot;<indexterm><primary>cmz</primary></indexterm> instead of &quot;cm&quot; in order to embed <indexterm><primary>embed</primary></indexterm>the font in the PS <indexterm><primary>PS</primary></indexterm>file, thus making it portable (there is also a file config.cmz):</para><screen><![CDATA[PRINTER="cmz"
]]><![CDATA[export PRINTER
]]><![CDATA[$OPENJADE -t tex -d $PRINT_PS_DSL -o $1.tex -i "output.print.eps" $1.sgml
]]><![CDATA[# Compress PS
]]><![CDATA[$GZIP $1.ps
]]></screen><para>As with PDFJADETEX <indexterm><primary>PDFJADETEX</primary></indexterm>in <xref linkend="explain-document-creation-PDF">, again 3 passes are necessary:</para><screen><![CDATA[$JADETEX $1.tex
]]><![CDATA[$JADETEX $1.tex
]]><![CDATA[$JADETEX $1.tex
]]></screen><para>An equivalent command would be </para><screen><![CDATA[$SGMLTOOLS -b ps -s sgmltools-ps -j "-i output.print.eps" $1.sgml
]]></screen><para>but you would have to use the right stylesheet <indexterm><primary>stylesheet</primary></indexterm>(in this invocation,<indexterm><primary>invocation</primary></indexterm> the sgmltools-ps <indexterm><primary>sgmltools-ps</primary></indexterm>stylesheet is used, which is mapped, through the /etc/sgml/aliases file to &quot;-//SGMLtools//DOCUMENT Docbook <indexterm><primary>Docbook</primary></indexterm>Style Sheet for Print//EN&quot;#print.ps, which in turn is mapped, through the sgmltools <indexterm><primary>sgmltools</primary></indexterm>catalog file /usr/share/sgml/stylesheets/sgmltools/sgmltools.cat, to print.dsl#print.ps, i.e. the print.ps id of the print.dsl <indexterm><primary>print.dsl</primary></indexterm>file in the same directory where sgmltools.<indexterm><primary>sgmltools</primary></indexterm>cat is also located - phew...).</para></sect3>
<sect3 id="explain-housekeeping-and-special-processing"><title>Housekeeping and special processing</title><para>Our documents are now all ready. What follows is just general housekeeping:<indexterm><primary>housekeeping</primary></indexterm> move all documents in the HTML<indexterm><primary>HTML</primary></indexterm> directory and remove the .tpt file. Remove all .pdf, .eps, .gif and .jpg images from ./images under $1 (myTemplate in our example, ./images in the <emphasis>current</emphasis> directory is not affected!). From what has been created, leave only $1.sgml and index.sgml in the current (working) directory:</para><screen><![CDATA[mv $1.txt $1.rtf $1.pdf $1.ps.gz $1/
]]><![CDATA[mv $1.html $1/
]]><![CDATA[rm $1.tpt $1.log $1.aux $1.out $1.tex
]]><![CDATA[rm $1/images/*.pdf $1/images/*.eps $1/images/*.gif $1/images/*.jpg
]]><![CDATA[rm $1/images/*/*.pdf $1/images/*/*.eps $1/images/*/*.gif $1/images/*/*.jpg
]]><![CDATA[cp $1.sgml $1/
]]></screen><para>You may continue with the processing,<indexterm><primary>processing</primary></indexterm> calling tar to create various archives,<indexterm><primary>archives</primary></indexterm> or sed to further tweak <indexterm><primary>tweak</primary></indexterm>the HTML <indexterm><primary>HTML</primary></indexterm>code of the files. I leave these steps as an example for the interested reader. If you don't need this special processing,<indexterm><primary>processing</primary></indexterm> you should comment it!</para></sect3>
</sect2>
<sect2 id="explain-DSSSL-stylesheets"><title>DSSSL stylesheets</title><para>In <xref linkend="DSSSL-stylesheets"> we copied these .dsl files to the current working directory:</para><itemizedlist><listitem><para><ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink>, <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink>, <ulink url="lyxtox-print-ps.dsl">lyxtox-print-ps.dsl</ulink>, <ulink url="lyxtox-print-rtf.dsl">lyxtox-print-rtf.dsl</ulink>, <ulink url="lyxtox-print-txt.dsl">lyxtox-print-txt.dsl</ulink> and <ulink url="lyxtox-print-howto.dsl">lyxtox-print-howto.dsl</ulink>. These control the style of the print formats (i.e. all formats except HTML). </para></listitem><listitem><para><ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink>: this file controls the HTML <indexterm><primary>HTML</primary></indexterm>output in many HTML <indexterm><primary>HTML</primary></indexterm>files (one HTML <indexterm><primary>HTML</primary></indexterm>file per section).</para></listitem><listitem><para><ulink url="lyxtox-onehtml.dsl">lyxtox-onehtml.dsl</ulink>: this file controls the HTML <indexterm><primary>HTML</primary></indexterm>output in one big HTML <indexterm><primary>HTML</primary></indexterm>file (Jade option: nochunks).</para></listitem></itemizedlist><para>Every change you wish to do should normally go in one of these three files - often even to more than one, e.g. when your change affects the HTML <indexterm><primary>HTML</primary></indexterm>output for both one and many files (&ldquo;chunks&rdquo;). You should leave the original files that came with the Norman Walsh <indexterm><primary>Walsh</primary></indexterm>stylesheets unchanged and put your changes in the above files instead. Technically, this amounts to writing your own &ldquo;driver&rdquo; file. This is the easiest way to incorporate your preferences <indexterm><primary>preferences</primary></indexterm>and remain flexible during upgrades. </para><note>
<title>TXT and HOWTO print targets</title>
<para>
Currently, the <ulink url="lyxtox-print-txt.dsl">lyxtox-print-txt.dsl</ulink> and <ulink url="lyxtox-print-howto.dsl">lyxtox-print-howto.dsl</ulink> are not used, but are included here for your convenience and for the sake of completeness. You can thus see the common pattern used in all print stylesheets and use it for your own purposes.
</para>
<para>
For the TXT format I currently use the &ldquo;onehtml&rdquo; target: after the one, big HTML file has been rendered, Lynx (the text browser) is called with the -dump and -nolist options to create a text version directly from HTML, without any stylesheet for text. Note that, for a very complex document like the <ulink url="http://www.karakas-online.de/EN-Book/">PHP-Nuke HOWTO</ulink> (more than 500 pages, 1000 links to external URLs, 1500 cross-references, 2500 Index entries, 400 files in the &ldquo;chunked&rdquo; HTML version), the call to sgmltools with the &ldquo;-b txt&rdquo; option breaks with an error (caused probably by too many warnings about cross-references), although it works with smaller and less complex documents.
</para>
<para>
The &ldquo;howto&rdquo; print target is not used at all, but is included following the example of the print.dsl file that comes with the original sgmltools package. 
</para>
</note>
<para>The basic driver file looks like this (see <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/custom.html">Customizing the Stylesheets</ulink>):</para><screen><![CDATA[<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
]]><![CDATA[<!ENTITY dbstyle SYSTEM "docbook.dsl" CDATA DSSSL>
]]><![CDATA[]>
]]><![CDATA[
]]><![CDATA[<style-sheet>
]]><![CDATA[<style-specification use="docbook">
]]><![CDATA[<style-specification-body>
]]><![CDATA[
]]><![CDATA[;; your stuff goes here...
]]><![CDATA[
]]><![CDATA[</style-specification-body>
]]><![CDATA[</style-specification>
]]><![CDATA[<external-specification id="docbook" document="dbstyle">
]]><![CDATA[</style-sheet>
]]></screen><para>Make sure that you specify, in the system identifier,<indexterm><primary>identifier</primary></indexterm> the full path <indexterm><primary>path</primary></indexterm>to the docbook.dsl <indexterm><primary>docbook.dsl</primary></indexterm>file that you want to customize; for example, /usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/docbook.dsl (this is already done in the stylesheets provided, at least as long as your other settings, like Catalogs (<xref linkend="catalog-paths">) are correct).</para><para>You can add your own definitions, or redefinitions, of stylesheet <indexterm><primary>stylesheet</primary></indexterm>rules<indexterm><primary>rules</primary></indexterm> and parameters where</para><screen><![CDATA[;; your stuff goes here...
]]></screen><para>occurs in the example above.</para><para>A lot of work, research <indexterm><primary>research</primary></indexterm>and experimentation has been invested in the above three stylesheet <indexterm><primary>stylesheet</primary></indexterm>files, so let's explain some of the most important changes they introduce:</para><itemizedlist><listitem><para>To generate a Table of Contents for articles, %generate-article-toc% <indexterm><primary>%generate-article-toc%</primary></indexterm>has been set to true:</para><screen><![CDATA[(define %generate-article-toc%
]]><![CDATA[  ;; Should a Table of Contents be produced for Articles?
]]><![CDATA[  #t)
]]></screen></listitem><listitem><para>To get a title page for articles, %generate-article-titlepage% <indexterm><primary>%generate-article-titlepage%</primary></indexterm>has been set to true:</para><screen><![CDATA[(define %generate-article-titlepage%
]]><![CDATA[  ;; Should an article title page be produced?
]]><![CDATA[  #t)
]]></screen></listitem><listitem><para>The CSS <indexterm><primary>CSS</primary></indexterm>has been set to &ldquo;ck-style.css&rdquo;:</para><screen><![CDATA[(define %stylesheet%
]]><![CDATA[  ;; Name of the stylesheet to use
]]><![CDATA[  ;; #f)
]]><![CDATA[  "ck-style.css")
]]></screen><para>Note that this setting will be overwritten by the technique described in <xref linkend="HTML-validation">. You will have to enter the correct CSS <indexterm><primary>CSS</primary></indexterm>in <ulink url="part2">part2</ulink> too. The CSS <indexterm><primary>CSS</primary></indexterm>file used here, <ulink url="ck-style.css">ck-style.css</ulink>, is a <ulink url="http://www.karakas-online.de/myLinuxTips/css-for-docbook.html">CSS for DocBook</ulink>, especially crafted for the classes that appear in the automatically <indexterm><primary>automatically</primary></indexterm>generated HTML <indexterm><primary>HTML</primary></indexterm>code of the DocBook <indexterm><primary>DocBook</primary></indexterm>stylesheets. It incorporates some other fine features as well, like an elaborate font-controlling mechanism that passes the accessibility <indexterm><primary>accessibility</primary></indexterm>tests (see <xref linkend="accessibility">) and is still browser-independent, or a user-specified <indexterm><primary>user-specified</primary></indexterm>icon <indexterm><primary>icon</primary></indexterm>as a list bullet<indexterm><primary>bullet</primary></indexterm> - up to a rotating globe <indexterm><primary>globe</primary></indexterm>that appears besides links that do <emphasis>not</emphasis> belong to a user-specifiable &ldquo;local&rdquo; domain (i.e. links that point &ldquo;outside&rdquo; the document <indexterm><primary>document</primary></indexterm>collection currently viewed). The CSS <indexterm><primary>CSS</primary></indexterm>file is discussed in detail in <xref linkend="explain-CSS">.</para></listitem><listitem><para>The width of the table that contains verbatim environments <indexterm><primary>environments</primary></indexterm>(like program listings) has been set to max. 95%. This is not the same as the value used in the CSS <indexterm><primary>CSS</primary></indexterm>(see <xref linkend="explain-CSS">) for the PRE.SCREEN <indexterm><primary>PRE.SCREEN</primary></indexterm>and PRE.PROGRAMLISTING environments,<indexterm><primary>environments</primary></indexterm> which should be 100%.</para><screen><![CDATA[(define ($table-width$)
]]><![CDATA[  ;; REFENTRY table-width
]]><![CDATA[  ;; PURP Calculate table width
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; This function is called to calculate the width of tables that should
]]><![CDATA[  ;; theoretically be "100%" wide. Unfortunately, in HTML, a 100% width 
]]><![CDATA[  ;; table in a list hangs off the right side of the browser window.  (Who's
]]><![CDATA[  ;; mistake was that!).  So this function provides a way to massage
]]><![CDATA[  ;; the width appropriately.
]]><![CDATA[  ;;
]]><![CDATA[  ;; This version is fairly dumb.
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[  (if (has-ancestor-member? (current-node) '("LISTITEM"))
]]><![CDATA[      "90%"
]]><![CDATA[      "95%"))
]]></screen></listitem></itemizedlist><screen><![CDATA[
]]></screen><itemizedlist><listitem><para>&ldquo;PDF&rdquo; has been added to the list of mediaobject <indexterm><primary>mediaobject</primary></indexterm>notations.<indexterm><primary>notations</primary></indexterm> Otherwise, no images will be displayed in PDF <indexterm><primary>PDF</primary></indexterm>(see also <xref linkend="explain-figures">):</para><screen><![CDATA[(define preferred-mediaobject-notations
]]><![CDATA[  (list "PDF" "EPS" "PS" "JPG" "JPEG" "PNG" "linespecific"))
]]><![CDATA[(define preferred-mediaobject-extensions
]]><![CDATA[  (list "pdf" "eps" "ps" "jpg" "jpeg" "png"))
]]></screen></listitem><listitem><para>The default graphic extension <indexterm><primary>extension</primary></indexterm>has been changed to &ldquo;png&rdquo;:</para><screen><![CDATA[(define %graphic-default-extension%
]]><![CDATA[  ;; REFENTRY graphic-default-extension
]]><![CDATA[  ;; PURP Default extension for graphic FILEREFs
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; The '%graphic-default-extension%' will be
]]><![CDATA[  ;; added to the end of all 'fileref' filenames on
]]><![CDATA[  ;; 'Graphic's if they do not end in one of the
]]><![CDATA[  ;; '%graphic-extensions%'.  Set this to '#f'
]]><![CDATA[  ;; to turn off this feature.
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[  ;; #f)
]]><![CDATA[  "png")
]]></screen></listitem><listitem><para>&ldquo;pdf&rdquo; and &ldquo;tex&rdquo; have been added to the list of graphic extensions <indexterm><primary>extensions</primary></indexterm>- otherwise you will get errors (see <xref linkend="errors-and-warnings">):</para><screen><![CDATA[(define %graphic-extensions%
]]><![CDATA[  ;; REFENTRY graphic-extensions
]]><![CDATA[  ;; PURP List of graphic filename extensions
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; The list of extensions which may appear on a 'fileref'
]]><![CDATA[  ;; on a 'Graphic' which are indicative of graphic formats.
]]><![CDATA[  ;;
]]><![CDATA[  ;; Filenames that end in one of these extensions will not have
]]><![CDATA[  ;; the '%graphic-default-extension%' added to them.
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[  '("gif" "jpg" "jpeg" "png" "tif" "tiff" "eps" "epsf" "pdf" "tex"))
]]></screen></listitem><listitem><para>Use graphics for admonitions <indexterm><primary>admonitions</primary></indexterm>(see <xref linkend="admonitions">) and callouts <indexterm><primary>callouts</primary></indexterm>(see <xref linkend="callouts">):</para><screen><![CDATA[(define %admon-graphics%
]]><![CDATA[  ;; Use graphics in admonitions?
]]><![CDATA[  #t)
]]><![CDATA[
]]><![CDATA[(define %callout-graphics%
]]><![CDATA[  ;; If true, callouts are presented with graphics (e.g., reverse-video
]]><![CDATA[  ;; circled numbers instead of "(1)", "(2)", etc.).
]]><![CDATA[  ;; Default graphics are provided in the distribution.
]]><![CDATA[  #t)
]]></screen></listitem><listitem><para>The admonition <indexterm><primary>admonition</primary></indexterm>graphics path <indexterm><primary>path</primary></indexterm>has been set to &ldquo;./images&rdquo;:</para><screen><![CDATA[(define %admon-graphics-path%
]]><![CDATA[  ;; Path to admonition graphics
]]><![CDATA[  ;; Sets the path, probably relative to the directory
]]><![CDATA[  ;; where the HTML files are created, to the admonition
]]><![CDATA[  ;; graphics.
]]><![CDATA[  ;;
]]><![CDATA[  ;; This needs to be "./images/" for tar distributed articles
]]><![CDATA[  ;; This needs to be "../images/" for tar distributed Newbiedoc book
]]><![CDATA[  ;; This needs to be "../images/" for individual articles on our website
]]><![CDATA[  "./images/")
]]></screen></listitem><listitem><para>The callouts <indexterm><primary>callouts</primary></indexterm>graphics path <indexterm><primary>path</primary></indexterm>has been set to &quot;./images/callouts/&quot;:</para><screen><![CDATA[(define %callout-graphics-path%
]]><![CDATA[  ;; Sets the path, probably relative to the directory where the HTML
]]><![CDATA[  ;; files are created, to the callout graphics.
]]><![CDATA[  "./images/callouts/")
]]></screen></listitem><listitem><para>The callout graphics extension <indexterm><primary>extension</primary></indexterm>has been set to &ldquo;png&rdquo;:</para><screen><![CDATA[(define %callout-graphics-extension%
]]><![CDATA[  ;; REFENTRY callout-graphics-extension
]]><![CDATA[  ;; PURP Extension for callout graphics
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; Sets the extension to use on callout graphics.
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[  ".png")
]]></screen></listitem><listitem><para>The code that produces the full name of admonitions <indexterm><primary>admonitions</primary></indexterm>has been changed:</para><screen><![CDATA[(define ($admon-graphic$ #!optional (nd (current-node)))
]]><![CDATA[  ;; Admonition graphic file
]]><![CDATA[  ;; Given an admonition node, returns the name of the
]]><![CDATA[  ;; graphic that should be used for that admonition.
]]><![CDATA[  (cond ((equal? (gi nd) (normalize "tip"))
]]><![CDATA[         (string-append %admon-graphics-path% "tip."
]]><![CDATA[                        %graphic-default-extension%))
]]><![CDATA[        ((equal? (gi nd) (normalize "note"))
]]><![CDATA[         (string-append %admon-graphics-path% "note."
]]><![CDATA[                        %graphic-default-extension%))
]]><![CDATA[        ((equal? (gi nd) (normalize "important"))
]]><![CDATA[         (string-append %admon-graphics-path% "important."
]]><![CDATA[                        %graphic-default-extension%))
]]><![CDATA[        ((equal? (gi nd) (normalize "caution"))
]]><![CDATA[         (string-append %admon-graphics-path% "caution."
]]><![CDATA[                        %graphic-default-extension%))
]]><![CDATA[        ((equal? (gi nd) (normalize "warning"))
]]><![CDATA[         (string-append %admon-graphics-path% "warning."
]]><![CDATA[                        %graphic-default-extension%))
]]><![CDATA[        (else (error (string-append (gi nd) " is not an admonition.")))))
]]></screen></listitem><listitem><para>In <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink> (which uses elements taken from Mandrake's manual-print.dsl), in order to be able to have URLs in PDF:<indexterm><primary>PDF</primary></indexterm></para><screen><![CDATA[;;  Inserted in order to be able to get URLs in PDF documents.
]]><![CDATA[;;  Adapted from manual-print.dsl of <productname>Mandrake</productname>.
]]><![CDATA[;; Include the flow object class "formatting-instruction" : ONLY for Jade
]]><![CDATA[(declare-flow-object-class formatting-instruction
]]><![CDATA[       "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction")
]]><![CDATA[;; *** URLs ***
]]><![CDATA[;; Original : dblink.dsl
]]><![CDATA[(element ulink
]]><![CDATA[ (sosofo-append
]]><![CDATA[  ;; If you allow process-children here, you will get the text printed once more!
]]><![CDATA[  ;; (process-children)             ;; Write the text with its format (anchor in HTML)
]]><![CDATA[  (make formatting-instruction      ;; Write : " \href{" + theUrl + "}{" + theText + "}"
]]><![CDATA[    data: (string-append " \\href{" (attribute-string (normalize "url")) "}{" (data-of (current-node)) "}")
]]><![CDATA[  )
]]><![CDATA[ )
]]><![CDATA[)
]]><![CDATA[;; These three elements are from "dbindex.dsl".
]]><![CDATA[;; Must be placed here because of the redifinition of "ulink".
]]><![CDATA[;; Otherwise the Index entries will point to HTML files,
]]><![CDATA[;; instead of page numbers.
]]><![CDATA[(element (primaryie ulink)
]]><![CDATA[  (indexentry-link (current-node)))
]]><![CDATA[(element (secondaryie ulink)
]]><![CDATA[  (indexentry-link (current-node)))
]]><![CDATA[(element (tertiaryie ulink)
]]><![CDATA[  (indexentry-link (current-node)))
]]></screen></listitem><listitem><para>To be able to use Computer Modern fonts:<indexterm><primary>fonts</primary></indexterm></para><screen><![CDATA[;;  Inserted in order to be able to use Computer Modern fonts  in PS and PDF documents.
]]><![CDATA[;;  The font names _must_ be written exactly as follows ("Computer-Modern", 
]]><![CDATA[;;  not "Computer Modern") for pdfjadetex to recognize them and use the T1
]]><![CDATA[;;  fonts istead of the PK (Type 3) ones (which will look ugly on screen)!
]]><![CDATA[    ;;
]]><![CDATA[    ;;  Gnuishly correct fonts...
]]><![CDATA[    ;;
]]><![CDATA[    (define %body-font-family% "Computer-Modern")
]]><![CDATA[    (define %mono-font-family% "Computer-Modern-Typewriter")
]]><![CDATA[    (define %title-font-family% "Computer-Modern-Sans")
]]><![CDATA[    (define %admon-font-family% "Computer-Modern-Sans")
]]><![CDATA[    (define %guilabel-font-family% "Computer-Modern-Sans")
]]></screen></listitem><listitem><para>To use chapter/section/subsection labels as filenames for the respective HTML <indexterm><primary>HTML</primary></indexterm>files:</para><screen><![CDATA[(define %use-id-as-filename%
]]><![CDATA[  ;; Use <acronym>ID</acronym> attributes as name for component HTML files?
]]><![CDATA[  #t)
]]></screen></listitem></itemizedlist><screen><![CDATA[
]]></screen><itemizedlist><listitem><para>In <ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink>, to be able control what section levels get put into separate HTML <indexterm><primary>HTML</primary></indexterm>files (chunks) in the chunked <indexterm><primary>chunked</primary></indexterm>version, the chunk-section-depth <indexterm><primary>chunk-section-depth</primary></indexterm>has been included (taken from the html/dbchunk.dsl file, which on my system is /usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/html/dbchunk.dsl with full name):</para><screen><![CDATA[(define (chunk-section-depth)
]]><![CDATA[  2)
]]></screen><para>A value of 1 for chunk-section-depth <indexterm><primary>chunk-section-depth</primary></indexterm>means that the chunks <indexterm><primary>chunks</primary></indexterm>are the individual SECT1 elements, i.e. the Sections. A value of 2 means that the chunks <indexterm><primary>chunks</primary></indexterm>are the individual SECT2 <indexterm><primary>SECT2</primary></indexterm>elements, i.e. the SubSections <indexterm><primary>SubSections</primary></indexterm>and so on. SECT1, <indexterm><primary>SECT1,</primary></indexterm>SECT2 <indexterm><primary>SECT2</primary></indexterm>and SECT3 <indexterm><primary>SECT3</primary></indexterm>are the SGML <indexterm><primary>SGML</primary></indexterm>tags used to denote a Section, SubSection<indexterm><primary>SubSection</primary></indexterm> and SubSubSection <indexterm><primary>SubSubSection</primary></indexterm>respectively. There is no meaning in using chunk-section-depth <indexterm><primary>chunk-section-depth</primary></indexterm>with values higher than 3, at least not with LyX,<indexterm><primary>LyX</primary></indexterm> since SubSubSubsections <indexterm><primary>SubSubSubsections</primary></indexterm>is the deepest level you can use in LyX <indexterm><primary>LyX</primary></indexterm>(at least with the default settings).</para></listitem><listitem><para>However, as painful experimentation has shown, setting a higher value for chunk-section-depth <indexterm><primary>chunk-section-depth</primary></indexterm>will have no effect, if &ldquo;sect2&rdquo;, &ldquo;sect3&rdquo; etc. are not contained in the chunk-element-list <indexterm><primary>chunk-element-list</primary></indexterm>list. The list </para><screen><![CDATA[(define (chunk-element-list)
]]><![CDATA[  (list (normalize "preface")
]]><![CDATA[        (normalize "chapter")
]]><![CDATA[        (normalize "appendix")
]]><![CDATA[        (normalize "article")
]]><![CDATA[        (normalize "glossary")
]]><![CDATA[        (normalize "bibliography")
]]><![CDATA[        (normalize "index")
]]><![CDATA[        (normalize "colophon")
]]><![CDATA[        (normalize "setindex")
]]><![CDATA[        (normalize "reference")
]]><![CDATA[        (normalize "refentry")
]]><![CDATA[        (normalize "part")
]]><![CDATA[        (normalize "sect1")
]]><![CDATA[        (normalize "sect2")
]]><![CDATA[        (normalize "section")
]]><![CDATA[        (normalize "book") ;; just in case nothing else matches...
]]><![CDATA[        (normalize "set")  ;; sets are definitely chunks...
]]><![CDATA[        ))
]]></screen><para>contains the elements that constitute chunks.<indexterm><primary>chunks</primary></indexterm> If you take an element <indexterm><primary>element</primary></indexterm>out of the list, the chunk-section-depth <indexterm><primary>chunk-section-depth</primary></indexterm>above will not have any effect. Thus, to have chunks <indexterm><primary>chunks</primary></indexterm>on sect2, sect3 etc., you must have them included in this list. chunk-element-list <indexterm><primary>chunk-element-list</primary></indexterm>is originally defined in the html/dbchunk.dsl file (just like chunk-section-depth), which on my system is /usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/html/dbchunk.dsl with full name. See also <ulink url="http://www.via.ecp.fr/via/ml/sgml-tools/199901/msg00205.html">Naming of generated html code from sgml documents</ulink>. Note that if you include &ldquo;sect3&rdquo; (SubSubSubsections) in the chunk-element-list <indexterm><primary>chunk-element-list</primary></indexterm>list, you will get chunks<indexterm><primary>chunks</primary></indexterm> on SubSubSubsections,<indexterm><primary>SubSubSubsections</primary></indexterm> no matter if your chunk-section-depth <indexterm><primary>chunk-section-depth</primary></indexterm>is only 2 and not 3!</para></listitem><listitem><para>To force the table of contents to be on a separate HTML <indexterm><primary>HTML</primary></indexterm>page and not contain any section:</para><screen><![CDATA[(define (chunk-skip-first-element-list)
]]><![CDATA[  ;; forces the Table of Contents on separate page
]]><![CDATA[  '())
]]></screen><para>The reason that Norm added support for merging <indexterm><primary>merging</primary></indexterm>the first sect1 into the file with its parent is because the alternative is really ugly in the case that you have a chapter (title) immediately followed by a section (title) (see <ulink url="http://www.via.ecp.fr/via/ml/sgml-tools/199901/msg00163.html">Use of &lt;Para&gt; within &lt;ListItem&gt; mangles list items</ulink>). </para><tip>
<title>Tip</title> 
<para> 
That's why you should try to put at least some introductory text after a chapter title and before the first section of the chapter!
</para>
</tip>  
<para>FIXME: LyX inserts an extra &lt;/listitem&gt; here, if I don't have this line...</para></listitem><listitem><para>To get a list of figures <indexterm><primary>figures</primary></indexterm>at the start of the document,<indexterm><primary>document</primary></indexterm> the generate-book-lot-list must contain &ldquo;figure&rdquo;, as in the following example:</para><screen><![CDATA[(define ($generate-book-lot-list$)
]]><![CDATA[  ;; REFENTRY generate-book-lot-list
]]><![CDATA[  ;; PURP Which Lists of Titles should be produced for Books?
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; This parameter should be a list (possibly empty) of the elements
]]><![CDATA[  ;; for which Lists of Titles should be produced for each 'Book'.
]]><![CDATA[  ;;
]]><![CDATA[  ;; It is meaningless to put elements that do not have titles in this
]]><![CDATA[  ;; list.  If elements with optional titles are placed in this list, only
]]><![CDATA[  ;; the instances of those elements that do have titles will appear in
]]><![CDATA[  ;; the LOT.
]]><![CDATA[  ;;
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[(list (normalize "table")
]]><![CDATA[(normalize "figure")
]]><![CDATA[(normalize "example")
]]><![CDATA[(normalize "equation")))
]]></screen><para>The same must be the case if you want a list of tables (&ldquo;table&rdquo;), examples (&ldquo;example&rdquo;) or equations <indexterm><primary>equations</primary></indexterm>(&ldquo;equation&rdquo;). Normally, you will not have to touch this (i.e. your customization <indexterm><primary>customization</primary></indexterm>layer need not contain this code), as the above setting is the default one (for books).</para></listitem></itemizedlist><screen><![CDATA[
]]></screen><itemizedlist><listitem><para>To be able to display &ldquo;other credit&rdquo;, &ldquo;release info&rdquo; and &ldquo;publisher&rdquo; information on a book's title page, these elements must be added to the book-titlepage-recto-elements <indexterm><primary>book-titlepage-recto-elements</primary></indexterm>list:</para><screen><![CDATA[(define (book-titlepage-recto-elements)
]]><![CDATA[  ;; elements on a book's titlepage
]]><![CDATA[  ;; note: added revhistory to the default list
]]><![CDATA[  ;; note: added othercredit to the default list
]]><![CDATA[  ;; note: added releaseinfo to the default list
]]><![CDATA[  ;; note: added publisher to the default list
]]><![CDATA[  (list (normalize "title")
]]><![CDATA[        (normalize "subtitle")
]]><![CDATA[        (normalize "graphic")
]]><![CDATA[        (normalize "mediaobject")
]]><![CDATA[        (normalize "corpauthor")
]]><![CDATA[        (normalize "authorgroup")
]]><![CDATA[        (normalize "author")
]]><![CDATA[        (normalize "othercredit")
]]><![CDATA[        (normalize "releaseinfo")
]]><![CDATA[        (normalize "publisher")
]]><![CDATA[        (normalize "editor")
]]><![CDATA[        (normalize "copyright")
]]><![CDATA[        (normalize "pubdate")
]]><![CDATA[        (normalize "revhistory")
]]><![CDATA[        (normalize "abstract")
]]><![CDATA[        (normalize "legalnotice")))
]]></screen></listitem><listitem><para>and the same must be done for the article-titlepage-recto-elements <indexterm><primary>article-titlepage-recto-elements</primary></indexterm>list, if we want to display them in articles' title pages too:</para><screen><![CDATA[(define (article-titlepage-recto-elements)
]]><![CDATA[  ;; elements on an article's titlepage
]]><![CDATA[  ;; note: added othercredit to the default list
]]><![CDATA[  (list (normalize "title")
]]><![CDATA[        (normalize "subtitle")
]]><![CDATA[        (normalize "authorgroup")
]]><![CDATA[        (normalize "author")
]]><![CDATA[        (normalize "othercredit")
]]><![CDATA[        (normalize "releaseinfo")
]]><![CDATA[        (normalize "copyright")
]]><![CDATA[        (normalize "pubdate")
]]><![CDATA[        (normalize "revhistory")
]]><![CDATA[        (normalize "abstract")
]]><![CDATA[        (normalize "legalnotice")))
]]></screen></listitem><listitem><para>and the following code must be added:</para><screen><![CDATA[(define (process-contrib #!optional (sosofo (process-children)))
]]><![CDATA[  ;; print out with othercredit information; for translators, etc.
]]><![CDATA[  (make sequence
]]><![CDATA[    (make element gi: "SPAN"
]]><![CDATA[          attributes: (list (list "CLASS" (gi)))
]]><![CDATA[          (process-children))))
]]><![CDATA[(define (process-othercredit #!optional (sosofo (process-children)))
]]><![CDATA[  ;; print out othercredit information; for translators, etc.
]]><![CDATA[  (let ((author-name  (author-string))
]]><![CDATA[        (author-contrib (select-elements (children (current-node))
]]><![CDATA[                                          (normalize "contrib"))))
]]><![CDATA[    (make element gi: "P"
]]><![CDATA[         attributes: (list (list "CLASS" (gi)))
]]><![CDATA[         (make element gi: "B"
]]><![CDATA[              (literal author-name)
]]><![CDATA[              (literal " - "))
]]><![CDATA[         (process-node-list author-contrib))))
]]><![CDATA[(mode article-titlepage-recto-mode
]]><![CDATA[  (element contrib (process-contrib))
]]><![CDATA[  (element othercredit (process-othercredit))
]]><![CDATA[)
]]><![CDATA[(mode book-titlepage-recto-mode
]]><![CDATA[  (element contrib (process-contrib))
]]><![CDATA[  (element othercredit (process-othercredit))
]]><![CDATA[)
]]><![CDATA[(define (article-title nd)
]]><![CDATA[  (let* ((artchild  (children nd))
]]><![CDATA[         (artheader (select-elements artchild (normalize "artheader")))
]]><![CDATA[         (artinfo   (select-elements artchild (normalize "articleinfo")))
]]><![CDATA[         (ahdr (if (node-list-empty? artheader)
]]><![CDATA[                   artinfo
]]><![CDATA[                   artheader))
]]><![CDATA[         (ahtitles  (select-elements (children ahdr)
]]><![CDATA[                                     (normalize "title")))
]]><![CDATA[         (artitles  (select-elements artchild (normalize "title")))
]]><![CDATA[         (titles    (if (node-list-empty? artitles)
]]><![CDATA[                        ahtitles
]]><![CDATA[                        artitles)))
]]><![CDATA[    (if (node-list-empty? titles)
]]><![CDATA[        ""
]]><![CDATA[        (node-list-first titles))))
]]></screen></listitem><listitem><para>...and many other details. You are encouraged to read the source of the stylesheets (<ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink>, <ulink url="lyxtox-onehtml.dsl">lyxtox-onehtml.dsl</ulink>, <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink>, <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink>, <ulink url="lyxtox-print-ps.dsl">lyxtox-print-ps.dsl</ulink>, <ulink url="lyxtox-print-rtf.dsl">lyxtox-print-rtf.dsl</ulink>, <ulink url="lyxtox-print-txt.dsl">lyxtox-print-txt.dsl</ulink>, <ulink url="lyxtox-print-howto.dsl">lyxtox-print-howto.dsl</ulink>)!</para></listitem></itemizedlist><tip>
<title>Important DocBook files</title> 
<para> 
FYI, all changes presented here refer to variables that were originally defined in one of the following files:
<itemizedlist>
<listitem>
<para>
/usr/share/sgml/stylesheets/sgmltools/print.dsl
</para>
</listitem>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/html/dbparam.dsl
</para>
</listitem>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/dbparam.dsl
</para>
</listitem>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/db31.dsl</para>
</listitem>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/print/dbchunk.dsl</para>
</listitem>
</itemizedlist>
As said above, you should not change these files directly, because you will run into a lot of work when you upgrade them.
</para>
<para>
For a list of all parameters, with references to the files that use them, see the 
</para>
<itemizedlist>
<listitem>
<para>
/usr/share/sgml/docbook/docbook-dsssl-stylesheets-1.72/html/XREF
</para>
</listitem>
</itemizedlist>
<para>
file. If you are looking for a parameter and you can't find the file it's in, the XREF file is your friend.
</para>
</tip>
</sect2>
<sect2 id="explain-inline-graphics"><title>Inline graphics</title><para>There is no way to include inline <indexterm><primary>inline</primary></indexterm>graphics with the method described in this document <indexterm><primary>document</primary></indexterm>- here's why:</para><para>In theory, you could put something like</para><screen><![CDATA[/^.*[^<]*<inlinegraphic/{
]]><![CDATA[s/<inlinegraphic fileref="\([^"]*\)"[^>]*>/\
]]><![CDATA[   <inlinemediaobject>\
]]><![CDATA[      <\!\[ \%output\.print\.png; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\.\/images\/\1.png" format="PNG">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[      \]\]>\
]]><![CDATA[      <\!\[ \%output\.print\.pdf; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\1.pdf" format="PDF" scale="65">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[      \]\]>\
]]><![CDATA[      <\!\[ \%output\.print\.eps; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\1.eps" format="EPS">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[       \]\]>\
]]><![CDATA[      <\!\[ \%output\.print\.bmp; \[\
]]><![CDATA[      <imageobject>\
]]><![CDATA[         <imagedata fileref="\1.bmp" format="BMP">\
]]><![CDATA[      <\/imageobject>\
]]><![CDATA[       \]\]>\
]]><![CDATA[      <textobject>\
]]><![CDATA[         <phrase>Inline graphic<\/phrase>\
]]><![CDATA[      <\/textobject>\
]]><![CDATA[   <\/inlinemediaobject>/g
]]><![CDATA[}
]]></screen><para>in <ulink url="sedscr">sedscr</ulink> and thus substitute the &lt;inlinegraphic&gt; element <indexterm><primary>element</primary></indexterm>(which is produced by LyX<indexterm><primary>LyX</primary></indexterm> whenever you choose Insert--&gt;Include File, then &ldquo;Verbatim&rdquo; ) with an &lt;inlinemediaobject&gt; along the lines of <xref linkend="explain-runsed-sed-sedscr">. But LyX <indexterm><primary>LyX</primary></indexterm>uses &lt;inlinegraphic&gt; also for verbatim inclusions of files. We make use of this feature in <xref linkend="LyX-SGML-code">, where we see how to include potentially problematic SGML <indexterm><primary>SGML</primary></indexterm>code in program listings.<indexterm><primary>listings</primary></indexterm> Unfortunately, there is no way to tell which purpose the &lt;inlinegraphic&gt; element <indexterm><primary>element</primary></indexterm>serves in the SGML <indexterm><primary>SGML</primary></indexterm>file that is exported from LyX,<indexterm><primary>LyX</primary></indexterm> a file inclusion of program code, or an inline <indexterm><primary>inline</primary></indexterm>image. The code above would make the substitution <indexterm><primary>substitution</primary></indexterm>in <emphasis>both</emphasis> cases, which would definitely mess things up.</para><tip>
<title>Tip</title> 
<para> 
Nevertheless, you can try it, if you are sure that your code does not include any other files, only images. There is a caveat though: you should create files with the same basename (i.e. <emphasis>without</emphasis> the ending) in the <emphasis>working</emphasis> directory, in addition to the ones you create in ./images. Example: if you want to include an icon named wink.png inline, then you have to create wink.png, wink.eps, wink.pdf and wink.bmp in ./images (as shown in <xref linkend="add-density">) <emphasis>and</emphasis> a (possibly empty, it doesn't really matter) file named "wink" in ./. This is because when you will try to Insert-->Include File, LyX will not allow you to enter a fantasy name in the filename field and, on the other side, you <emphasis>must</emphasis>  enter the filename without the ending and without the directory path, in order for the above code to work in sedscr.
</para>
</tip>  
</sect2>
<sect2 id="explain-catalogs"><title>Catalogs </title><para>A catalogue <indexterm><primary>catalogue</primary></indexterm>is a text file containing the translation rules <indexterm><primary>rules</primary></indexterm>of the public identifier <indexterm><primary>identifier</primary></indexterm>to system's files.</para><para>The identifier <indexterm><primary>identifier</primary></indexterm>systems used by SGML <indexterm><primary>SGML</primary></indexterm>and by some tools <indexterm><primary>tools</primary></indexterm>are based on catalogues<indexterm><primary>catalogues</primary></indexterm> that perform the translation of these identifiers <indexterm><primary>identifiers</primary></indexterm>to files that hold the necessary definitions. For tools <indexterm><primary>tools</primary></indexterm>to be able to find the necessary catalogue(s), the environment<indexterm><primary>environment</primary></indexterm> variable SGML_CATALOG_FILES <indexterm><primary>SGML_CATALOG_FILES</primary></indexterm>should be set, as explained in <xref linkend="explain-environment-variables">. </para><para>In my system, the sgmltools-lite <indexterm><primary>sgmltools-lite</primary></indexterm>package installed the /etc/sgml/catalog file. Its content can be used to set SGML_CATALOG_FILES <indexterm><primary>SGML_CATALOG_FILES</primary></indexterm>as follows:</para><screen><![CDATA[SGML_CATALOG_FILES="/usr/share/sgml/CATALOG.iso_ent" SGML_CATALOG_FILES="$SGML_CATALOG_FILES:
]]><![CDATA[/usr/share/sgml/CATALOG.docbook-dsssl-stylesheets" SGML_CATALOG_FILES="$SGML_CATALOG_FILES:
]]><![CDATA[/usr/share/sgml/CATALOG.docbook_3" SGML_CATALOG_FILES="$SGML_CATALOG_FILES:
]]><![CDATA[/usr/share/sgml/CATALOG.docbook_4" SGML_CATALOG_FILES="$SGML_CATALOG_FILES:
]]><![CDATA[/usr/share/sgml/openjade/catalog" SGML_CATALOG_FILES="$SGML_CATALOG_FILES:
]]><![CDATA[/usr/share/sgml/stylesheets/sgmltools/sgmltools.cat" SGML_CATALOG_FILES="$SGML_CATALOG_FILES:
]]><![CDATA[/usr/share/sgml/dtd/sgmltools/catalog" 
]]><![CDATA[export SGML_CATALOG_FILES 
]]></screen><para>However, as recent versions of lyxtox <indexterm><primary>lyxtox</primary></indexterm>do not use sgmltools,<indexterm><primary>sgmltools</primary></indexterm> I use the relevant (and only those!) lines of my &ldquo;master&rdquo; catalog <indexterm><primary>catalog</primary></indexterm>file in /etc/sgml/catalog to define SGML_CATALOG_FILES <indexterm><primary>SGML_CATALOG_FILES</primary></indexterm>as:</para><screen><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.iso_ent"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.docbook-dsssl-stylesheets"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.mathml-2.0"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.svg-1.1"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/CATALOG.docbook_4"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/sgml/openjade/catalog"
]]><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/refdb/refdb.cat"
]]><![CDATA[export SGML_CATALOG_FILES
]]></screen><para>Generally, you'll need to set the SGML_CATALOG_FILES <indexterm><primary>SGML_CATALOG_FILES</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>variable to all the catalogs that you have under the directory you installed the DocBook <indexterm><primary>DocBook</primary></indexterm>stylesheets (probably something like /usr/share/sgml or /usr/local/sgml, see <xref linkend="DocBook"> and <xref linkend="sgmltools"> for the packages <indexterm><primary>packages</primary></indexterm>that install stylesheets). </para><para>If you want to learn more on catalogues <indexterm><primary>catalogues</primary></indexterm>and the way they are constructed, see <ulink url="http://www.tldp.org/LDP/LDP-Author-Guide/making-catalogues.html">Creating and modifying catalogues</ulink>.</para></sect2>
<sect2 id="explain-CSS"><title>CSS </title><para>See <xref linkend="CSS"> and <xref linkend="HTML-validation"> for the details of using a CSS <indexterm><primary>CSS</primary></indexterm>for the HTML <indexterm><primary>HTML</primary></indexterm>output. The proposed ck-style.css <indexterm><primary>ck-style.css</primary></indexterm>is a CSS <indexterm><primary>CSS</primary></indexterm>tailored to the HTML <indexterm><primary>HTML</primary></indexterm>produced by DocBook.<indexterm><primary>DocBook</primary></indexterm> It also takes into account some modern approaches to accessibility <indexterm><primary>accessibility</primary></indexterm>(see <xref linkend="accessibility">, for more on accessibility <indexterm><primary>accessibility</primary></indexterm>of DocBook <indexterm><primary>DocBook</primary></indexterm>generated HTML <indexterm><primary>HTML</primary></indexterm>pages).</para><para>For example, you can control the navigation header style with</para><screen><![CDATA[DIV.NAVHEADER {
]]><![CDATA[        color: #000000;
]]><![CDATA[        background-color: #EFEFF8;
]]><![CDATA[        padding: 5px;
]]><![CDATA[        margin-bottom: 10px;
]]><![CDATA[        width: 100%;
]]><![CDATA[        border: thin solid #a0a0d0;
]]><![CDATA[}
]]></screen><para>and the navigation footer style with</para><screen><![CDATA[DIV.NAVFOOTER {
]]><![CDATA[        color: #000000;
]]><![CDATA[        background-color: #EFEFF8;
]]><![CDATA[        padding: 5px;
]]><![CDATA[        margin-top: 10px;
]]><![CDATA[        width: 100%;
]]><![CDATA[        border: thin solid #a0a0d0;
]]><![CDATA[}
]]></screen><para>The concepts of margin, border and padding <indexterm><primary>padding</primary></indexterm>follow a page model that is described in W3C's working draft <ulink url="http://www.w3.org/TR/2003/WD-css3-page-20031218/">CSS3 Paged Media Module</ulink>, version of Dec. 18th 2003. <xref linkend="fig-page-area-model">, taken from this document <indexterm><primary>document</primary></indexterm>(Copyright &copy; 2003 <ulink url="http://www.w3.org">W3C</ulink> (<ulink url="http://www.lcs.mit.edu">MIT</ulink>, <ulink url="http://www.ercim.org">ERCIM</ulink>, <ulink url="http://www.keio.ac.jp">Keio</ulink>), All Rights Reserved) illustrates the various geometric <indexterm><primary>geometric</primary></indexterm>notions of this page model. Note that the <ulink url="http://www.w3.org/TR/2003/WD-xsl11-20031217/#area_model">XSL area model</ulink> is deliberately very similar to the CSS <indexterm><primary>CSS</primary></indexterm>one.</para><para>
<figure id="fig-page-area-model" float="1">
   <title>
   CSS page area model.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1004;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1004;.pdf" format="PDF">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1004;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1004;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>CSS page area model.</phrase>
      </textobject>
      <caption>
         <para>CSS page area model.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>If you output admonitions <indexterm><primary>admonitions</primary></indexterm>as tables, rather than graphics (see <xref linkend="admonitions">), then you can control their style with a code like the following (shown here for the &quot;Important&quot; admonition):</para><screen><![CDATA[TABLE.IMPORTANT
]]><![CDATA[{
]]><![CDATA[        font-style:italic;
]]><![CDATA[        border: solid 2px #ff0000;
]]><![CDATA[        width: 70%;
]]><![CDATA[        margin-left: 15%;
]]><![CDATA[}
]]></screen><para>Screen output (code) is controlled by </para><screen><![CDATA[PRE.SCREEN
]]><![CDATA[{
]]><![CDATA[        font-family:monospace;
]]><![CDATA[        white-space: pre;
]]><![CDATA[        width: 100%;
]]><![CDATA[        background-color: #ffffcc;
]]><![CDATA[        border:solid;
]]><![CDATA[        color: #000000;
]]><![CDATA[        border-color: #009999;
]]><![CDATA[        border-left: solid #009999 2px;
]]><![CDATA[        border-right: solid #009999 2px;
]]><![CDATA[        border-top: solid #009999 2px;
]]><![CDATA[        border-bottom: solid #009999 2px;
]]><![CDATA[        padding-left: 15pt;
]]><![CDATA[}
]]></screen><para>while examples and the Table of Contents by</para><screen><![CDATA[DIV.EXAMPLE,DIV.TOC {
]]><![CDATA[        border: thin dotted #70AAE5;
]]><![CDATA[        padding-left: 10px;
]]><![CDATA[        padding-right: 10px;
]]><![CDATA[        color: #000000;
]]><![CDATA[        background-color: #EFF8F8;
]]><![CDATA[}
]]><![CDATA[DIV.TOC {
]]><![CDATA[        margin-left: 20px;
]]><![CDATA[        margin-right: 20px;
]]><![CDATA[        width: 95%;
]]><![CDATA[}
]]></screen><para>An &ldquo;external link&rdquo; icon <indexterm><primary>icon</primary></indexterm>to absolute links (i.e. links starting with &ldquo;http:&rdquo;) is added through</para><screen><![CDATA[/* Add an external-link icon to absolute links */
]]><![CDATA[a[href^="http:"] {
]]><![CDATA[        background: url(images/remote.gif) right center no-repeat;
]]><![CDATA[        padding-right: 12px;
]]><![CDATA[}
]]><![CDATA[a[href^="http:"]:hover {
]]><![CDATA[        background: url(images/remote_a.gif) right center no-repeat;
]]><![CDATA[}
]]></screen><para>However, this alone would put the icon <indexterm><primary>icon</primary></indexterm>on every link with an absolute URL,<indexterm><primary>URL</primary></indexterm> including links pointing to the local domain. This is corrected by</para><screen><![CDATA[/* ...but not to absolute links in this domain... */
]]><![CDATA[a[href^="http://www.karakas-online.de"] {
]]><![CDATA[        background: transparent;
]]><![CDATA[        padding-right: 0px;
]]><![CDATA[}
]]><![CDATA[a[href^="http://www.karakas-online.de"]:hover {
]]><![CDATA[        background: transparent;
]]><![CDATA[}
]]></screen><para>&ldquo;External link&rdquo; icons <indexterm><primary>icons</primary></indexterm>tell you what a link will do before you click on it. There are icons <indexterm><primary>icons</primary></indexterm>specifically designed for this purpose, like <ulink url="http://www.matterform.com/index.php?page=/download/menu.php">QBullets</ulink>. QBullets <indexterm><primary>QBullets</primary></indexterm>are a collection of elegant, animated icons <indexterm><primary>icons</primary></indexterm>that attach to hypertext<indexterm><primary>hypertext</primary></indexterm> links to indicate their function. You can <ulink url="http://www.matterform.com/download/files/qbullets.zip">download Qbullets</ulink> for free from matterform <indexterm><primary>matterform</primary></indexterm>media.</para><para>To use this idea for footnotes,<indexterm><primary>footnotes</primary></indexterm> the name attribute <indexterm><primary>attribute</primary></indexterm>is used as a selector:<indexterm><primary>selector</primary></indexterm></para><screen><![CDATA[/* Add a note icon to footnote links */
]]><![CDATA[a[href^="#FTN"] {
]]><![CDATA[        background: url(images/qbullet-note.gif) right center no-repeat;
]]><![CDATA[        padding-right: 12px;
]]><![CDATA[}
]]><![CDATA[a[href^="#FTN"]:hover {
]]><![CDATA[        background: url(images/qbullet-note_a.gif) right center no-repeat;
]]><![CDATA[}
]]></screen><para>This will select all links whose href attribute <indexterm><primary>attribute</primary></indexterm>starts with &quot;#FTN&quot; and append<indexterm><primary>append</primary></indexterm> a note icon <indexterm><primary>icon</primary></indexterm>to them, which will even show an animated page curl upon passing with the mouse over it (hover). The links whose href attribute <indexterm><primary>attribute</primary></indexterm>starts with &ldquo;#FTN&rdquo; look like </para><screen><![CDATA[<a name="AEN1175" href="#FTN.AEN1175">[1]</a>
]]></screen><para>and point to a footnote.<indexterm><primary>footnote</primary></indexterm> The footnote <indexterm><primary>footnote</primary></indexterm>itself also contains a link - which points back to the referring text. That link will not be affected by the above selection, since its href attribute<indexterm><primary>attribute</primary></indexterm> does not start with &ldquo;#FTN&rdquo; :</para><screen><![CDATA[<a name="FTN.AEN1175" href="explain-runsed-sed-sedscr.html#AEN1175">[1]</a>
]]></screen><para>To display a back icon <indexterm><primary>icon</primary></indexterm>besides those links, a selector <indexterm><primary>selector</primary></indexterm>on the name attribute<indexterm><primary>attribute</primary></indexterm> is used:</para><screen><![CDATA[/* ...and a back icon to the backlinks in the footnotes themselves */
]]><![CDATA[a[name^="FTN"] {
]]><![CDATA[        background: url(images/scrollup.gif) right center no-repeat;
]]><![CDATA[        padding-right: 12px;
]]><![CDATA[}
]]><![CDATA[a[name^="FTN"]:hover {
]]><![CDATA[        background: url(images/scrollup_a.gif) right center no-repeat;
]]><![CDATA[}
]]></screen><note>
<title>String matching on attributes is a CSS3 feature!</title>
<para>
To be able to use string matching on attributes, as we have done in the QBullets examples above, the user must view our document with a browser that supports this CSS3 feature. If you are wondering whether  your browser belongs to this cutting edge category (Mozilla 1.5 does, tip, tip <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject>), you can do this <ulink url="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/index.html">W3C browser test on CSS selectors</ulink> and test for "Substring matching attribute selector".
</para>
</note>
<para>To get an icon <indexterm><primary>icon</primary></indexterm>in place of the usual bullet <indexterm><primary>bullet</primary></indexterm>in itemized <indexterm><primary>itemized</primary></indexterm>lists, the list-style<indexterm><primary>list-style</primary></indexterm> property is used for the UL <indexterm><primary>UL</primary></indexterm>tag:</para><screen><![CDATA[UL {
]]><![CDATA[        margin-bottom: 10px;
]]><![CDATA[        list-style: url(images/tux-bullet.png) square;
]]><![CDATA[    }
]]></screen><para>Last but not least, a cross-browser <indexterm><primary>cross-browser</primary></indexterm>relative font setting can be achieved with </para><screen><![CDATA[P {
]]><![CDATA[        font-size: 12px;
]]><![CDATA[}
]]><![CDATA[/*/*/A{}
]]><![CDATA[BODY P {
]]><![CDATA[        font-size: x-small;
]]><![CDATA[        voice-family: "\"}\"";
]]><![CDATA[        voice-family: inherit;
]]><![CDATA[        font-size: small;
]]><![CDATA[}
]]><![CDATA[HTML>BODY P {
]]><![CDATA[        font-size: small;
]]><![CDATA[}
]]><![CDATA[/* */
]]></screen><para>which is indeed too complicated to explain here in all its depth. See <ulink url="http://diveintoaccessibility.org/day_26_using_relative_font_sizes.html">Dive into Accessibility, day 26</ulink> for this.</para></sect2>
<sect2 id="explain-appendix"><title>Appendix</title><para>As already noted in <xref linkend="LyX-Appendix">, we can't include the Appendix in the main document,<indexterm><primary>document</primary></indexterm> even if we mark <indexterm><primary>mark</primary></indexterm>it as an appendix <indexterm><primary>appendix</primary></indexterm>with LyX' aproppriate check box in the Layout -&gt; &ldquo;Start Appendix here&rdquo; menu item. We must include an extra LyX <indexterm><primary>LyX</primary></indexterm>document of DocBook <indexterm><primary>DocBook</primary></indexterm>article type that is marked as an Appendix itself and contains our Appendix.</para><para>If such a file with the name appendix.<indexterm><primary>appendix</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>exists, <ulink url="lyxtox">lyxtox</ulink> will take a series of actions to incorporate it into the final SGML <indexterm><primary>SGML</primary></indexterm>document automatically:<indexterm><primary>automatically</primary></indexterm></para><itemizedlist><listitem><para>The appendix.<indexterm><primary>appendix</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>file is exported to SGML:<indexterm><primary>SGML</primary></indexterm></para><screen><![CDATA[# Export the Appendix to DocBook SGML.
]]><![CDATA[if test -e appendix.lyx; then
]]><![CDATA[  $LYX -e docbook appendix.lyx
]]><![CDATA[fi
]]></screen></listitem><listitem><para>A series of SGML <indexterm><primary>SGML</primary></indexterm>code corrections take place through successive runs of 3 sed scripts:</para><screen><![CDATA[if test -e appendix.lyx; then
]]><![CDATA[  $RUNSED $SEDSCRABI  $1.sgml
]]><![CDATA[  $RUNSED $SEDSCR appendix.sgml
]]><![CDATA[  $RUNSED $SEDSCRAPP appendix.sgml
]]><![CDATA[fi
]]></screen><orderedlist><listitem><para>With the <ulink url="sedscr&amp;lowbar;abi">sedscr_abi</ulink> sed script, the ending tags &lt;/book&gt; or &lt;/article&gt; are substituted with SGML <indexterm><primary>SGML</primary></indexterm>code that inserts the SGML <indexterm><primary>SGML</primary></indexterm>entities of the Appendix, Bibliography and Index as defined in the Preample <indexterm><primary>Preample</primary></indexterm>(see <xref linkend="preample">). For example, the following sed commands from sedscr_abi:<indexterm><primary>sedscr_abi</primary></indexterm></para><screen><![CDATA[/<\/book>/s/<\/book>/\
]]><![CDATA[\&appendix;\
]]><![CDATA[\&bibliography;\
]]><![CDATA[\&index;\
]]><![CDATA[<\/book>/
]]></screen><para>will substitute</para><screen><![CDATA[
&appendix;
&bibliography;
&index;
</book>
]]><![CDATA[with
]]><![CDATA[&appendix;
]]><![CDATA[&bibliography;
]]><![CDATA[&index;
]]><![CDATA[
&appendix;
&bibliography;
&index;
</book>
]]></screen><para>Note that the inserted lines before the closing &lt;/book&gt; tag contain SGML<indexterm><primary>SGML</primary></indexterm> entities <indexterm><primary>entities</primary></indexterm>that were defined as SYSTEM files with the names appendix.<indexterm><primary>appendix</primary></indexterm>sgml, bibliography.<indexterm><primary>bibliography</primary></indexterm>sgml and index.sgml respectively in the Preample <indexterm><primary>Preample</primary></indexterm>(see <xref linkend="preample">). Similar sed commands in sedscr_abi <indexterm><primary>sedscr_abi</primary></indexterm>will do the same for the closing &lt;/article&gt; tag.</para></listitem><listitem><para>The <ulink url="sedscr">sedscr</ulink> sed script will correct the SGML <indexterm><primary>SGML</primary></indexterm>code of appendix.<indexterm><primary>appendix</primary></indexterm>sgml, as it will do for the main document.<indexterm><primary>document</primary></indexterm> See <xref linkend="explain-runsed-sed-sedscr"> for an explanation of its inner workings.</para></listitem><listitem><para>Finally, the <ulink url="sedscr&amp;lowbar;app">sedscr_app</ulink> sed script will replace the first line of appendix.<indexterm><primary>appendix</primary></indexterm>sgml and its subsequent 3 lines with the correct SGML <indexterm><primary>SGML</primary></indexterm>incantation for an Appendix:</para><screen><![CDATA[<appendix label="A"><title>Appendix</title>
]]></screen><para>It also replaces the closing &lt;/article&gt; tag (remember that we created the appendix.<indexterm><primary>appendix</primary></indexterm> lyx <indexterm><primary>lyx</primary></indexterm>file as a document <indexterm><primary>document</primary></indexterm>of type &quot;DocBook article (SGML)&quot;, see <xref linkend="LyX-Appendix">) with the right &lt;/appendix&gt; one.</para></listitem></orderedlist></listitem><listitem><para>If Mathematics <indexterm><primary>Mathematics</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>is ON (with the variable $process_math set to 1 at the start of <ulink url="lyxtox">lyxtox</ulink>), the appendix.<indexterm><primary>appendix</primary></indexterm>sgml file is undergone the same transformations as the main document <indexterm><primary>document</primary></indexterm>using the awkscr_math <indexterm><primary>awkscr_math</primary></indexterm>awk script (explained in <xref linkend="magic-behind-the-math">):</para><screen><![CDATA[  $AWK -f $AWKSCRMATH appendix.sgml > appendix.awk.sgml
]]><![CDATA[  mv appendix.awk.sgml appendix.sgml
]]></screen></listitem><listitem><para>Openjade <indexterm><primary>Openjade</primary></indexterm>(<xref linkend="openjade-pdftex-jadetex">), called by the <ulink url="lyxtox">lyxtox</ulink> script, will process both the main document <indexterm><primary>document</primary></indexterm>and appendix.<indexterm><primary>appendix</primary></indexterm>sgml and will insert the contents of the latter in place of the appendix<indexterm><primary>appendix</primary></indexterm> SGML <indexterm><primary>SGML</primary></indexterm>entity that was inserted by <ulink url="sedscr&amp;lowbar;abi">sedscr_abi</ulink> above.</para></listitem></itemizedlist></sect2>
<sect2 id="explain-bibliography"><title>Bibliography</title><para>To create a bibliography <indexterm><primary>bibliography</primary></indexterm>section, LyX <indexterm><primary>LyX</primary></indexterm>offers two possibilities: one using the citation <indexterm><primary>citation</primary></indexterm>keys of your free choice and one using keys of bibliographic<indexterm><primary>bibliographic</primary></indexterm> entries in a BibTeX <indexterm><primary>BibTeX</primary></indexterm>database. Neither of them produces SGML <indexterm><primary>SGML</primary></indexterm>code when the document <indexterm><primary>document</primary></indexterm>is exported to SGML, so we have to search for other methods. Before I explain the RefDB <indexterm><primary>RefDB</primary></indexterm>method, which suits our purposes perfectly, I will first decribe both standard methods to give you an idea of the classic bibliography <indexterm><primary>bibliography</primary></indexterm>creation process in a TeX/LaTeX system with LyX.<indexterm><primary>LyX</primary></indexterm> You can read more about them in the LyX <indexterm><primary>LyX</primary></indexterm>User's Guide and Extended Features Guide respective, both accessible from LyX' Help menu.</para><sect3 id="explain-standard-Bibliography-methods"><title>Standard Bibliography methods in LyX</title><para>Both standard methods have in common that they make use of the Bibliography environment <indexterm><primary>environment</primary></indexterm>(<xref linkend="LyX-environments">) to list references. When you first open a Bibliography environment,<indexterm><primary>environment</primary></indexterm> LyX <indexterm><primary>LyX</primary></indexterm>adds a large vertical <indexterm><primary>vertical</primary></indexterm>space, followed by the heading &ldquo;Bibliography&rdquo; or &ldquo;References,&rdquo; depending on the document <indexterm><primary>document</primary></indexterm>class.<indexterm><primary>class</primary></indexterm> The heading is in a large boldface font. Each paragraph <indexterm><primary>paragraph</primary></indexterm>of the Bibliography environment <indexterm><primary>environment</primary></indexterm>is a bibliography <indexterm><primary>bibliography</primary></indexterm>entry. </para><para>At the <emphasis>beginning</emphasis> of the <emphasis>first line</emphasis> of each paragraph,<indexterm><primary>paragraph</primary></indexterm> you will see a grayish box showing a number. If you click on it, you will get a dialog in which you can set a key and a label. The key is the symbolic <indexterm><primary>symbolic</primary></indexterm>name by which you will refer to this bibliography<indexterm><primary>bibliography</primary></indexterm> entry. For example, suppose your first entry in the bibliography <indexterm><primary>bibliography</primary></indexterm>was a book about <application>LaTeX</application>.<indexterm><primary>LaTeX</primary></indexterm> We could choose the key &ldquo;latexguide&rdquo; for that entry. You can also give a label,<indexterm><primary>label</primary></indexterm> which will be displayed in the gray inset box.</para><para>The key field isn't useless. You can refer to your bibliography <indexterm><primary>bibliography</primary></indexterm>entries using the Insert-&gt;Citation&nbsp;Reference command. Just choose the key inside in the panel Bibliography&nbsp;keys, then transfer it to the Inset&nbsp;Keys panel with the left arrow. Multiple references can be placed by selecting more than one key. This is the first standard way of creating a bibliography <indexterm><primary>bibliography</primary></indexterm>in LyX.<indexterm><primary>LyX</primary></indexterm></para><para>The second standard way of creating a bibliography <indexterm><primary>bibliography</primary></indexterm>with LyX <indexterm><primary>LyX</primary></indexterm>uses BibTeX.<indexterm><primary>BibTeX</primary></indexterm> BibTeX <indexterm><primary>BibTeX</primary></indexterm>is, it is a system for creating a large database <indexterm><primary>database</primary></indexterm>of your most used journal references. For all future articles you write, you only need to include this standard database <indexterm><primary>database</primary></indexterm>and reference the appropriate key to each reference. </para><para>To use BibTeX <indexterm><primary>BibTeX</primary></indexterm>for inserting references in your document,<indexterm><primary>document</primary></indexterm> proceed as follows: at the very end of your document,<indexterm><primary>document</primary></indexterm> select Insert-&gt;Lists &amp; TOC-&gt;BibTeX Reference. In the resulting dialog, fill out the dialog boxes <indexterm><primary>boxes</primary></indexterm>as follows: </para><variablelist><varlistentry><term>Database:
</term><listitem><para>enter the name of your <indexterm><primary>typewriter</primary></indexterm>.bib file *without* the <indexterm><primary>typewriter</primary></indexterm>.bib extension.<indexterm><primary>extension</primary></indexterm> For searching multiple <indexterm><primary>typewriter</primary></indexterm>.bib files, just enter them in the desired order, separated by commas. </para></listitem></varlistentry><varlistentry><term>Style:
</term><listitem><para>enter the name of your BibTeX <indexterm><primary>BibTeX</primary></indexterm>style file *without* the <indexterm><primary>typewriter</primary></indexterm>.bst extension.<indexterm><primary>extension</primary></indexterm> The default style is <indexterm><primary>typewriter</primary></indexterm>plain (which should be included in your <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>distribution,<indexterm><primary>distribution</primary></indexterm> so you don't have to worry about creating it).</para></listitem></varlistentry></variablelist><para>For each citation,<indexterm><primary>citation</primary></indexterm> assuming that the source is in the <indexterm><primary>typewriter</primary></indexterm>.bib file, just call Insert-&gt;Citation Reference at the correct location in the text, and enter the appropriate reference key. </para></sect3>
<sect3 id="explain-RefDB"><title>The RefDB method</title><para>The problem with both methods is that they don't &ldquo;speak&rdquo; SGML.<indexterm><primary>SGML</primary></indexterm> Of course, you can use BibTeX <indexterm><primary>BibTeX</primary></indexterm>to create a DVI <indexterm><primary>DVI</primary></indexterm>document containing citations<indexterm><primary>citations</primary></indexterm> and bibliography <indexterm><primary>bibliography</primary></indexterm>and from there take the route to PS <indexterm><primary>PS</primary></indexterm>and PDF,<indexterm><primary>PDF</primary></indexterm> or even to HTML <indexterm><primary>HTML</primary></indexterm>through a tool like LaTeX2HTML,<indexterm><primary>LaTeX2HTML</primary></indexterm> but this is not the route we want to take. We want to take the route through SGML <indexterm><primary>SGML</primary></indexterm>- and that's where both methods fail to follow us.</para><para>The general principle of the RefDB <indexterm><primary>RefDB</primary></indexterm>method is straightforward: each citation<indexterm><primary>citation</primary></indexterm> that you want to be treated as a RefDB <indexterm><primary>RefDB</primary></indexterm>citation needs to have a role attribute<indexterm><primary>attribute</primary></indexterm> with the value &quot;REFDB&quot;. Each citation <indexterm><primary>citation</primary></indexterm>defines at least one xref <indexterm><primary>xref</primary></indexterm>element.<indexterm><primary>element</primary></indexterm> The value of the linkend attribute <indexterm><primary>attribute</primary></indexterm>encodes the <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>of the required reference in the database <indexterm><primary>database</primary></indexterm>(if you need references in several databases, this attribute<indexterm><primary>attribute</primary></indexterm> can additionally specify the database). RefDB <indexterm><primary>RefDB</primary></indexterm>uses this information to generate a DocBook <indexterm><primary>DocBook</primary></indexterm>bibliography <indexterm><primary>bibliography</primary></indexterm>element.<indexterm><primary>element</primary></indexterm> This contains an entry for each requested reference. These entries are labelled with <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>attributes that match the xref <indexterm><primary>xref</primary></indexterm>linkend attributes <indexterm><primary>attributes</primary></indexterm>in the text. Each RefDB-generated reference entry defines a xreflabel <indexterm><primary>xreflabel</primary></indexterm>attribute <indexterm><primary>attribute</primary></indexterm>which holds the text that is to be displayed at the position of the corresponding xref <indexterm><primary>xref</primary></indexterm>elements.</para><para>This is all it takes for single and unique citations,<indexterm><primary>citations</primary></indexterm> i.e. with one xref <indexterm><primary>xref</primary></indexterm>element <indexterm><primary>element</primary></indexterm>per citation <indexterm><primary>citation</primary></indexterm>element <indexterm><primary>element</primary></indexterm>and only one occurrence throughout the text. Both multiple occurrences of the same citation <indexterm><primary>citation</primary></indexterm>in the text and multiple citations <indexterm><primary>citations</primary></indexterm>(more than one xref <indexterm><primary>xref</primary></indexterm>elements per citation <indexterm><primary>citation</primary></indexterm>element) make things a bit more difficult.</para><para>Some output formats require a different formatting <indexterm><primary>formatting</primary></indexterm>for the first citation<indexterm><primary>citation</primary></indexterm> of a publication <indexterm><primary>publication</primary></indexterm>in the text and all subsequent citations <indexterm><primary>citations</primary></indexterm>of the same publication. The first citation <indexterm><primary>citation</primary></indexterm>is identical with the above mentioned default case. All following citations <indexterm><primary>citations</primary></indexterm>of the same publication <indexterm><primary>publication</primary></indexterm>need an additional xref<indexterm><primary>xref</primary></indexterm> endterm attribute <indexterm><primary>attribute</primary></indexterm>which points to an additional bibliomset <indexterm><primary>bibliomset</primary></indexterm>element <indexterm><primary>element</primary></indexterm>which in turn contains the text to be displayed for subsequent citations.<indexterm><primary>citations</primary></indexterm> The endterm attribute <indexterm><primary>attribute</primary></indexterm>has the same value as the linkend attribute <indexterm><primary>attribute</primary></indexterm>except that the letter &quot;S&quot; (as in subsequent) is appended to the attribute.<indexterm><primary>attribute</primary></indexterm> See <ulink url="http://refdb.sourceforge.net/manual-0.9.4/x9223.html">Processing expectations for the refdb DocBook bibliography output</ulink>.</para><para>Compare the way you would use BibTeX <indexterm><primary>BibTeX</primary></indexterm>with <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>(and LyX) to the way you use RefDB <indexterm><primary>RefDB</primary></indexterm>
<citation role="REFDB"><xref linkend="IDHOENICKA0S"></citation>
 to produce a Bibliography (see <ulink url="http://www.dpawson.co.uk/docbook/tools.html">RefDB and BibTeX comparison</ulink>):</para><para>With the BibTeX <indexterm><primary>BibTeX</primary></indexterm>method, you proceed as follows:</para><itemizedlist><listitem><para>You enter your <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>references into a flat-file <indexterm><primary>flat-file</primary></indexterm>database in the BibTeX<indexterm><primary>BibTeX</primary></indexterm> format.</para></listitem><listitem><para>You use style files in the powerful but somewhat cryptic BibTeX <indexterm><primary>BibTeX</primary></indexterm>format for your <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>documents.</para></listitem><listitem><para>In a <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>document, you specify with the \bibliography command which external bibliography <indexterm><primary>bibliography</primary></indexterm>file to use. You specify with \cite commands which references you want to cite <indexterm><primary>cite</primary></indexterm>(and appear in your bibliography<indexterm><primary>bibliography</primary></indexterm>). LyX <indexterm><primary>LyX</primary></indexterm>does this automatically <indexterm><primary>automatically</primary></indexterm>for you.</para></listitem><listitem><para>You run latex <indexterm><primary>latex</primary></indexterm>on your <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>document. This will create an .aux file which contains (among other stuff) a list of all citations.<indexterm><primary>citations</primary></indexterm></para></listitem><listitem><para>Then you run bibtex <indexterm><primary>bibtex</primary></indexterm>on your <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>document. This will use the bibliography <indexterm><primary>bibliography</primary></indexterm>style you specified in the document <indexterm><primary>document</primary></indexterm>and will create a cooked bibliography <indexterm><primary>bibliography</primary></indexterm>in a .bbl file.</para></listitem><listitem><para>Finally you run latex <indexterm><primary>latex</primary></indexterm>once or twice again to finalize your document.<indexterm><primary>document</primary></indexterm></para></listitem></itemizedlist><para>With the RefDB <indexterm><primary>RefDB</primary></indexterm>method, you proceed as follows:</para><itemizedlist><listitem><para>You enter your references for a SGML <indexterm><primary>SGML</primary></indexterm>or XML document <indexterm><primary>document</primary></indexterm>into a SQL <indexterm><primary>SQL</primary></indexterm>database. Input can be either RIS,<indexterm><primary>RIS</primary></indexterm> DocBook,<indexterm><primary>DocBook</primary></indexterm> or BibTeX.<indexterm><primary>BibTeX</primary></indexterm> As RefDB <indexterm><primary>RefDB</primary></indexterm>is Unix-style, you can write other import filters <indexterm><primary>filters</primary></indexterm>in any language that can send output to either stdout or to a file. Using a SQL <indexterm><primary>SQL</primary></indexterm>database means better scalability <indexterm><primary>scalability</primary></indexterm>for large collections <indexterm><primary>collections</primary></indexterm>and added benefit if you share your data with colleagues (think workgroups,<indexterm><primary>workgroups</primary></indexterm> departments, access control...)</para></listitem><listitem><para>You specify the bibliography <indexterm><primary>bibliography</primary></indexterm>and citation <indexterm><primary>citation</primary></indexterm>styles for SGML <indexterm><primary>SGML</primary></indexterm>and XML documents in XML files which are essentially templates for the sequence and appearance of bibliography <indexterm><primary>bibliography</primary></indexterm>and citation <indexterm><primary>citation</primary></indexterm>elements. These are also loaded into a database.<indexterm><primary>database</primary></indexterm> This means they are pre-parsed,<indexterm><primary>pre-parsed</primary></indexterm> which speeds up the formatting <indexterm><primary>formatting</primary></indexterm>of bibliographies.<indexterm><primary>bibliographies</primary></indexterm></para></listitem><listitem><para>In an SGML <indexterm><primary>SGML</primary></indexterm>or XML document,<indexterm><primary>document</primary></indexterm> you specify an external entity <indexterm><primary>entity</primary></indexterm>with the name of the SMGL <indexterm><primary>SMGL</primary></indexterm>or XML file that will contain your bibliography.<indexterm><primary>bibliography</primary></indexterm> In DocBook <indexterm><primary>DocBook</primary></indexterm>documents you specify with &lt;citation&gt;&lt;xref..&gt;&lt;/citation&gt; constructs which references you want to cite.<indexterm><primary>cite</primary></indexterm> Parenthetical and textual citations <indexterm><primary>citations</primary></indexterm>are supported.</para></listitem><listitem><para>RefDB <indexterm><primary>RefDB</primary></indexterm>uses a DSSSL <indexterm><primary>DSSSL</primary></indexterm>script to extract a list of all citations <indexterm><primary>citations</primary></indexterm>from SGML <indexterm><primary>SGML</primary></indexterm>or XML documents into an XML document <indexterm><primary>document</primary></indexterm>(which you can edit to add other, not cited references)</para></listitem><listitem><para>Then you run a RefDB <indexterm><primary>RefDB</primary></indexterm>tool on your SGML <indexterm><primary>SGML</primary></indexterm>or XML document.<indexterm><primary>document</primary></indexterm> This will use the bibliography <indexterm><primary>bibliography</primary></indexterm>style you specified on the command line and will create a cooked bibliography <indexterm><primary>bibliography</primary></indexterm>in a SGML <indexterm><primary>SGML</primary></indexterm>or XML file. It will also create a small stylesheet <indexterm><primary>stylesheet</primary></indexterm>driver file specific for your bibliography style.</para></listitem><listitem><para>Finally you run Jade <indexterm><primary>Jade</primary></indexterm>or an XSLT processor on your document <indexterm><primary>document</primary></indexterm>to transform it to the final output. This step uses the RefDB-created <indexterm><primary>RefDB-created</primary></indexterm>driver files to format the RefDB <indexterm><primary>RefDB</primary></indexterm>bibliographies (leaving alone potential other bibliographies) and the RefDB <indexterm><primary>RefDB</primary></indexterm>citations (leaving alone potential other citations). The stylesheet <indexterm><primary>stylesheet</primary></indexterm>driver files essentially take care of character properties like font weight, posture etc. for various parts of the citation <indexterm><primary>citation</primary></indexterm>or bibliography.<indexterm><primary>bibliography</primary></indexterm> The citations <indexterm><primary>citations</primary></indexterm>are neatly hyperlinked <indexterm><primary>hyperlinked</primary></indexterm>with the references in the bibliography<indexterm><primary>bibliography</primary></indexterm> in all output formats that support this.</para></listitem></itemizedlist><note>
<title>
Your sources remain intact!
</title>
<para>
Please note that neither BibTeX nor RefDB do any "search-and-replace"-style mangling of your sources. The cooked bibliography is kept in an external file in both cases. This way it is easy to reformat your document for a different bibliography style without touching the document source. And the whole thing works for DocBook, TEI, and any other reasonable DTD (with a little stylesheet tweaking, that is).
</para>
</note>
<para>Let's see how <ulink url="lyxtox">lyxtox</ulink> handles all this complexity <indexterm><primary>complexity</primary></indexterm>in the background <indexterm><primary>background</primary></indexterm>for you:</para><para>When <ulink url="sedscr">sedscr</ulink> is run through <ulink url="runsed">runsed</ulink> from <ulink url="lyxtox">lyxtox</ulink>:</para><screen><![CDATA[$RUNSED $SEDSCR $1.sgml
]]></screen><para>it makes a lot of changes to the SGML <indexterm><primary>SGML</primary></indexterm>file $1.sgml that was previously exported by LyX <indexterm><primary>LyX</primary></indexterm>(see <xref linkend="explain-runsed-sed-sedscr"> for an in-depth description of them). The following code in <ulink url="sedscr">sedscr</ulink> takes care of citations <indexterm><primary>citations</primary></indexterm>that were entered as described in <xref linkend="LyX-Bibliography-with-RefDB">:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1021;" format="linespecific"><![CDATA[
]]></screen><para>This sed code will substitute every <emphasis>cross-reference</emphasis> to a label <indexterm><primary>label</primary></indexterm>of the form &ldquo;cit:IDsome&rdquo; with a <emphasis>citation</emphasis> of the form:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1022;" format="linespecific"><![CDATA[
]]></screen><para>in the exported SGML <indexterm><primary>SGML</primary></indexterm>file. Then, <ulink url="lyxtox">lyxtox</ulink> will call refdbxp:<indexterm><primary>refdbxp</primary></indexterm></para><screen><![CDATA[$REFDBXP -t db31 < $1.sgml > $1.full.sgml
]]><![CDATA[mv $1.full.sgml $1.sgml
]]></screen><para>to transform all citations <indexterm><primary>citations</primary></indexterm>of the above form to one of the form:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1023;" format="linespecific"><![CDATA[
]]></screen><para>But how are the citations <indexterm><primary>citations</primary></indexterm>and references going to be <emphasis>formatted</emphasis>? We need special DSSSL <indexterm><primary>DSSSL</primary></indexterm>instructions for those parts of our document! Fortunately, RefDB <indexterm><primary>RefDB</primary></indexterm>provides us with the aproppriate stylesheet.<indexterm><primary>stylesheet</primary></indexterm> It is generated dynamically each time, using as input the style name we entered in <ulink url="lyxtox">lyxtox</ulink> as the value of the REFDB_style <indexterm><primary>REFDB_style</primary></indexterm>variable (see <xref linkend="bibliographic-database">), with a call to runbib <indexterm><primary>runbib</primary></indexterm>from <ulink url="lyxtox">lyxtox</ulink>:</para><screen><![CDATA[$RUNBIB -d $RefDB_db -S $REFDB_style -t db31 $1.sgml
]]></screen><para>This will produce the stylesheet <indexterm><primary>stylesheet</primary></indexterm>${REFDB_style}dsl (notice the absence of a dot before the dsl ending). For example, if REFDB_style <indexterm><primary>REFDB_style</primary></indexterm>is &ldquo;J.Biol.Chem.&rdquo;, then the above call to runbib <indexterm><primary>runbib</primary></indexterm>will create J.Biol.Chem.dsl.<indexterm><primary>J.Biol.Chem.dsl</primary></indexterm> </para><para>J.Biol.Chem.dsl <indexterm><primary>J.Biol.Chem.dsl</primary></indexterm>looks like this:</para><screen><![CDATA[<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
]]><![CDATA[<!ENTITY docbook-refdb-html.dsl PUBLIC "-//Markus Hoenicka//DOCUMENT 
]]><![CDATA[RefDB DocBook html stylesheet//EN" CDATA DSSSL>
]]><![CDATA[<!ENTITY docbook-refdb-print.dsl PUBLIC "-//Markus Hoenicka//DOCUMENT 
]]><![CDATA[RefDB DocBook print stylesheet//EN" CDATA DSSSL>
]]><![CDATA[]>
]]><![CDATA[<style-sheet>
]]><![CDATA[<style-specification id="html" use="docbook-refdb-html">
]]><![CDATA[<style-specification-body>
]]><![CDATA[(define ABSTJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define ABSTVOLUMESTYLE "BOLD")
]]><![CDATA[(define CHAPBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define BOOKBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define INPRJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURVOLUMESTYLE "BOLD")
]]><![CDATA[(define NEWSJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define NEWSVOLUMESTYLE "BOLD")
]]><![CDATA[</style-specification-body>
]]><![CDATA[</style-specification>
]]><![CDATA[<style-specification id="print" use="docbook-refdb-print">
]]><![CDATA[<style-specification-body>
]]><![CDATA[(define ABSTJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define ABSTVOLUMESTYLE "BOLD")
]]><![CDATA[(define CHAPBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define BOOKBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define INPRJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURVOLUMESTYLE "BOLD")
]]><![CDATA[(define NEWSJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define NEWSVOLUMESTYLE "BOLD")
]]><![CDATA[</style-specification-body>
]]><![CDATA[</style-specification>
]]><![CDATA[<external-specification id="docbook-refdb-html" document="docbook-refdb-html.dsl">
]]><![CDATA[<external-specification id="docbook-refdb-print" document="docbook-refdb-print.dsl">
]]><![CDATA[</style-sheet>
]]></screen><para>This means the following:</para><para>For online output (id=&rdquo;html&rdquo;), take those define's into account and then proceed to use the part of the stylesheets with <acronym>ID</acronym> <indexterm><primary>ID</primary></indexterm>&ldquo;docbook-refdb-html&rdquo; (use=&rdquo;docbook-refdb-html&rdquo;). Openjade <indexterm><primary>Openjade</primary></indexterm>will look at the external specification <indexterm><primary>specification</primary></indexterm>with id &ldquo;docbook-refdb-html&rdquo; at the end:</para><screen><![CDATA[<external-specification id="docbook-refdb-html" document="docbook-refdb-html.dsl">
]]></screen><para>and will see that is is the document <indexterm><primary>document</primary></indexterm>whose name is the &quot;docbook-refdb-html.dsl&quot; SGML <indexterm><primary>SGML</primary></indexterm>entity (document=&quot;docbook-refdb-html.dsl&quot;). It will then consult the entity <indexterm><primary>entity</primary></indexterm>declarations at the start of the stylesheet:<indexterm><primary>stylesheet</primary></indexterm></para><screen><![CDATA[<!ENTITY docbook-refdb-html.dsl PUBLIC "-//Markus Hoenicka//DOCUMENT 
]]><![CDATA[RefDB DocBook html stylesheet//EN" CDATA DSSSL>
]]></screen><para>and find out that the docbook-refdb-html.<indexterm><primary>docbook-refdb-html</primary></indexterm>dsl entity <indexterm><primary>entity</primary></indexterm>is the one with the public identifier <indexterm><primary>identifier</primary></indexterm>&quot;-//Markus Hoenicka//DOCUMENT RefDB <indexterm><primary>RefDB</primary></indexterm>DocBook html stylesheet//EN&quot;, it will search the catalog <indexterm><primary>catalog</primary></indexterm>files (see <xref linkend="catalog-paths">) and, since the <ulink url="lyxtox">lyxtox</ulink> script stores the RefDB <indexterm><primary>RefDB</primary></indexterm>catalog file in its SGML_CATALOG_FILES <indexterm><primary>SGML_CATALOG_FILES</primary></indexterm>variable:</para><screen><![CDATA[SGML_CATALOG_FILES="$SGML_CATALOG_FILES:/usr/share/refdb/refdb.cat"
]]></screen><para>openjade <indexterm><primary>openjade</primary></indexterm>will finally be able to locate the document <indexterm><primary>document</primary></indexterm>containing the rest of the DSSSL <indexterm><primary>DSSSL</primary></indexterm>instructions necessary for processing <indexterm><primary>processing</primary></indexterm>the Bibliography. It turns out that, on my system, this is the /usr/share/refdb/dsssl/html/docbook-refdb.dsl, but this depends on how you compiled RefDB <indexterm><primary>RefDB</primary></indexterm>- on the value of the --prefix option precisely. The same procedure <indexterm><primary>procedure</primary></indexterm>is followed for the print output (the id=&rdquo;print&rdquo; part).</para><para>But wait a minute! That /usr/share/refdb/dsssl/html/docbook-refdb.dsl, does it contain any special code for Mathematics,<indexterm><primary>Mathematics</primary></indexterm> like the one in <xref linkend="explain-math-processing-in-HTML-stylesheets">? No. Does it contain any of the other special DSSSL <indexterm><primary>DSSSL</primary></indexterm>processing as described in <xref linkend="explain-DSSSL-stylesheets">? Again, no. It is a &ldquo;driver&rdquo; file containing only the RefDB-specific <indexterm><primary>RefDB-specific</primary></indexterm>DSSSL <indexterm><primary>DSSSL</primary></indexterm>instructions - for the rest, it jumps directly to the standard DocBook <indexterm><primary>DocBook</primary></indexterm>stylesheets of Norman Walsh,<indexterm><primary>Walsh</primary></indexterm> through the use=&rdquo;docbook&rdquo; attribute,<indexterm><primary>attribute</primary></indexterm> just as our J.Biol.Chem.dsl <indexterm><primary>J.Biol.Chem.dsl</primary></indexterm>jumps to /usr/share/refdb/dsssl/html/docbook-refdb.dsl through the use=&quot;docbook-refdb-html&quot; attribute.<indexterm><primary>attribute</primary></indexterm></para><para>Of course, you can tweak <indexterm><primary>tweak</primary></indexterm>the /usr/share/refdb/dsssl/html/docbook-refdb.dsl to include both the Mathematics <indexterm><primary>Mathematics</primary></indexterm>(DBTeXMath) and all the other specific code, but this is not acceptable. Clearly, we need an automatic solution.</para><para>Fortnunately, there is one: use the ${REFDB_style}dsl stylesheet <indexterm><primary>stylesheet</primary></indexterm>that RefDB<indexterm><primary>RefDB</primary></indexterm> created automatically <indexterm><primary>automatically</primary></indexterm>for us, to create two new DSSSL <indexterm><primary>DSSSL</primary></indexterm>driver files, one for HTML <indexterm><primary>HTML</primary></indexterm>and one for print output. these stylesheets will take care to jump first to our other DSSSL <indexterm><primary>DSSSL</primary></indexterm>files - the latter ones will then jump to the standard DocBook <indexterm><primary>DocBook</primary></indexterm>stylesheets.</para><para>To implement this solution, two new scripts are necessary, <ulink url="awkscr_refdb_html">awkscr_refdb_html</ulink> and <ulink url="awkscr_refdb_print">awkscr_refdb_print</ulink>. The <ulink url="lyxtox">lyxtox</ulink> script calls them as follows:</para><screen><![CDATA[  $AWKSCR_REFDB_HTML  ${REFDB_style}dsl > $HTML_DSL
]]><![CDATA[  $AWKSCR_REFDB_PRINT ${REFDB_style}dsl > $PRINT_DSL
]]></screen><para>Both take as input the newly created ${REFDB_style}dsl stylesheet <indexterm><primary>stylesheet</primary></indexterm>(J.Biol.Chem.dsl in our example) and produce a new HTML <indexterm><primary>HTML</primary></indexterm>and print DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet respectively. Here is the <ulink url="awkscr_refdb_html">awkscr_refdb_html</ulink> script :</para><screen><![CDATA[#! /bin/sh
]]><![CDATA[
]]><![CDATA[AWK="/usr/bin/awk"
]]><![CDATA[
]]><![CDATA[cat <<-EOF 
]]><![CDATA[<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
]]><![CDATA[<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML 
]]><![CDATA[Stylesheet//EN" CDATA DSSSL>
]]><![CDATA[<!ENTITY lyxtox-html.dsl SYSTEM "lyxtox-html.dsl" CDATA DSSSL>
]]><![CDATA[<!ENTITY lyxtox-onehtml.dsl SYSTEM "lyxtox-onehtml.dsl" CDATA DSSSL>
]]><![CDATA[]>
]]><![CDATA[<style-sheet>
]]><![CDATA[EOF
]]><![CDATA[
]]><![CDATA[for id in "html" "onehtml"; do
]]><![CDATA[  echo "<style-specification id=\"$id\" use=\"lyxtox-"$id"\">"
]]><![CDATA[  echo "<style-specification-body>"
]]><![CDATA[  $AWK '$1 ~ /<style-specification/ && $2 ~ "id=\"html\"",$1 ~ /<\/style-specification/ 
]]><![CDATA[  {if ($1 !~ /^</) {print}}' "id=$id" $1
]]><![CDATA[  echo "</style-specification-body>"
]]><![CDATA[  echo "</style-specification>"
]]><![CDATA[done
]]><![CDATA[
]]><![CDATA[cat <<-EOF 
]]><![CDATA[<external-specification id="lyxtox-html" document="lyxtox-html.dsl">
]]><![CDATA[<external-specification id="lyxtox-onehtml" document="lyxtox-onehtml.dsl">
]]><![CDATA[</style-sheet>
]]><![CDATA[EOF
]]></screen><para>This script</para><orderedlist><listitem><para>Prints the necessary entity <indexterm><primary>entity</primary></indexterm>declarations that have to come at the top of the new DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet.</para></listitem><listitem><para>For every HTML <indexterm><primary>HTML</primary></indexterm>id (there are currently two of them, &ldquo;html&rdquo; and &ldquo;onehtml&rdquo;), print as style specification <indexterm><primary>specification</primary></indexterm>containing all lines that do NOT start with &ldquo;&lt;&rdquo; in the style specification <indexterm><primary>specification</primary></indexterm>for the &ldquo;html&rdquo; id in the given file, i.e. the newly created ${REFDB_style}dsl stylesheet.<indexterm><primary>stylesheet</primary></indexterm> In our example, it prints every line not starting with &ldquo;&lt;&rdquo; in the following part of J.Biol.Chem.dsl <indexterm><primary>J.Biol.Chem.dsl</primary></indexterm>that comprises only the style specification for the id=&rdquo;html&rdquo; part:</para><screen><![CDATA[<style-specification id="html" use="docbook-refdb-html">
]]><![CDATA[<style-specification-body>
]]><![CDATA[(define ABSTJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define ABSTVOLUMESTYLE "BOLD")
]]><![CDATA[(define CHAPBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define BOOKBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define INPRJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURVOLUMESTYLE "BOLD")
]]><![CDATA[(define NEWSJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define NEWSVOLUMESTYLE "BOLD")
]]><![CDATA[</style-specification-body>
]]><![CDATA[</style-specification>
]]></screen><para>Obviously, the lines that do NOT start with a &ldquo;&lt;&rdquo; are those define's - and those are exactly the lines we are interested in, everything else will be replaced by our own code.</para></listitem><listitem><para>Prints aproppriate external specifications that point to our own stylesheets that contain the rest of our customization.<indexterm><primary>customization</primary></indexterm></para></listitem></orderedlist><para>The output looks like this (see also <ulink url="refdb-html.dsl">refdb-html.dsl</ulink>):</para><screen><![CDATA[<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
]]><![CDATA[<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML 
]]><![CDATA[Stylesheet//EN" CDATA DSSSL>
]]><![CDATA[<!ENTITY lyxtox-html.dsl SYSTEM "lyxtox-html.dsl" CDATA DSSSL>
]]><![CDATA[<!ENTITY lyxtox-onehtml.dsl SYSTEM "lyxtox-onehtml.dsl" CDATA DSSSL>
]]><![CDATA[]>
]]><![CDATA[<style-sheet>
]]><![CDATA[<style-specification id="html" use="lyxtox-html">
]]><![CDATA[<style-specification-body>
]]><![CDATA[(define ABSTJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define ABSTVOLUMESTYLE "BOLD")
]]><![CDATA[(define CHAPBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define BOOKBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define INPRJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURVOLUMESTYLE "BOLD")
]]><![CDATA[(define NEWSJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define NEWSVOLUMESTYLE "BOLD")
]]><![CDATA[</style-specification-body>
]]><![CDATA[</style-specification>
]]><![CDATA[<style-specification id="onehtml" use="lyxtox-onehtml">
]]><![CDATA[<style-specification-body>
]]><![CDATA[(define ABSTJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define ABSTVOLUMESTYLE "BOLD")
]]><![CDATA[(define CHAPBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define BOOKBOOKTITLESTYLE "ITALIC")
]]><![CDATA[(define INPRJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define JOURVOLUMESTYLE "BOLD")
]]><![CDATA[(define NEWSJOURNALNAMESTYLE "ITALIC")
]]><![CDATA[(define NEWSVOLUMESTYLE "BOLD")
]]><![CDATA[</style-specification-body>
]]><![CDATA[</style-specification>
]]><![CDATA[<external-specification id="lyxtox-html" document="lyxtox-html.dsl">
]]><![CDATA[<external-specification id="lyxtox-onehtml" document="lyxtox-onehtml.dsl">
]]><![CDATA[</style-sheet>
]]></screen><para>We then process our SGML <indexterm><primary>SGML</primary></indexterm>file with <emphasis>this</emphasis> stylesheets for HTML <indexterm><primary>HTML</primary></indexterm>output!</para><para>Let's examine for a moment what the new stylesheet <indexterm><primary>stylesheet</primary></indexterm>does:</para><orderedlist><listitem><para><ulink url="lyxtox">lyxtox</ulink> calls openjade <indexterm><primary>openjade</primary></indexterm>and tells it to use the &ldquo;html&rdquo; id of this stylesheet.<indexterm><primary>stylesheet</primary></indexterm> This is because, in case RefDB <indexterm><primary>RefDB</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>is on, the stylesheet <indexterm><primary>stylesheet</primary></indexterm>for HTML<indexterm><primary>HTML</primary></indexterm> chunked <indexterm><primary>chunked</primary></indexterm>output is defined by:</para><screen><![CDATA[  HTML_DSL="refdb-html.dsl"
]]><![CDATA[  HTML_CHUNKS_DSL="$HTML_DSL#html"
]]></screen><para>and HTML_DSL <indexterm><primary>HTML_DSL</primary></indexterm>is the name of the file created by awkscr_refdb_html <indexterm><primary>awkscr_refdb_html</primary></indexterm>above:</para><screen><![CDATA[$AWKSCR_REFDB_HTML  ${REFDB_style}dsl > $HTML_DSL
]]></screen><para>That &ldquo;#html&rdquo; is a special Jade/Openjade construct that tells it to start processing<indexterm><primary>processing</primary></indexterm> at id=&rdquo;html&rdquo; of the given stylesheet.<indexterm><primary>stylesheet</primary></indexterm></para></listitem></orderedlist><para>The new stylesheet <indexterm><primary>stylesheet</primary></indexterm>(which will bear the name refdb-html.dsl,<indexterm><primary>refdb-html.dsl</primary></indexterm> if HTML_DSL<indexterm><primary>HTML_DSL</primary></indexterm> is left to its default value) jumps to id &ldquo;lyxtox-html&rdquo; which, by the same reasoning as we saw for the original J.Biol.Chem.dsl <indexterm><primary>J.Biol.Chem.dsl</primary></indexterm>file previously, will be found in the <ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink> file that contains all our non-RefDB-specific <indexterm><primary>non-RefDB-specific</primary></indexterm>customization.<indexterm><primary>customization</primary></indexterm> <ulink url="lyxtox-html.dsl">lyxtox-html.dsl</ulink>, on the other hand, is constructed in such a way that it will call the standard DocBook <indexterm><primary>DocBook</primary></indexterm>stylesheets with a use=&rdquo;docbook&rdquo; attribute <indexterm><primary>attribute</primary></indexterm>- and the processing <indexterm><primary>processing</primary></indexterm>chain is closed!</para><para>Processing for print output is done similarly: awkscr_refdb_print <indexterm><primary>awkscr_refdb_print</primary></indexterm>creates a new print stylesheet <indexterm><primary>stylesheet</primary></indexterm>from ${REFDB_style}dsl, <ulink url="refdb-print.dsl">refdb-print.dsl</ulink>, then this new stylesheet <indexterm><primary>stylesheet</primary></indexterm>is called from <ulink url="lyxtox">lyxtox</ulink> with an id of &ldquo;print-pdf&rdquo;, &ldquo;print-ps&rdquo;, &ldquo;print-rtf&rdquo; or &ldquo;print-txt&rdquo; respectively for each one of the print formats:</para><screen><![CDATA[  PRINT_DSL="refdb-print.dsl"
]]><![CDATA[  PRINT_PDF_DSL="$PRINT_DSL#print-pdf"
]]><![CDATA[  PRINT_PS_DSL="$PRINT_DSL#print-ps"
]]><![CDATA[  PRINT_RTF_DSL="$PRINT_DSL#print-rtf"
]]><![CDATA[  PRINT_TXT_DSL="$PRINT_DSL#print-txt"
]]></screen><para>Just as its HTML <indexterm><primary>HTML</primary></indexterm>counterpart above, <ulink url="refdb-print.dsl">refdb-print.dsl</ulink> is constructed in such a way that it will call our <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink>, <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink> etc. stylesheets with use attributes <indexterm><primary>attributes</primary></indexterm>like use=&quot;lyxtox-print-pdf&quot;, use=&quot;lyxtox-print-ps&quot; etc. respectively. Those stylesheets, in turn, will jump to the standard DocBook <indexterm><primary>DocBook</primary></indexterm>stylesheets with a use=&rdquo;docbook&rdquo; attribute.<indexterm><primary>attribute</primary></indexterm></para><para>How does a typical RefDB <indexterm><primary>RefDB</primary></indexterm>bibliography look like? <ulink url="lyxtox">lyxtox</ulink> copies the $1.bib.sgml file (wher $1 is the argument passed to it) to the file with the fixed name bibliography.<indexterm><primary>bibliography</primary></indexterm>sgml:</para><screen><![CDATA[mv $1.bib.sgml bibliography.sgml
]]></screen><para>The &amp;bibliography; entity <indexterm><primary>entity</primary></indexterm>that <ulink url="sedscr_abi">sedscr_abi</ulink> appends to our SGML <indexterm><primary>SGML</primary></indexterm>file is mapped automatically <indexterm><primary>automatically</primary></indexterm>to bibliography.<indexterm><primary>bibliography</primary></indexterm>sgml through the line</para><screen><![CDATA[<!entity bibliography SYSTEM "bibliography.sgml">
]]></screen><para>in the preample <indexterm><primary>preample</primary></indexterm>of our document <indexterm><primary>document</primary></indexterm>(see <xref linkend="preample">). Thus, you only have to look at <ulink url="bibliography.sgml">bibliography.sgml</ulink> - a typical entry there looks like:</para><screen><![CDATA[<bibliomixed id="IDKARAKAS1992" role="BOOK">
]]><![CDATA[
]]><![CDATA[<bibliomset role="intext" id="IDKARAKAS1992X">
]]><![CDATA[    (<abbrev>11</abbrev>)
]]><![CDATA[</bibliomset>
]]><![CDATA[
]]><![CDATA[<bibliomset role="intextsq" id="IDKARAKAS1992S">
]]><![CDATA[    (<abbrev>11</abbrev>)
]]><![CDATA[</bibliomset>
]]><![CDATA[
]]><![CDATA[<bibliomset role="authoronly" id="IDKARAKAS1992A">
]]><![CDATA[    <bibliomset relation="author">
]]><![CDATA[        <surname>Karakas</surname>
]]><![CDATA[    </bibliomset>
]]><![CDATA[</bibliomset>
]]><![CDATA[
]]><![CDATA[<bibliomset role="authoronlysq" id="IDKARAKAS1992Q">
]]><![CDATA[    <bibliomset relation="author">
]]><![CDATA[        <surname>Karakas</surname>
]]><![CDATA[    </bibliomset>
]]><![CDATA[</bibliomset>
]]><![CDATA[
]]><![CDATA[<bibliomset role="yearonly" id="IDKARAKAS1992Y">
]]><![CDATA[    (<abbrev>11</abbrev>)
]]><![CDATA[</bibliomset>
]]><![CDATA[
]]><![CDATA[<bibliomset role="bibliography" id="IDKARAKAS1992B">
]]><![CDATA[    <abbrev>11. </abbrev>
]]><![CDATA[    <bibliomset relation="book">
]]><![CDATA[        <bibliomset relation="author">
]]><![CDATA[            <surname>Karakas</surname> 
]]><![CDATA[            <firstname>C.</firstname>
]]><![CDATA[        </bibliomset> 
]]><![CDATA[    </bibliomset>
]]><![CDATA[    <bibliomset relation="book">
]]><![CDATA[        (<pubdate role="primary">1999</pubdate>) 
]]><![CDATA[    </bibliomset>
]]><![CDATA[    <bibliomset relation="book">
]]><![CDATA[        <publishername>BoD GmbH, Norderstedt</publishername>  
]]><![CDATA[    </bibliomset>
]]><![CDATA[</bibliomset>
]]><![CDATA[
]]><![CDATA[</bibliomixed>
]]></screen><para>As you can see, it is based on <ulink url="http://www.docbook.org/tdg/en/html/bibliomixed.html">bibliomixed</ulink> and <ulink url="http://www.docbook.org/tdg/en/html/bibliomset.html">bibliomset</ulink> elements. The content of a bibliomixed <indexterm><primary>bibliomixed</primary></indexterm>element <indexterm><primary>element</primary></indexterm>includes all necessary punctuation<indexterm><primary>punctuation</primary></indexterm> for formatting <indexterm><primary>formatting</primary></indexterm>- we say that bibliomixed <indexterm><primary>bibliomixed</primary></indexterm>entries are &ldquo;cooked&rdquo;. The creator of RefDB,<indexterm><primary>RefDB</primary></indexterm> Markus Hoenicka, says the following about the role of bibliomixed <indexterm><primary>bibliomixed</primary></indexterm>elements in RefDB <indexterm><primary>RefDB</primary></indexterm>(see <ulink url="http://www.dpawson.co.uk/docbook/tools.html#d841e1062">Formatting DocBook bibliographies</ulink>):</para><blockquote><para>RefDB <indexterm><primary>RefDB</primary></indexterm>does use bibliomixed <indexterm><primary>bibliomixed</primary></indexterm>on purpose. I think the choice between raw and cooked is a compromise between philosophy<indexterm><primary>philosophy</primary></indexterm> and ease of implementation,<indexterm><primary>implementation</primary></indexterm> speed of execution etc. I see the main purpose of auto-generating <indexterm><primary>auto-generating</primary></indexterm>bibliographies not in creating beautiful and philosophically correct *source* documents, but to help users create correct *formatted* output. The intermediate bibliography <indexterm><primary>bibliography</primary></indexterm>element <indexterm><primary>element</primary></indexterm>is a means to achieve this. The DocBook <indexterm><primary>DocBook</primary></indexterm>DTD <indexterm><primary>DTD</primary></indexterm>explicitly defines the bibliomixed <indexterm><primary>bibliomixed</primary></indexterm>element <indexterm><primary>element</primary></indexterm>to create bibliographic output that would be too tedious or complicated to create on the stylesheet<indexterm><primary>stylesheet</primary></indexterm> level alone.</para></blockquote></sect3>
</sect2>
<sect2 id="explain-index"><title>Index </title><para>Before you can process your document,<indexterm><primary>document</primary></indexterm> you must make sure that index.sgml exists. This is a chicken and egg <indexterm><primary>egg</primary></indexterm>problem, but it can be solved with the collateindex.<indexterm><primary>collateindex</primary></indexterm>pl<indexterm><primary>collateindex.pl</primary></indexterm> command:</para><screen><![CDATA[perl collateindex.pl -N -o index.sgml 
]]></screen><para>or, as in <ulink url="lyxtox">lyxtox</ulink>:</para><screen><![CDATA[$PERL $COLLATEINDEX -N -o index.sgml
]]></screen><para>The -N option creates a new index; -o indentifies the name of the output file. This name must be the same as the name you specified in the preample <indexterm><primary>preample</primary></indexterm>(see <xref linkend="preample">). The collateindex.<indexterm><primary>collateindex</primary></indexterm>pl script is part of the docbook-dsssl-stylesheets <indexterm><primary>docbook-dsssl-stylesheets</primary></indexterm>package (see <xref linkend="DocBook">). There are a multitude of options to collateindex.<indexterm><primary>collateindex</primary></indexterm>pl;<indexterm><primary>collateindex.pl</primary></indexterm> see the <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/collateindex.html">reference page</ulink> for more information.</para><para>Creating an index is a multi-step,<indexterm><primary>multi-step</primary></indexterm> two-pass process (see <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/indexing.html">Automatic Indexing with the DocBook DSSSL Stylesheets</ulink>):</para><itemizedlist><listitem><para>In order to create an index, you must first generate the raw index data. This is done with the HTML <indexterm><primary>HTML</primary></indexterm>stylesheet <indexterm><primary>stylesheet</primary></indexterm>(even if you want print output). That's why in <ulink url="lyxtox">lyxtox</ulink> we use the same copy of HTML.<indexterm><primary>HTML</primary></indexterm>index which was created with the &ldquo;no-chunks&rdquo; HTML <indexterm><primary>HTML</primary></indexterm>stylesheet<indexterm><primary>stylesheet</primary></indexterm></para><screen><![CDATA[$PERL $COLLATEINDEX -p -g -o index.sgml HTML.index
]]></screen></listitem><listitem><para>After you created the HTML.<indexterm><primary>HTML</primary></indexterm>index file, you can generate your final document <indexterm><primary>document</primary></indexterm>as usual using whichever stylesheet <indexterm><primary>stylesheet</primary></indexterm>is appropriate. The generated document <indexterm><primary>document</primary></indexterm>will contain the index:</para><itemizedlist><listitem><para>Using sgmltools,<indexterm><primary>sgmltools</primary></indexterm> as in older versions of lyxtox:<indexterm><primary>lyxtox</primary></indexterm></para><itemizedlist><listitem><para>For one big HTML <indexterm><primary>HTML</primary></indexterm>file:</para><screen><![CDATA[$SGMLTOOLS -b onehtml -s $HTML_NOCHUNKS_DSL -j "-i output.print.png" $1.sgml
]]></screen><para>(notice the nochunks <indexterm><primary>nochunks</primary></indexterm>option we pass to openjade <indexterm><primary>openjade</primary></indexterm>through sgmltools)</para></listitem><listitem><para>For many HTML <indexterm><primary>HTML</primary></indexterm>files (one per chapter/section):</para><screen><![CDATA[$SGMLTOOLS -b html -s $HTML_DSL -j "-i output.print.png" $1.sgml
]]></screen></listitem><listitem><para>and for PDF:<indexterm><primary>PDF</primary></indexterm></para><screen><![CDATA[$SGMLTOOLS -b pdf -s sgmltools-pdf -j "-i output.print.pdf" $1.sgml
]]></screen></listitem></itemizedlist></listitem><listitem><para>And using openjade <indexterm><primary>openjade</primary></indexterm>and pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>as in newer versions:</para><itemizedlist><listitem><para>For one big HTML <indexterm><primary>HTML</primary></indexterm>file:</para><screen><![CDATA[${OPENJADE} -t sgml -d $HTML_NOCHUNKS_DSL -i output.print.png -V nochunks $1.sgml > $1.html
]]></screen></listitem><listitem><para>For many HTML <indexterm><primary>HTML</primary></indexterm>files (one per chapter/section):</para><screen><![CDATA[$OPENJADE -t sgml -d $HTML_CHUNKS_DSL -i output.print.png $1.sgml
]]></screen></listitem><listitem><para>and for PDF:<indexterm><primary>PDF</primary></indexterm></para><screen><![CDATA[${PDFJADETEX} $1.tex
]]></screen></listitem></itemizedlist></listitem></itemizedlist></listitem></itemizedlist><tip>
<title>Tip</title> 
<para> 
Whether an index has to be created or not, can be controlled by setting html-index to "#t" in the stylesheets (see <xref linkend="DSSSL-stylesheets"> and <xref linkend="explain-DSSSL-stylesheets">) as follows (original code is in dbparam.dsl, but it is better not to touch it):
<screen>
<![CDATA[
(define html-index
  ;; REFENTRY html-index
  ;; PURP HTML indexing?
  ;; DESC
  ;; Turns on HTML indexing.  If true, then index data will be written
  ;; to the file defined by 'html-index-filename'.  This data can be
  ;; collated and turned into a DocBook index with bin/collateindex.pl.
  ;; /DESC
  ;; AUTHOR N/A
  ;; /REFENTRY
  #t)
]]>
</screen>Default is false ("#f"). I preferred to let the default untouched and insert the external entity "index" at the end of the document using <ulink url="runsed">runsed</ulink> and <ulink url="sedscr">sedscr</ulink>, see <xref linkend="explain-runsed-sed-sedscr">. If you decide to set html-index you will have to comment this in <ulink url="sedscr">sedscr</ulink>.
</para>
</tip>
<tip>
<title>Tip</title> 
<para> 
You can change the name of the file to which index data will be written by setting html-index-filename in the stylesheets (see <xref linkend="DSSSL-stylesheets"> and <xref linkend="explain-DSSSL-stylesheets">) as follows (original code is in dbparam.dsl, but it is better not to touch it):
<screen>
<![CDATA[
(define html-index-filename
  ;; REFENTRY html-index-filename
  ;; PURP Name of HTML index file
  ;; DESC
  ;; The name of the file to which index data will be written if
  ;; 'html-index' is not '#f'.
  ;; /DESC
  ;; AUTHOR N/A
  ;; /REFENTRY
  "HTML.index")
]]>
</screen>Default is HTML.index. I preferred to let the default untouched. If you decide to set html-index-filename, you will have to adapt <ulink url="lyxtox">lyxtox</ulink> to reflect the name change.
</para>
</tip>  
</sect2>
</sect1>
<sect1 id="explain-optimal-PDF"><title>Optimal PDF </title><para>HTML <indexterm><primary>HTML</primary></indexterm>is quite limited when it comes to advanced formatting <indexterm><primary>formatting</primary></indexterm>capabilities<indexterm><primary>capabilities</primary></indexterm> (although this has somewhat changed with the advent of CSS,<indexterm><primary>CSS</primary></indexterm> see <xref linkend="CSS"> and <xref linkend="explain-CSS">). On the other side, the layout <indexterm><primary>layout</primary></indexterm>of a PDF <indexterm><primary>PDF</primary></indexterm>document remains unchanged, regardless of the output medium,<indexterm><primary>medium</primary></indexterm> be it monitor, or printer. It retains all its typographic <indexterm><primary>typographic</primary></indexterm>finesse and is not (at least easily) modifiable.<indexterm><primary>modifiable</primary></indexterm> These properties, together with the availability <indexterm><primary>availability</primary></indexterm>of free PDF <indexterm><primary>PDF</primary></indexterm>readers, like Acrobat® <indexterm><primary>Acrobat®</primary></indexterm>Reader or xpdf, have rendered PDF <indexterm><primary>PDF</primary></indexterm>a very popular format. </para><para>But PDF <indexterm><primary>PDF</primary></indexterm>is not a simple print format. It incorporates features that bear similarities to HTML <indexterm><primary>HTML</primary></indexterm>: you can insert hypertext <indexterm><primary>hypertext</primary></indexterm>links to point either to some other place in the same document<indexterm><primary>document</primary></indexterm> (a cross-reference), to other PDF <indexterm><primary>PDF</primary></indexterm>documents, or even to WWW <indexterm><primary>WWW</primary></indexterm>pages. You can have the Table of Contents as a link tree to the left (&ldquo;bookmarks&rdquo;), extended Document Information (author, keywords,<indexterm><primary>keywords</primary></indexterm> creator, embedded <indexterm><primary>embedded</primary></indexterm>fonts etc.), or thumbnails <indexterm><primary>thumbnails</primary></indexterm>(we will talk in <xref linkend="explain-thumbnails"> for the details of thumbnail generation), which are small pictograms <indexterm><primary>pictograms</primary></indexterm>of the document's pages to aid visual navigation.</para><para>In this section I will discuss the details of incorporating all these advanced features in the PDF <indexterm><primary>PDF</primary></indexterm>document generated by DocBook <indexterm><primary>DocBook</primary></indexterm>through LyX.<indexterm><primary>LyX</primary></indexterm></para><sect2 id="explain-lyx-to-pdf"><title>From .lyx to .pdf </title><para>The classic way to transform a . lyx <indexterm><primary>lyx</primary></indexterm>document to PDF <indexterm><primary>PDF</primary></indexterm>format is to follow a three-pass <indexterm><primary>three-pass</primary></indexterm>procedure:<indexterm><primary>procedure</primary></indexterm> first, the .lyx document <indexterm><primary>document</primary></indexterm>is exported to DVI,<indexterm><primary>DVI</primary></indexterm> then to PS <indexterm><primary>PS</primary></indexterm>through dvi2ps,<indexterm><primary>dvi2ps</primary></indexterm> then the PS <indexterm><primary>PS</primary></indexterm>version is tranformed to PDF <indexterm><primary>PDF</primary></indexterm>through software like the commercial Acrobat® <indexterm><primary>Acrobat®</primary></indexterm>Distiller®<indexterm><primary>Distiller®</primary></indexterm><footnote><para>Distiller® is a registered trademark of Adobe Systems Incorporated. </para></footnote>, or the freely available Ghostscript.<indexterm><primary>Ghostscript</primary></indexterm> (via ps2pdf).</para><para>This classic three-pass <indexterm><primary>three-pass</primary></indexterm>procedure <indexterm><primary>procedure</primary></indexterm>is not only complicated, it also loses some information through the intermediate DVI <indexterm><primary>DVI</primary></indexterm>format. The results are often not acceptable: the most frequent problem is bad presentation of the character glyphs <indexterm><primary>glyphs</primary></indexterm>that make up the document <indexterm><primary>document</primary></indexterm>(see <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=dvips-pdf">Quality of PDF from PostScript</ulink>):</para><itemizedlist><listitem><para>Wrong type of fonts <indexterm><primary>fonts</primary></indexterm>used, which is the commonest cause of fuzzy text.</para></listitem><listitem><para>ghostscript <indexterm><primary>ghostscript</primary></indexterm>too old, which can also result in fuzzy text.</para></listitem><listitem><para>Switching to font encoding <indexterm><primary>encoding</primary></indexterm>T1,<indexterm><primary>T1</primary></indexterm> which is yet another possible cause of fuzzy text.</para></listitem><listitem><para>Another problem - missing characters - arises from an aged version of Acrobat®<indexterm><primary>Acrobat®</primary></indexterm> Distiller®.<indexterm><primary>Distiller®</primary></indexterm></para></listitem><listitem><para>Finally, there's the common confusion that arises from using the dvips <indexterm><primary>dvips</primary></indexterm>configuration file -Ppdf, the weird characters.</para></listitem></itemizedlist><para>It would be much better to produce the PDF <indexterm><primary>PDF</primary></indexterm>version directly from the TeX<indexterm><primary>TeX</primary></indexterm> (i.e. LyX) output. The pdftex <indexterm><primary>pdftex</primary></indexterm>package (see <xref linkend="TeX-LaTeX">) was created with this objective in mind. pdftex <indexterm><primary>pdftex</primary></indexterm>(and pdfjadetex) creates the PDF <indexterm><primary>PDF</primary></indexterm>document in one pass from the TeX<indexterm><primary>TeX</primary></indexterm> format. A disadvantage of pdftex <indexterm><primary>pdftex</primary></indexterm>and pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>used to be the complexity <indexterm><primary>complexity</primary></indexterm>of the preliminary steps (see <xref linkend="required-preliminary-steps">, especially <xref linkend="add-density">) needed to get a <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>document converted to PDF,<indexterm><primary>PDF</primary></indexterm> escecially when it contained images. Not anymore: the method described here automates the format transormations<indexterm><primary>transormations</primary></indexterm> for the images and hides the complexity <indexterm><primary>complexity</primary></indexterm>of the commands involved in three files (<ulink url="./sedscr">sedscr</ulink>, <ulink url="./jadetex.cfg">jadetex.cfg</ulink>, <ulink url="./lyxtox">lyxtox</ulink>). See <xref linkend="explain-figures">.</para></sect2>
<sect2 id="explain-figures"><title>Figures </title><para>This is a serious problem most people fail in first place. <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>(and LyX) expects the images to be in encapsulated <indexterm><primary>encapsulated</primary></indexterm>PostScript® (.eps) format (see <xref linkend="LyX-images">). On the other hand, pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>(see <xref linkend="openjade-pdftex-jadetex">) is not capable of dealing with eps (only with PDF,<indexterm><primary>PDF</primary></indexterm> JPEG,<indexterm><primary>JPEG</primary></indexterm> PNG <indexterm><primary>PNG</primary></indexterm>or MetaPost), we will have to convert <indexterm><primary>convert</primary></indexterm>the images to <emphasis> encapsulated <indexterm><primary>encapsulated</primary></indexterm>PDF</emphasis> (.epdf) format, while still carrying the .pdf ending! This is best done by the <ulink url="addd">addd</ulink> script, which in turn uses convert <indexterm><primary>convert</primary></indexterm>(from the <ulink url="http://www.imagemagick.org">Image Magick</ulink> package) and <ulink url="http://www.ctan.org/ctan/tex-archive/support/eps2pdf/?action=/ctan/tex-archive/support">eps2pdf</ulink>. The script works as follows (FIXME: The script has been simplified. I didn't test it extensively though. The following describes the old script):</para><para>Some variables are set first:</para><screen>
CONVERT="/usr/bin/convert" <co id="convert">
DENSITY=133 <co id="density">
</screen>
<calloutlist>
    <callout arearefs="convert">
       <para>
      The location of the convert utility. It is part of the ImageMagick package, so you must have ImageMagick installed.
      </para>
    </callout>
<callout arearefs="density">
       <para>
     The "dots-per-inch" of the device where the image was made. If you plan to use the addd script to add density to screenshots, then this is the DPI value of the monitor where the screenshots were made.
      </para>
    </callout>
</calloutlist>
<itemizedlist><listitem><para>The script echoes some information about the file it processes and the calculated constants:<indexterm><primary>constants</primary></indexterm></para><screen><![CDATA[echo ""
]]><![CDATA[echo "Processing file $1.png"
]]><![CDATA[echo ""
]]><![CDATA[echo "DENSITY=$DENSITY"
]]></screen></listitem><listitem><para>We use ImageMagik <indexterm><primary>ImageMagik</primary></indexterm>to convert <indexterm><primary>convert</primary></indexterm>the PNG <indexterm><primary>PNG</primary></indexterm>image to encapsulated <indexterm><primary>encapsulated</primary></indexterm>PDF (EPDF, a format different from encapsulated <indexterm><primary>encapsulated</primary></indexterm>PostScript®, EPS), adding density and antialiasing (so that texts are more readable). This is necessary in order for the bitmapped <indexterm><primary>bitmapped</primary></indexterm>image to behave correctly in the PS <indexterm><primary>PS</primary></indexterm>document and is a point often and easily missed<footnote><para>A PostScript® and an encapsulated PostScript® file differ only in the bounding box statement. The preamble of the PostScript® file contains, for example</para><screen><![CDATA[%%BoundingBox: 65 242 547 550 
]]></screen><para>while the preamble of the encapsulated PostScript® file contains</para><screen><![CDATA[%%BoundingBox: 0 0 482 308 
]]></screen><para>Thus, the PostScript® file specifies an absolute position for the image, while the encapsulated PostScript® file does not. The encapsulated PostScript® file will be offset by some amount, to be determined by the program that includes it. Knowing this, you can easily convert from one format to the other manually, just by editing the BoundingBox statement. </para><para>(O.K., there is another small difference: the PostScript® file contains a <emphasis>showpage</emphasis> command that instructs the printer to print the page after rendering it.)</para></footnote>:</para><screen><![CDATA[${CONVERT} -antialias -density ${DENSITY} $1.png $1.epdf
]]></screen></listitem><listitem><para>We then use ImageMagick again to convert the PNG image to encapsulated <indexterm><primary>encapsulated</primary></indexterm>PostScript®<footnote><para>A PostScript® and an encapsulated PostScript® file differ only in the bounding box statement. The preamble of the PostScript® file contains, for example</para><screen><![CDATA[%%BoundingBox: 65 242 547 550 
]]></screen><para>while the preamble of the encapsulated PostScript® file contains</para><screen><![CDATA[%%BoundingBox: 0 0 482 308 
]]></screen><para>Thus, the PostScript® file specifies an absolute position for the image, while the encapsulated PostScript® file does not. The encapsulated PostScript® file will be offset by some amount, to be determined by the program that includes it. Knowing this, you can easily convert from one format to the other manually, just by editing the BoundingBox statement. </para><para>(O.K., there is another small difference: the PostScript® file contains a <emphasis>showpage</emphasis> command that instructs the printer to print the page after rendering it.)</para></footnote> format, adding antialiasing again: </para><screen><![CDATA[${CONVERT} -antialias -density ${DENSITY} $1.png $1.eps
]]></screen></listitem><listitem><para>But we are still not done! pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>will accept encapsulated <indexterm><primary>encapsulated</primary></indexterm>PDF images (.epdf), but only if they end in .pdf! We thus have to rename the EPDF <indexterm><primary>EPDF</primary></indexterm>image to a PDF <indexterm><primary>PDF</primary></indexterm>one:</para><screen><![CDATA[# Rename the file so that it ends in pdf - pdftex wants this!
]]><![CDATA[mv $1.epdf $1.pdf
]]></screen></listitem></itemizedlist><para>This procedure<indexterm><primary>procedure</primary></indexterm> will create pdf and png files with the right resolution<indexterm><primary>resolution</primary></indexterm> (density) information<indexterm><primary>information</primary></indexterm>. Unfortunately the eps file that is also created as a by-product, will display somewhat smaller. FIXME: This may be the result of ghostview<indexterm><primary>ghostview</primary></indexterm> not using the right DPI<indexterm><primary>DPI</primary></indexterm> when it displays the image, so it may be a problem of my system configuration.</para><para>You can automate the &ldquo;add density&rdquo; procedure using the <ulink url="adddscr">adddscr</ulink> script, which is included in the packages that you will find in <xref linkend="formats">:</para><screen><![CDATA[#! /bin/sh
]]><![CDATA[for x in `ls *.$1`; do
]]><![CDATA[y=`basename $x .$1`
]]><![CDATA[convert $y.$1 $y.png
]]><![CDATA[addd $y
]]><![CDATA[convert $y.png $y.bmp
]]><![CDATA[done
]]></screen><para>The <ulink url="adddscr">adddscr</ulink> script accepts one parameter: the format from which you want to start the conversion. The idea is the following: suppose you have a set of GIFs, but no PNGs or any other format. Then you can change to the directory of the images, type</para><screen><![CDATA[adddscr gif
]]></screen><para>and get your GIFs converted to PNGs, then get EPDF (renamed as PDF) and EPS version with added density. If you only have, say, BMP versions, just type</para><screen><![CDATA[adddscr bmp
]]></screen><para>and the script will convert your BMPs to PNGs first, then to all other formats<indexterm><primary>formats</primary></indexterm>, adding density on the way.</para><para>For example, you can use the <ulink url="adddscr">adddscr</ulink> <indexterm><primary>adddscr</primary></indexterm>script the very first time you install the docbook-dsssl-stylesheets <acronym>RPM</acronym>. The <acronym>RPM</acronym> package offers GIF<indexterm><primary>GIF</primary></indexterm>, EPS<indexterm><primary>EPS</primary></indexterm> and PDF<indexterm><primary>PDF</primary></indexterm> versions of admonitions<indexterm><primary>admonitions</primary></indexterm> (see <xref linkend="admonitions">) and callouts<indexterm><primary>callouts</primary></indexterm> (see <xref linkend="callouts">). The EPS and PDF versions surely come with the density of the system<indexterm><primary>system</primary></indexterm> (read: monitor<indexterm><primary>monitor</primary></indexterm>) they were created on, so it may not be wise to add density to them once again (if you do it, it may make the admonition and callout icons display smaller or larger than they should in PDF and PS documents)<footnote><para>Although, I must say that I <emphasis>had</emphasis> to add the right density to the EPS and PDF versions too, after all - the original ones appeared too large in the PDF and PS documents.</para></footnote>. However, while you might want to leave the EPS and PDF versions untouched, you definitely need PNG and BMP versions of the images. Here's where the <ulink url="adddscr">adddscr</ulink> script comes in handy:</para><para>Comment the line that adds density in <ulink url="adddscr">adddscr</ulink>:</para><screen><![CDATA[#! /bin/sh
]]><![CDATA[for x in `ls *.$1`; do
]]><![CDATA[y=`basename $x .$1`
]]><![CDATA[convert $y.$1 $y.png
]]><![CDATA[# addd $y
]]><![CDATA[convert $y.png $y.bmp
]]><![CDATA[done
]]></screen><para>change to the directory of the admonitions and callouts:</para><screen><![CDATA[cd /usr/share/sgml/docbook/docbook-dsssl-stylesheets/images
]]></screen><para>then type</para><screen><![CDATA[adddscr gif
]]></screen><para>Do the same for the callouts:</para><screen><![CDATA[cd /usr/share/sgml/docbook/docbook-dsssl-stylesheets/images/callouts
]]><![CDATA[adddscr gif
]]></screen><para>Now you have PNG and BMP versions of all your admonition and callout icons!<footnote><para>Depending on your stylesheets, you may need to copy them to wherever they expect the icons to be, e.g. /usr/share/sgml/docbkdsl/images or somewhere else. YMMV.</para></footnote></para><para>If you wondered why your images dont't get included in the PDF, although you meticulously prepared everything &ldquo;right&rdquo;, now you know why! But there's more to it - read on!<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
<note>
<title>But what is this "density" anyway?</title>
<para>
From <ulink url="http://studio.imagemagick.org/pipermail/magick-users/2002-May/002779.html">problem downsampling</ulink>:
</para>
<para>
You should think of a digital image as a rectangular pixel grid.  Suppose you have an image of 1500 by 2000 pixels. The image could be printed (on paper) or viewed (on screen). For that purpose, you have to tell the printer software or the "display" utility program how large an image pixel should be printed as. 
</para>
<para>
Suppose you want a single image pixel for a single printer dot, at 300 dots per inch (dpi).  That means that the image will come out of the printer with a size of about 5 inch by 6.6 inch (or 127 mm by 169 mm).
</para>
<para>
But the image file (normally) only knows about its pixel size (1500x2000), not its size at which it should be printed (since you could as well print it at double or half of the size; that's up to the printer software).
</para>
<para>
However, some image formats (e.g. TIFF, EPS, EPDF) allow to store the "density", i.e., the real physical size of a pixel, as extra (header) information. This is what we have to do with  our EPS and PDF images too.
</para>
</note>
<para>Having converted the images to all possible formats and having used the right parameters for each format, still does not mean we are done! If we are not very careful about the way we will use them, we will end up in a real mess, even though all seems to be right according to the packages,<indexterm><primary>packages</primary></indexterm> the SGML <indexterm><primary>SGML</primary></indexterm>specification, the Stylesheets etc. </para><para>The problem is that when you generate &quot;print&quot; output, the stylesheets don't have any means to know which print format you mean, EPS,<indexterm><primary>EPS</primary></indexterm> PDF <indexterm><primary>PDF</primary></indexterm>or RTF <indexterm><primary>RTF</primary></indexterm>-- there's no way to provide them with that information yet. Given the choice of PNG,<indexterm><primary>PNG</primary></indexterm> BMP <indexterm><primary>BMP</primary></indexterm>or EPS <indexterm><primary>EPS</primary></indexterm>they'll choose EPS <indexterm><primary>EPS</primary></indexterm>every time. As we've said, pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>doesn't handle .eps files.</para><para>The solution is to use parameter <indexterm><primary>parameter</primary></indexterm>entities <indexterm><primary>entities</primary></indexterm>(if that's an unfamiliar term, read the <ulink url="http://www.freebsd.org/doc/en_US.ISO8859-1/books/fdp-primer/sgml-primer-entities.html">FreeBSD Documentation Project Primer for New Contributors: Entities</ulink>, there's a section in there which explains them, and gives examples of using them to conditionally include certain parts of your document).</para><para>In a nutshell,<indexterm><primary>nutshell</primary></indexterm> start your document <indexterm><primary>document</primary></indexterm>like this:</para><screen><![CDATA[<!DOCTYPE book  PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
]]><![CDATA[<!ENTITY % output.print.png "IGNORE">
]]><![CDATA[<!ENTITY % output.print.pdf "IGNORE">
]]><![CDATA[<!ENTITY % output.print.eps "IGNORE">
]]><![CDATA[<!ENTITY % output.print.bmp "IGNORE">
]]><![CDATA[]>
]]><![CDATA[<!-- rest of the document as normal -->
]]></screen><para>Adjust that as necessary, depending on which version of the DTD <indexterm><primary>DTD</primary></indexterm>you're using. The key bits are the ENTITY lines.</para><para>Then, when you want to include an image, do this (see the explanation of the <ulink url="sedscr">sedscr</ulink> file in <xref linkend="explain-runsed-sed-sedscr">):</para><screen><![CDATA[]]><inlinegraphic fileref="&file1024;" format="linespecific"><![CDATA[
]]></screen><para>Now, when you process your document <indexterm><primary>document</primary></indexterm>with &quot;openjade ...&quot;, the &quot;%output.print.xxx;&quot; is replaced by the word &quot;IGNORE&quot;. This tells Jade <indexterm><primary>Jade</primary></indexterm>to ignore that section of the document.<indexterm><primary>document</primary></indexterm> The overall effect is that <emphasis>no</emphasis> image will be included, neither PNG,<indexterm><primary>PNG</primary></indexterm> nor PDF,<indexterm><primary>PDF</primary></indexterm> nor EPS,<indexterm><primary>EPS</primary></indexterm> nor BMP.<indexterm><primary>BMP</primary></indexterm></para><para>In order to get one (and only one) image included, you have to tell Jade<indexterm><primary>Jade</primary></indexterm> that one or other of the %output.print.xxx; entities <indexterm><primary>entities</primary></indexterm>must contain &quot;INCLUDE&quot; rather than &quot;IGNORE&quot;. You can do this on the command line with the &quot;-i&quot; flag. So if you're producing a HTML <indexterm><primary>HTML</primary></indexterm>file, you would do (see <ulink url="lyxtox">lyxtox</ulink> and <xref linkend="explain-document-creation-HTML">):</para><screen><![CDATA[$SGMLTOOLS -b html -s $HTML_DSL -j "-i output.print.png" $1.sgml
]]></screen><para>If you're producing a PDF <indexterm><primary>PDF</primary></indexterm>file, you would do (see <ulink url="lyxtox">lyxtox</ulink> and <xref linkend="explain-document-creation-PDF">):</para><screen><![CDATA[$SGMLTOOLS -b pdf -s sgmltools-pdf -j "-i output.print.pdf" $1.sgml
]]></screen><para>and so on. With the -j option to sgmltools <indexterm><primary>sgmltools</primary></indexterm>you can pass options to Jade <indexterm><primary>Jade</primary></indexterm>- we thus pass the aproppriate &quot;-i output.print.xxx&quot; for each format. </para><para>Using openjade <indexterm><primary>openjade</primary></indexterm>and pdfjadetex,<indexterm><primary>pdfjadetex</primary></indexterm> these commands are equivalent to:</para><screen><![CDATA[${OPENJADE} -t sgml -d $HTML_NOCHUNKS_DSL -i output.print.png -V nochunks $1.sgml > $1.html
]]></screen><para>and:</para><screen><![CDATA[${OPENJADE} -t tex -d ${PRINT_PDF_DSL} -o $1.tex -i "output.print.pdf" $1.sgml
]]><![CDATA[${PDFJADETEX} $1.tex
]]></screen><para>respectively. </para><para>Yes, it's a <ulink url="http://whatis.techtarget.com/definition/0,,sid9_gci212446,00.html">kludge</ulink>. But once incorporated in a script (like <ulink url="sedscr">sedscr</ulink>, see <xref linkend="explain-runsed-sed-sedscr">), that doesn't have to bother us any more. I owe it to Nik Clayton<indexterm><primary>Clayton</primary></indexterm>, who posted it to the docbook-apps mailing list on June 8th, 2000 . It works great! Thanks Nik.</para></sect2>
<sect2 id="explain-Type-1"><title>Using Type 1 Fonts </title><para>If you want a PDF <indexterm><primary>PDF</primary></indexterm>document that not only excels when printed, but also when displayed on the screen, it is advisable to embed <indexterm><primary>embed</primary></indexterm>Type 1 fonts,<indexterm><primary>fonts</primary></indexterm> even though the document <indexterm><primary>document</primary></indexterm>may increase in size. The reason is is that by default TeX/LaTeX uses bitmapped <indexterm><primary>bitmapped</primary></indexterm>fonts <indexterm><primary>fonts</primary></indexterm>instead of Type1 <indexterm><primary>Type1</primary></indexterm>or TrueType <indexterm><primary>TrueType</primary></indexterm>ones. The resolution <indexterm><primary>resolution</primary></indexterm>of these bitmapped <indexterm><primary>bitmapped</primary></indexterm>fonts <indexterm><primary>fonts</primary></indexterm>matches that of the printer on the system you create the document.<indexterm><primary>document</primary></indexterm> This is rarely the same resolution <indexterm><primary>resolution</primary></indexterm>of the monitor or printer the reader will use. This change in resolution <indexterm><primary>resolution</primary></indexterm>results in terrible quality when displaying these fonts <indexterm><primary>fonts</primary></indexterm>on a screen. or printing it on a printer, whose resolution <indexterm><primary>resolution</primary></indexterm>does not match the one of the bitmapped <indexterm><primary>bitmapped</primary></indexterm>font. </para><para>The solution to the problem is to force TeX/LaTeX to use Type1 <indexterm><primary>Type1</primary></indexterm>fonts <indexterm><primary>fonts</primary></indexterm>which are scalable <indexterm><primary>scalable</primary></indexterm>and thus resolution-independent. There are two ways to achieve this:</para><itemizedlist><listitem><para>Use of the standard PostScript® <indexterm><primary>PostScript®</primary></indexterm>fonts<indexterm><primary>fonts</primary></indexterm></para></listitem><listitem><para>Use of Type1 <indexterm><primary>Type1</primary></indexterm>versions of Computer Modern (CM) fonts.<indexterm><primary>fonts</primary></indexterm></para></listitem></itemizedlist><para>I chose the latter method. I like the look of the <application>TeX</application> documents that use Computer Modern fonts. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_cool.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_cool.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_cool.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_cool.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject></para>
<para>I am not alone with this predilection:<indexterm><primary>predilection</primary></indexterm> most people use Computer Modern to start with, and even those relative sophisticates who use something as exotic as <emphasis>Sabon</emphasis> often find themselves using odd characters from CM without really intending to do so (see <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=fuzzy-type3">The wrong type of fonts in PDF</ulink>). </para><para>Fortunately, rather good versions of the CM fonts <indexterm><primary>fonts</primary></indexterm>are available from the AMS (who have them courtesy <indexterm><primary>courtesy</primary></indexterm>of <ulink url="http://www.bluesky.com">Blue Sky</ulink> Research and <ulink url="http://www.yandy.com">Y&amp;Y</ulink>, see <ulink url="http://www.math.utah.edu/~beebe/fonts/bluesky.html">Blue Sky Research and Computer Modern fonts</ulink> for some historical background) and most modern systems have the fonts<indexterm><primary>fonts</primary></indexterm> installed ready to use (if yours doesn't, go get them from the <ulink url="http://ctan.tug.org/tex-archive/fonts/cm/ps-type1/bluesky/">Comprehensive <application>TeX</application> Archive Network archives: Blue Sky CM Type 1 fonts</ulink>, or any other CTAN <indexterm><primary>CTAN</primary></indexterm>mirror). </para><para>There are six DSSSL<indexterm><primary>DSSSL</primary></indexterm> variables for defining parameters for changing fonts.<indexterm><primary>fonts</primary></indexterm></para><variablelist><varlistentry><term>%title-font-family%
</term><listitem><para><indexterm><primary>%title-font-family%</primary></indexterm>the font used for all titles. Example: titles, glossary<indexterm><primary>glossary</primary></indexterm> entries.</para></listitem></varlistentry><varlistentry><term>%admon-font-family%
</term><listitem><para><indexterm><primary>%admon-font-family%</primary></indexterm>the font used for admonissions.<indexterm><primary>admonissions</primary></indexterm> Example: note.</para></listitem></varlistentry><varlistentry><term>%guilabel-font-family%
</term><listitem><para><indexterm><primary>%guilabel-font-family%</primary></indexterm>the font used for GUI<indexterm><primary>GUI</primary></indexterm> text. Example: guimenuitem.</para></listitem></varlistentry><varlistentry><term>%mono-font-family%
</term><listitem><para><indexterm><primary>%mono-font-family%</primary></indexterm>the font used for elements needing typewriter <indexterm><primary>typewriter</primary></indexterm>or monospace<indexterm><primary>monospace</primary></indexterm> text. Example: file names, commands and URLs.</para></listitem></varlistentry><varlistentry><term>%refentry-font-family%
</term><listitem><para>the font used for references.</para></listitem></varlistentry><varlistentry><term>%body-font-family%
</term><listitem><para><indexterm><primary>%body-font-family%</primary></indexterm>the font used for body<indexterm><primary>body</primary></indexterm> text.</para></listitem></varlistentry></variablelist><para>By default, these variables may take the following values:</para><itemizedlist><listitem><para>Helvetica</para></listitem><listitem><para>Palatino</para></listitem><listitem><para>Bookman</para></listitem><listitem><para>Courier</para></listitem><listitem><para>Wingdings</para></listitem><listitem><para>Avant-Garde</para></listitem><listitem><para>New-Century-Schoolbook</para></listitem><listitem><para>Times-Roman</para></listitem><listitem><para>Zapf-Dingbats</para></listitem><listitem><para>Computer-Modern-Typewriter</para></listitem><listitem><para>Computer-Moder-Sans</para></listitem><listitem><para>Computer-Modern</para></listitem><listitem><para>Computer-Modern-Caps-And-Small-Caps</para></listitem></itemizedlist><para>Other font names may be used, but they correspond to one of the fonts <indexterm><primary>fonts</primary></indexterm>in the list above. For example:</para><itemizedlist><listitem><para>Arial = iso-sanserif = Helvetica<indexterm><primary>Helvetica</primary></indexterm></para></listitem><listitem><para>Courier-New = Courier<indexterm><primary>Courier</primary></indexterm></para></listitem><listitem><para>Times-New-Roman = iso-serif = Times-Roman<indexterm><primary>Times-Roman</primary></indexterm></para></listitem><listitem><para>WingDings = Wingdings<indexterm><primary>Wingdings</primary></indexterm></para></listitem></itemizedlist><para>To use other fonts,<indexterm><primary>fonts</primary></indexterm> they must be T1 <indexterm><primary>T1</primary></indexterm>fonts, the coding used by <application>TeX</application>.<indexterm><primary>TeX</primary></indexterm> These are listed in the file called t1***.fd, where *** is the font code. The first letter represents the font provider; the next two letters represent the font name. In addition, we must ensure that all required files are present in our installation, i.e. the .tfm, .afm, .vf, .pfm and .pfb files for each .fd file.</para><para>We must ensure that Jadetex can associate the font name, e.g. Utopia, with the code name of the font (for Utopia, &quot;put&quot;). This is done by adding lines such as the following to the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file: </para><screen><![CDATA[\def\Family@font_name(***)
]]></screen><para>where *** again represents the three-letter code and &quot;font_name&quot; is the... font name. For example, to use the Utopia font, the following line would be added to the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file: </para><screen><![CDATA[\def\Family@Utopia{put}.
]]></screen><para>Following <ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/fixingproblems.html">Customizing Document Production</ulink>, we can include these lines in the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file (currently commented, since they make sense only if you have those fonts <indexterm><primary>fonts</primary></indexterm>installed - uncomment accordingly):</para><screen><![CDATA[\makeatletter
]]><![CDATA[\def\Family@Utopia{put}
]]><![CDATA[\def\Family@ZapfChancery{pzc}
]]><![CDATA[\def\Family@Fibonacci{cmfib}
]]><![CDATA[\def\Family@Funny{cmfr}
]]><![CDATA[\def\Family@Dunhill{cmdh}
]]><![CDATA[\def\Family@Concrete{ccr}
]]><![CDATA[\def\Family@Charter{bch}
]]><![CDATA[\def\Family@Fontpxr{pxr}
]]><![CDATA[\def\Family@Fontaer{aer}
]]><![CDATA[\def\Family@Fontaess{aess}
]]><![CDATA[\def\Family@Fontaett{aett}
]]><![CDATA[\def\Family@Fontlcmss{lcmss}
]]><![CDATA[\def\Family@Fontlcmtt{lcmtt}
]]><![CDATA[\def\Family@Fontcmvtt{cmvtt}
]]><![CDATA[\def\Family@Fontcmbr{cmbr}
]]><![CDATA[\def\Family@Fontcmtl{cmtl}
]]><![CDATA[\def\Family@Fontpxss{pxss}
]]><![CDATA[\def\Family@Fonttxss{txss}
]]><![CDATA[\def\Family@Fonttxr{txr}
]]><![CDATA[\makeatother
]]></screen><para>The font declarations are preceded by \makeatletter and followed by \makeatother to properly escape the &quot;@&quot; symbol.</para><para>Now, if we wish titles to be formatted using Fonttxr and body <indexterm><primary>body</primary></indexterm>text with Concrete, all that is necessary is to add the following lines to <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink>:</para><screen><![CDATA[(define %title-font-family% "Fonttxr") (define
]]><![CDATA[%body-font-family% "Concrete"
]]></screen><para>And in order to use Computer Modern fonts <indexterm><primary>fonts</primary></indexterm>in the PDF <indexterm><primary>PDF</primary></indexterm>document , we write the following in the print stylesheet,<indexterm><primary>stylesheet</primary></indexterm> <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink> (see <xref linkend="explain-DSSSL-stylesheets">):</para><screen><![CDATA[    ;;  Gnuishly correct fonts...
]]><![CDATA[    ;;
]]><![CDATA[    (define %body-font-family% "Computer-Modern")
]]><![CDATA[    (define %mono-font-family% "Computer-Modern-Typewriter")
]]><![CDATA[    (define %title-font-family% "Computer-Modern")
]]><![CDATA[    (define %admon-font-family% "Computer-Modern-Sans")
]]><![CDATA[    (define %guilabel-font-family% "Computer-Modern-Sans")
]]></screen><para>Now, if the T1 <indexterm><primary>T1</primary></indexterm>font encoding<indexterm><primary>encoding</primary></indexterm> is used, i.e. if the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file contains the line</para><screen><![CDATA[\usepackage[T1]{fontenc}
]]></screen><para>the EC <indexterm><primary>EC</primary></indexterm>fonts will be used instead of the CM ones. Since there are no Type1 <indexterm><primary>Type1</primary></indexterm>EC <indexterm><primary>EC</primary></indexterm>fonts available, pdftex <indexterm><primary>pdftex</primary></indexterm>will use bitmapped<indexterm><primary>bitmapped</primary></indexterm> ones, yielding poor quality PDF <indexterm><primary>PDF</primary></indexterm>files. Fortunately, there is a workaround:<indexterm><primary>workaround</primary></indexterm> the ae <indexterm><primary>ae</primary></indexterm>package provides virtual EC <indexterm><primary>EC</primary></indexterm>fonts based on the CM ones, so that the Type1 <indexterm><primary>Type1</primary></indexterm>CM fonts <indexterm><primary>fonts</primary></indexterm>can be used in the output file. However, not all EC <indexterm><primary>EC</primary></indexterm>characters are available in this way. The aecompl<indexterm><primary>aecompl</primary></indexterm> package defines the missing characters as bitmapped <indexterm><primary>bitmapped</primary></indexterm>fonts.<indexterm><primary>fonts</primary></indexterm> To use them you should have the following in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg:</para><screen><![CDATA[\usepackage{ae} 
]]><![CDATA[\usepackage{aecompl} 
]]></screen><para>or just</para><screen><![CDATA[\usepackage{ae,aecompl} 
]]></screen><para>In this way the output file will use CM fonts <indexterm><primary>fonts</primary></indexterm>for all except some rarely used characters. pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>will end saying something like:</para><screen><![CDATA[<8r.enc><cmex10.pfb><cmti9.pfb><cmmi6.pfb><cmr7.pfb><cmmi7.pfb> </var/cache/f
]]><![CDATA[onts/pk/ljfour/jknappen/tc/tcrm0700.600pk><cmr6.pfb><cmsy10.pfb><cmitt10.pfb><c
]]><![CDATA[mssi9.pfb><cmmi9.pfb><cmr9.pfb><cmmi10.pfb><cmtt8.pfb><cmtt9.pfb><cmss9.pfb> </
]]><![CDATA[var/cache/fonts/pk/ljfour/jknappen/tc/tcrm0800.600pk><cmti10.pfb><cmbx10.pfb> <
]]><![CDATA[/var/cache/fonts/pk/ljfour/jknappen/tc/tcrm1000.600pk><cmr10.pfb><cmssbx10.pfb>
]]></screen><para>meaning that it has embedded <indexterm><primary>embedded</primary></indexterm>all fonts <indexterm><primary>fonts</primary></indexterm>shown in angle brackets into the PDF <indexterm><primary>PDF</primary></indexterm>file. See <ulink url="http://ltswww.epfl.ch/~dsanta/resources/type1">High quality PDF output from <application>LaTeX</application> and TeX</ulink> for more details. </para><tip>
<title>Tip:</title> 
<para> 
You can check the fonts used in the PDF file by choosing File-->Documet Info-->Fonts-->List all fonts in Acrobat® <application>Reader</application>. You will see that the fonts are embedded (not totally, but as a subset, which is the legally correct way) in the PDF document, see <xref linkend="fig-DocInfo-Fonts">.
</para> 
</tip>
<para>
<figure id="fig-DocInfo-Fonts" float="1">
   <title>
   Document Info: Fonts.
   </title>
   <mediaobject>
      <![ %output.print.png; [
      <imageobject>
         <imagedata fileref="./images/&graph1005;.png" format="PNG">
      </imageobject>
      ]]>
      <![ %output.print.pdf; [
      <imageobject>
         <imagedata fileref="&graph1005;.pdf" format="PDF">
      </imageobject>
      ]]>
      <![ %output.print.eps; [
      <imageobject>
         <imagedata fileref="&graph1005;.eps" format="EPS">
      </imageobject>
       ]]>
      <![ %output.print.bmp; [
      <imageobject>
         <imagedata fileref="&graph1005;.bmp" format="BMP">
      </imageobject>
       ]]>
      <textobject>
         <phrase>Document Info: Fonts.</phrase>
      </textobject>
      <caption>
         <para>Document Info: Fonts.</para>
      </caption>
   </mediaobject>
</figure>
</para><para>However, today other solutions to the font quality problem exist as well: instead of using <emphasis>virtual</emphasis> Type 1 fonts <indexterm><primary>fonts</primary></indexterm>(which is what you do when you use the ae,<indexterm><primary>ae</primary></indexterm> aecompl <indexterm><primary>aecompl</primary></indexterm>and aeguill<indexterm><primary>aeguill</primary></indexterm> packages), you may choose to use &ldquo;<emphasis>true</emphasis>&rdquo; Type 1<footnote><para>Not to be confused with &ldquo;True Type&rdquo; fonts.</para></footnote> fonts <indexterm><primary>fonts</primary></indexterm>by installing one of the new CM-super,<indexterm><primary>CM-super</primary></indexterm> CM-LGC <indexterm><primary>CM-LGC</primary></indexterm>or Latin Modern <indexterm><primary>Latin Modern</primary></indexterm>fonts. From <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=type1T1">Finding 8-bit Type 1 fonts</ulink>:</para><variablelist><varlistentry><term>CM-super
</term><listitem><para><indexterm><primary>CM-super</primary></indexterm>is an auto-traced<indexterm><primary>auto-traced</primary></indexterm> set which encompasses all of the T1 <indexterm><primary>T1</primary></indexterm>and TS1 encodings as well as the T2* series (the family of encodings that cover languages based on Cyrillic<indexterm><primary>Cyrillic</primary></indexterm> alphabets). These fonts <indexterm><primary>fonts</primary></indexterm>are pretty easy to install (the installation instructions are clear), but they are huge: don't try to install them if you're short of disc space.</para></listitem></varlistentry><varlistentry><term>CM-LGC
</term><listitem><para><indexterm><primary>CM-LGC</primary></indexterm>is a similar &quot;super-font&quot; set, but of much more modest size; it covers T1,<indexterm><primary>T1</primary></indexterm> TS1 and T2{A} encodings (as does CM-super,<indexterm><primary>CM-super</primary></indexterm> and also covers the LGR encoding<indexterm><primary>encoding</primary></indexterm> (for typesetting Greek, based on Claudio Beccari's Metafont sources). CM-LGC <indexterm><primary>CM-LGC</primary></indexterm>manages to be small by going to the opposite extreme from CM-super,<indexterm><primary>CM-super</primary></indexterm> which includes fonts <indexterm><primary>fonts</primary></indexterm>at all the sizes supported by the original EC <indexterm><primary>EC</primary></indexterm>(a huge range); CM-LGC <indexterm><primary>CM-LGC</primary></indexterm>has one font per font shape, getting other sizes by scaling.<indexterm><primary>scaling</primary></indexterm> There is an inevitable loss of quality inherent in this approach,<indexterm><primary>approach</primary></indexterm> but for the disc-space-challenged machine, CM-LGC <indexterm><primary>CM-LGC</primary></indexterm>is an obvious choice.</para></listitem></varlistentry><varlistentry><term>Latin&nbsp;Modern
</term><listitem><para>is produced using a program MetaType1 which, as its name implies, brings the power of the Metafont paradigm to the production <indexterm><primary>production</primary></indexterm>of Type 1 fonts.<indexterm><primary>fonts</primary></indexterm> The Latin Modern <indexterm><primary>Latin Modern</primary></indexterm>set comes with T1,<indexterm><primary>T1</primary></indexterm> TS1 LY1 encoded variants (as well as a variant using the Polish QX encoding); for the glyph set it covers, its outlines <indexterm><primary>outlines</primary></indexterm>seem rather cleaner than those of CM-super.<indexterm><primary>CM-super</primary></indexterm> Latin Modern <indexterm><primary>Latin Modern</primary></indexterm>is more modest in its disc space demands than is CM-super,<indexterm><primary>CM-super</primary></indexterm> while not being nearly as stark in its range of design sizes as is CM-LGC<indexterm><primary>CM-LGC</primary></indexterm> - Latin Modern's fonts <indexterm><primary>fonts</primary></indexterm>are offered in the same set of sizes as the original CM fonts.<indexterm><primary>fonts</primary></indexterm> It's hard to argue with the choice: Knuth's range of sizes has stood the test of time, and is one of the bases on which the excellence of the TeX<indexterm><primary>TeX</primary></indexterm> system rests.</para></listitem></varlistentry></variablelist></sect2>
<sect2 id="explain-font-encoding"><title>Choosing the right font encoding</title><para>If you think of a font as being arranged in a table, then the font encoding<indexterm><primary>encoding</primary></indexterm> is nothing else than the way the font's symbols <indexterm><primary>symbols</primary></indexterm>(the &ldquo;glyphs&rdquo;) are arranged in the table. If you think of the table as being fixed, then different font encodings arrange the same or different glyphs <indexterm><primary>glyphs</primary></indexterm>in different ways in the table's cells. If you mentally number all table cells sequentially, then for each table cell you have a number and a glyph. The number is the font's internal representation <indexterm><primary>representation</primary></indexterm>(the &ldquo;encoding&rdquo;) of the glyph.</para><para>Fonts <indexterm><primary>Fonts</primary></indexterm>are always encoded in some encoding <indexterm><primary>encoding</primary></indexterm>- that's the nature of a font, being just a table of glyphs.<indexterm><primary>glyphs</primary></indexterm> Thus, in order to use a font that contains the glyphs <indexterm><primary>glyphs</primary></indexterm>(letters, symbols,<indexterm><primary>symbols</primary></indexterm>...) you need, you must tell pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>and jadetex <indexterm><primary>jadetex</primary></indexterm>which encoding <indexterm><primary>encoding</primary></indexterm>to use. For example, to use the T1 <indexterm><primary>T1</primary></indexterm>font encoding<indexterm><primary>encoding</primary></indexterm>, the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file must contain the line</para><screen><![CDATA[\usepackage[T1]{fontenc}
]]></screen><para>To use the OT1 <indexterm><primary>OT1</primary></indexterm>encoding,<indexterm><primary>encoding</primary></indexterm> you must have:</para><screen><![CDATA[\usepackage[OT1]{fontenc}
]]></screen><para>There are some factors that affect the choice of font encoding:<indexterm><primary>encoding</primary></indexterm></para><itemizedlist><listitem><para>Your language. More precisely, the glyphs<indexterm><primary>glyphs</primary></indexterm> you want to present in your document <indexterm><primary>document</primary></indexterm>(if you find the word &ldquo;glyphs&rdquo; confusing, just read &ldquo;letters&rdquo; or &ldquo;symbols&rdquo;). If your language is english, then you can use both the T1 <indexterm><primary>T1</primary></indexterm>and the OT1 <indexterm><primary>OT1</primary></indexterm>font encoding.<indexterm><primary>encoding</primary></indexterm> If your language is french, then you have to use the T1 <indexterm><primary>T1</primary></indexterm>encoding. The same is true for many european <indexterm><primary>european</primary></indexterm>languages. FIXME:<indexterm><primary>FIXME</primary></indexterm> encodings for other languages.</para></listitem><listitem><para>Mathematics. If you don't display any Mathematics,<indexterm><primary>Mathematics</primary></indexterm> you can choose from a wider choice of fonts <indexterm><primary>fonts</primary></indexterm>and font encodings. But if you use Mathematics,<indexterm><primary>Mathematics</primary></indexterm> your document <indexterm><primary>document</primary></indexterm>will look better if you choose a font family that contains mathematical <indexterm><primary>mathematical</primary></indexterm>symbols as well. A font family that contains excellent mathematical <indexterm><primary>mathematical</primary></indexterm>fonts is Computer Modern. Computer Codern came originally only in the OT1 <indexterm><primary>OT1</primary></indexterm>encoding.<indexterm><primary>encoding</primary></indexterm> This is fine, as long as you use only english. For european <indexterm><primary>european</primary></indexterm>languages, you have to use the T1 <indexterm><primary>T1</primary></indexterm>encoding. Now, if you have Mathematics <indexterm><primary>Mathematics</primary></indexterm><emphasis>and</emphasis> write in some european <indexterm><primary>european</primary></indexterm>language (e.g. french, where you need accented letters and the like), then your choice is becoming narrower: you need a good Mathematics <indexterm><primary>Mathematics</primary></indexterm>font, say Computer Modern, but you also need T1 <indexterm><primary>T1</primary></indexterm>encoding. This leads to the use of virtual EC <indexterm><primary>EC</primary></indexterm>fonts with the ae <indexterm><primary>ae</primary></indexterm>and aecompl <indexterm><primary>aecompl</primary></indexterm>packages,<indexterm><primary>packages</primary></indexterm> as discussed in <xref linkend="explain-Type-1">.</para></listitem><listitem><para>The symbols <indexterm><primary>symbols</primary></indexterm>you want to use. Some symbols <indexterm><primary>symbols</primary></indexterm>are available in one encoding,<indexterm><primary>encoding</primary></indexterm> but not in another. For example, 
 <inlineequation>
  <alt>$
 &lt;  &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/19071.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/19071.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/19071.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/19071.bmp">
 ]]>

 </inlineequation> is missing from the OT1 <indexterm><primary>OT1</primary></indexterm>encoded Computer Modern fonts,<indexterm><primary>fonts</primary></indexterm> but you can still get it in the PDF <indexterm><primary>PDF</primary></indexterm>and PS <indexterm><primary>PS</primary></indexterm>if you enter math <indexterm><primary>math</primary></indexterm>mode in Lyx and type the two 
 <inlineequation>
  <alt>$
 &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/16274.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/16274.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/16274.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/16274.bmp">
 ]]>

 </inlineequation> there. However,if your purpose is to get the french quotes (&ldquo;guillemets&rdquo;), then you might just as well choose the T1 <indexterm><primary>T1</primary></indexterm>encoding and the aeguill <indexterm><primary>aeguill</primary></indexterm>package:</para><screen><![CDATA[\usepackage[T1]{fontenc}
]]><![CDATA[\usepackage{aeguill}
]]></screen></listitem><listitem><para>Quality. You might not want to use the aeguill <indexterm><primary>aeguill</primary></indexterm>package, because the fonts <indexterm><primary>fonts</primary></indexterm>it defines are not as perfect as the original Computer Modern fonts,<indexterm><primary>fonts</primary></indexterm> leading to (maybe imperceptible, but nonetheless existent) inaccuracies and inconveniences in the resulting PDF.<indexterm><primary>PDF</primary></indexterm> So you might decide to use the OT1 <indexterm><primary>OT1</primary></indexterm>font encoding <indexterm><primary>encoding</primary></indexterm>and the original Computer Modern fonts,<indexterm><primary>fonts</primary></indexterm> entering your 
 <inlineequation>
  <alt>$
 &lt;  &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/17647.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/17647.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/17647.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/17647.bmp">
 ]]>

 </inlineequation> and 
 <inlineequation>
  <alt>$
 &gt;  &gt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/10553.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/10553.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/10553.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/10553.bmp">
 ]]>

 </inlineequation> always in math <indexterm><primary>math</primary></indexterm>mode in LyX.<indexterm><primary>LyX</primary></indexterm> Note that the HTML <indexterm><primary>HTML</primary></indexterm>versions of your document <indexterm><primary>document</primary></indexterm>will then contain small images in place of those symbols,<indexterm><primary>symbols</primary></indexterm> since <ulink url="lyxtox">lyxtox</ulink> will treat them as mathematical <indexterm><primary>mathematical</primary></indexterm>&ldquo; inline <indexterm><primary>inline</primary></indexterm>equations<indexterm><primary>equations</primary></indexterm>&rdquo; (see <xref linkend="mathematics">).</para></listitem></itemizedlist><para>Note that today other solutions to the font quality problem exist as well: instead of using <emphasis>virtual</emphasis> Type 1 fonts <indexterm><primary>fonts</primary></indexterm>(which is what you do when you use the ae,<indexterm><primary>ae</primary></indexterm> aecompl <indexterm><primary>aecompl</primary></indexterm>and aeguill<indexterm><primary>aeguill</primary></indexterm> packages), you may choose to use &ldquo;<emphasis>true</emphasis>&rdquo; Type 1 fonts <indexterm><primary>fonts</primary></indexterm>by installing one of the new CM-super,<indexterm><primary>CM-super</primary></indexterm> CM-LGC <indexterm><primary>CM-LGC</primary></indexterm>or Latin Modern<indexterm><primary>Latin Modern</primary></indexterm> fonts,<indexterm><primary>fonts</primary></indexterm> see <xref linkend="explain-Type-1">.</para></sect2>
<sect2 id="explain-true-type-fonts"><title>Using True Type fonts</title><para>FIXME: To be done. </para><para>For the moment, see <ulink url="http://www.tug.org/tex-archive/info/TrueType/ttf-tetex.pdf">Using TrueType fonts with <application>TeX</application> via Postscript Type1 format</ulink>. </para><para>The idea is: </para><itemizedlist><listitem><para>Transform the TT font to Type1 <indexterm><primary>Type1</primary></indexterm>(see <xref linkend="explain-Type-1">) using <ulink url="http://ttf2pt1.sourceforge.net/index.html">ttf2pt1</ulink>. Take care of naming conventions for the new font.</para></listitem><listitem><para>Integrate the newly created Type 1 font in your <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>installation. If you observed naming conventions, then this step might be done automatically.<indexterm><primary>automatically</primary></indexterm></para></listitem><listitem><para>In one of the last output lines of ttf2pt1, the font name was printed, for example:</para><screen><![CDATA[FontName VAGRoundedBT_Regular
]]></screen><para>Use that name in the <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink> file (see <xref linkend="explain-DSSSL-stylesheets">):</para><screen><![CDATA[    (define %body-font-family% "VAGRoundedBT_Regular")
]]><![CDATA[    (define %mono-font-family% "Computer-Modern-Typewriter")
]]><![CDATA[    (define %title-font-family% "VAGRoundedBT_Regular")
]]><![CDATA[    (define %admon-font-family% "Computer-Modern-Sans")
]]><![CDATA[    (define %guilabel-font-family% "Computer-Modern-Sans")
]]></screen><para>Of course, since this is a T1 <indexterm><primary>T1</primary></indexterm>font, the T1 <indexterm><primary>T1</primary></indexterm>font encoding<indexterm><primary>encoding</primary></indexterm> has to be used, i.e. the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file must contain the line</para><screen><![CDATA[\usepackage[T1]{fontenc}
]]></screen></listitem></itemizedlist></sect2>
<sect2 id="explain-hyperref"><title>The hyperref package </title><para>The <ulink url="http://www.ctan.org/tex-archive/help/Catalogue/entries/hyperref.html">hyperref</ulink> package by Sebastian Rahtz<indexterm><primary>Rahtz</primary></indexterm> und Heiko Oberdiek<indexterm><primary>Oberdiek</primary></indexterm> expands the cross-referencing <indexterm><primary>cross-referencing</primary></indexterm>capabilities of <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>introducing \special commands that can be interpreted <indexterm><primary>interpreted</primary></indexterm>by a driver (like pdfjadetex) to produce hypertext <indexterm><primary>hypertext</primary></indexterm>links to places in the same document <indexterm><primary>document</primary></indexterm>(cross-references), other PDF <indexterm><primary>PDF</primary></indexterm>documents, or even WWW <indexterm><primary>WWW</primary></indexterm>pages.</para><para>We pass options to the hyperref <indexterm><primary>hyperref</primary></indexterm>package in the <ulink url="jadetex.cfg">jadetex.cfg</ulink> configuration file. Either the classic \usepackage, or the new \ hypersetup <indexterm><primary>hypersetup</primary></indexterm>command can be used for this purpose. I use the latter. If you use the \ usepackage <indexterm><primary>usepackage</primary></indexterm>method, you should always specify the driver like in</para><screen><![CDATA[\usepackage[pdftex]{hyperref}
]]></screen><para>In addition to the base URL,<indexterm><primary>URL</primary></indexterm> author, title, subject and keywords <indexterm><primary>keywords</primary></indexterm>(which you have already set up correctly in <xref linkend="jadetex_cfg">), there are a lot of other options that can be set in <ulink url="jadetex.cfg">jadetex.cfg</ulink> (see <ulink url="http://www.ibnm.uni-hannover.de/Mitarbeiter/beuerman/LaTeX2PDF.pdf">Erstellung von pdf-Dokumenten mit LaTeX</ulink> (in german) ):</para><itemizedlist><listitem><para>open settings:</para><itemizedlist><listitem><para>pdfpagemode: Determines how the document <indexterm><primary>document</primary></indexterm>will open in Acrobat®.<indexterm><primary>Acrobat®</primary></indexterm> If no mode is explicitly chosen, but the bookmarks <indexterm><primary>bookmarks</primary></indexterm>option is set, UseOutlines<indexterm><primary>UseOutlines</primary></indexterm> is used.</para><itemizedlist><listitem><para>None</para></listitem><listitem><para>UseThumbs: show thumbnails.<indexterm><primary>thumbnails</primary></indexterm></para></listitem><listitem><para>UseOutlines: show bookmarks.<indexterm><primary>bookmarks</primary></indexterm> </para></listitem><listitem><para>FullScreen</para></listitem></itemizedlist></listitem><listitem><para>pdfstartpage: Determines on which page the PDF <indexterm><primary>PDF</primary></indexterm>document is opened. </para></listitem><listitem><para>pdfstartview: FitB <indexterm><primary>FitB</primary></indexterm>or FitH:<indexterm><primary>FitH</primary></indexterm> Set the startup page view. </para></listitem></itemizedlist></listitem><listitem><para>paper size settings: The keywords <indexterm><primary>keywords</primary></indexterm>for paper <indexterm><primary>paper</primary></indexterm>size may directly appear in the hypersetup <indexterm><primary>hypersetup</primary></indexterm>command, since they are boolean variables. (draft=true is equivalent to draft.) . An overview of the possible settings is presented in <xref linkend="tab-paper-sizes">.</para><para><table id="tab-paper-sizes"><title>Paper sizes with hyperref</title><tgroup cols="2" colsep="1" rowsep="1">
<colspec colname="col0" align="center">
<colspec colname="col1" align="center">
<tbody>
<row>
<entry align="center" valign="top"><para>Paper size option</para></entry>
<entry align="center" valign="top"><para>Meaning</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>draft</para></entry>
<entry align="center" valign="top"><para>all hypertext options are turned off</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>debug</para></entry>
<entry align="center" valign="top"><para>extra diagnostic messages are printed in the log file</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>a4paper</para></entry>
<entry align="center" valign="top"><para>210mm x 297mm</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>a5paper</para></entry>
<entry align="center" valign="top"><para>148mm x 210mm</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>b5paper</para></entry>
<entry align="center" valign="top"><para>176mm x 250mm</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>letterpaper</para></entry>
<entry align="center" valign="top"><para>8.5in x 11in</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>legalpaper</para></entry>
<entry align="center" valign="top"><para>8.5in x 14in</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>executivepaper</para></entry>
<entry align="center" valign="top"><para>7.25in x 10.5in</para></entry>
</row>
</tbody>
</tgroup></table></para></listitem></itemizedlist><para>The breaklinks option enables breaking of long hypertext <indexterm><primary>hypertext</primary></indexterm>links across lines, the linktopage <indexterm><primary>linktopage</primary></indexterm>option has the effect that only the page number (and not the chapter/section text) links to the relevant chapter or section. All possible link colour <indexterm><primary>colour</primary></indexterm>options are shown in <xref linkend="tab-link-colours">. The frenchlinks <indexterm><primary>frenchlinks</primary></indexterm>option differentiates links from the rest of the text not through colours, but through small caps instead.</para><para><table id="tab-link-colours"><title>Link colours with hyperref</title><tgroup cols="3" colsep="1" rowsep="1">
<colspec colname="col0" align="center">
<colspec colname="col1" align="center">
<colspec colname="col2" align="center">
<tbody>
<row>
<entry align="center" valign="top"><para>Option</para></entry>
<entry align="center" valign="top"><para>Standard colour</para></entry>
<entry align="center" valign="top"><para>Meaning</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>linkcolor</para></entry>
<entry align="center" valign="top"><para>red</para></entry>
<entry align="center" valign="top"><para>internal links</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>anchorcolor</para></entry>
<entry align="center" valign="top"><para>black</para></entry>
<entry align="center" valign="top"><para>anchors</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>citecolor</para></entry>
<entry align="center" valign="top"><para>green</para></entry>
<entry align="center" valign="top"><para>citations</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>filecolor</para></entry>
<entry align="center" valign="top"><para>magenta</para></entry>
<entry align="center" valign="top"><para>links to files</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>menucolor</para></entry>
<entry align="center" valign="top"><para>red</para></entry>
<entry align="center" valign="top"><para>links to Acrobat® menus</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>pagecolor</para></entry>
<entry align="center" valign="top"><para>red</para></entry>
<entry align="center" valign="top"><para>links to page numbers</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>urlcolor</para></entry>
<entry align="center" valign="top"><para>cyan</para></entry>
<entry align="center" valign="top"><para>links to WWW pages</para></entry>
</row>
</tbody>
</tgroup></table></para><para>See <ulink url="http://www.ibnm.uni-hannover.de/Mitarbeiter/beuerman/LaTeX2PDF.pdf">Erstellung von pdf-Dokumenten mit LaTeX</ulink> for more PDF <indexterm><primary>PDF</primary></indexterm>options.</para></sect2>
<sect2 id="explain-hyphenation"><title>Hyphenation </title><para>If pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>encounters a word it does not know how to hyphenate, the word is skipped! In the following example from <ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/fixingproblems.html">Customizing Document Production</ulink>, the french words savoir <indexterm><primary>savoir</primary></indexterm>or évolution were problematical. </para><para>The error log file contained the following lines:</para><screen><![CDATA[Overfull \hbox (3.64668pt too wide) in paragraph at lines
]]><![CDATA[249?256 \T1/ptm/m/n/11 plusiers resources liées á linux-mandrake. Si vous souhaitez en savoir
]]></screen><para>This message tells us that pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>does not know how to hyphenate savoir,<indexterm><primary>savoir</primary></indexterm> consequently it is skipped. In order for pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>to correctly format lines, we must ensure that hyphenation <indexterm><primary>hyphenation</primary></indexterm>is explicitly activated <indexterm><primary>activated</primary></indexterm>using the command \def\Hyphenate{1 } in <ulink url="jadetex.cfg">jadetex.cfg</ulink> and, in addition, that the text is justified (\def\Quadding{justify}). But, in addition, we must explicitly set the language in order to activate the correct hyphenation <indexterm><primary>hyphenation</primary></indexterm>module (with \def\Language{UK}).</para><para>Internet addresses can become quite long, even longer than a single line. jadetex <indexterm><primary>jadetex</primary></indexterm>doesn't hyphenate them properly. Actually, no hyphenation <indexterm><primary>hyphenation</primary></indexterm>rule prevents it from inserting a hyphen after the double slash. The url package was developed by Donald Arseneau to solve these problems. To use it, you must tell jadetex <indexterm><primary>jadetex</primary></indexterm>to load it. You do this by inserting the following in the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file (see <xref linkend="jadetex_cfg"> and <xref linkend="explain-configuring-pdfjadetex"> for more on jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg):</para><screen><![CDATA[\usepackage{url}
]]></screen><para>We must also ensure that openjade <indexterm><primary>openjade</primary></indexterm>properly transforms the &lt;ulink&gt; and &lt;filename&gt; elements into jadetex <indexterm><primary>jadetex</primary></indexterm>commands. See <xref linkend="explain-links-to-sites"> for more on this.</para></sect2>
<sect2 id="explain-bookmarks"><title>Bookmarks </title><para>Bookmarks are a navigation aid for the Acrobat® <indexterm><primary>Acrobat®</primary></indexterm>Reader. They are a tree-like <indexterm><primary>tree-like</primary></indexterm>structure that reflects the chapter/section structure of the document.<indexterm><primary>document</primary></indexterm> The nodes of the tree are the chapter/section texts, which link directly to the respective chapter/section. The behaviour <indexterm><primary>behaviour</primary></indexterm>of bookmarks <indexterm><primary>bookmarks</primary></indexterm>can be customised with the following commands (since they are boolean variables, they can appear directly in the hypersetup<indexterm><primary>hypersetup</primary></indexterm> command, e.g. to switch it explicitly off, use e.g. bookmarksopen=false):</para><itemizedlist><listitem><para>bookmarks: bookmarks <indexterm><primary>bookmarks</primary></indexterm>are created even if the \ tableofcontents <indexterm><primary>tableofcontents</primary></indexterm>command is not present. </para></listitem><listitem><para>bookmarksopen: Expand all bookmarks.<indexterm><primary>bookmarks</primary></indexterm> </para></listitem><listitem><para>bookmarksnumbered: <indexterm><primary>bookmarksnumbered:</primary></indexterm>Include section numbers <indexterm><primary>numbers</primary></indexterm>in bookmarks.<indexterm><primary>bookmarks</primary></indexterm></para></listitem><listitem><para>bookmarksopenlevel: The maximal tree depth of bookmarks <indexterm><primary>bookmarks</primary></indexterm>to open</para></listitem></itemizedlist></sect2>
<sect2 id="explain-PDF-view-options"><title>PDF view options </title><para>The most important options regarding PDF <indexterm><primary>PDF</primary></indexterm>view options are shown in <xref linkend="tab-PDF-view-options">. They are set in <ulink url="jadetex.cfg">jadetex.cfg</ulink> with the hypersetup <indexterm><primary>hypersetup</primary></indexterm>command.</para><para><table id="tab-PDF-view-options"><title>PDF view options</title><tgroup cols="3" colsep="1" rowsep="1">
<colspec colname="col0" align="left">
<colspec colname="col1" align="left">
<colspec colname="col2" align="left">
<tbody>
<row>
<entry align="left" valign="top"><para>PDF view option </para></entry>
<entry align="left" valign="top"><para>Meaning</para></entry>
<entry align="left" valign="top"><para>Values</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfcenterwindow</para></entry>
<entry align="left" valign="top"><para>Center the window of the document</para></entry>
<entry align="left" valign="top"><para>false, true</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdffitwindow</para></entry>
<entry align="left" valign="top"><para>Fit document window to the first document page</para></entry>
<entry align="left" valign="top"><para>false, true</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfhighlight</para></entry>
<entry align="left" valign="top"><para>How to highlight a link button when pressed</para></entry>
<entry align="left" valign="top"><para>/I (Inversion), /N (No effect), /O (Outline), /P (Pressed)</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfmenubar</para></entry>
<entry align="left" valign="top"><para>Show menu bar</para></entry>
<entry align="left" valign="top"><para>false, true</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfnewwindow</para></entry>
<entry align="left" valign="top"><para>Open the document in a new window</para></entry>
<entry align="left" valign="top"><para>false, true</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfpagelabels</para></entry>
<entry align="left" valign="top"><para>Show logical labels, instead of page numbers (use only in \usepackage)</para></entry>
<entry align="left" valign="top"><para>false, true</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfpagelayout</para></entry>
<entry align="left" valign="top"><para>Controls the page layout upon opening of the document</para></entry>
<entry align="left" valign="top"><para>SinglePage (default), OneColumn, TwoColumnLeft, TwoColumnRight</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfpagemode</para></entry>
<entry align="left" valign="top"><para>Specifies how to open the document</para></entry>
<entry align="left" valign="top"><para>None (default), UseThumbs, UseOutlines, FullScreen</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfstartpage</para></entry>
<entry align="left" valign="top"><para>Specifies the opening page of the document</para></entry>
<entry align="left" valign="top"><para>1 (default), other page number</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdfstartview</para></entry>
<entry align="left" valign="top"><para>Specifies opening size</para></entry>
<entry align="left" valign="top"><para>FitH, FitB, </para></entry>
</row>
<row>
<entry align="left" valign="top"><para>pdftoolbar</para></entry>
<entry align="left" valign="top"><para>Show viewer's toolbar</para></entry>
<entry align="left" valign="top"><para>false, true</para></entry>
</row>
<row>
<entry align="left" valign="top"><para>plainpages</para></entry>
<entry align="left" valign="top"><para>Page anchors as arabic numbers</para></entry>
<entry align="left" valign="top"><para>false, true</para></entry>
</row>
</tbody>
</tgroup></table></para><para>See <ulink url="http://www.ibnm.uni-hannover.de/Mitarbeiter/beuerman/LaTeX2PDF.pdf">Erstellung von pdf-Dokumenten mit LaTeX</ulink> for more PDF <indexterm><primary>PDF</primary></indexterm>options.</para></sect2>
<sect2 id="explain-links-to-sites"><title>Links to internet sites </title><para>The url package enables the use of URL <indexterm><primary>URL</primary></indexterm>links in the PDF <indexterm><primary>PDF</primary></indexterm>document and takes care of their hyphenation.<indexterm><primary>hyphenation</primary></indexterm> To use it, you must tell jadetex <indexterm><primary>jadetex</primary></indexterm>to load it. You do this by inserting the following in the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file (see also <xref linkend="jadetex_cfg">):</para><screen><![CDATA[\usepackage{url}
]]></screen><para>We must also ensure that openjade <indexterm><primary>openjade</primary></indexterm>properly transforms the &lt;ulink&gt; and &lt;filename&gt; elements into jadetex <indexterm><primary>jadetex</primary></indexterm>commands. For the &lt;ulink&gt; element,<indexterm><primary>element</primary></indexterm> we want openjade <indexterm><primary>openjade</primary></indexterm>to copy the text found between the two tags and within parentheses, i.e. the address given in the id attribute.<indexterm><primary>attribute</primary></indexterm></para><para>In order to do this, we use the customization <indexterm><primary>customization</primary></indexterm>as described by Pascal Lo Ré in <ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/fixingproblems.html">Customizing Document Production</ulink>: we create a sosofo <indexterm><primary>sosofo</primary></indexterm>of type formatting-instruction.<indexterm><primary>formatting-instruction</primary></indexterm> We added a new flow-object <indexterm><primary>flow-object</primary></indexterm>to those already defined in the DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets: </para><screen><![CDATA[;;  Inserted in order to be able to get URLs in PDF documents.
]]><![CDATA[;;  Adapted from manual-print.dsl of <productname>Mandrake</productname>.
]]><![CDATA[;; Include the flow object class "formatting-instruction" : ONLY for Jade
]]><![CDATA[(declare-flow-object-class formatting-instruction
]]><![CDATA[       "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction")
]]></screen><para>This addition allows us to insert arbitrary, non-formatted text into the output file. Then we can insert suitable <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>instructions into the intermediate output. This new flow-object <indexterm><primary>flow-object</primary></indexterm>is called formatting-instruction.<indexterm><primary>formatting-instruction</primary></indexterm> The usage syntax of formatting-instruction <indexterm><primary>formatting-instruction</primary></indexterm>is as follows:</para><screen><![CDATA[(make formatting-instruction data:
]]><![CDATA["text-to-be-output")
]]></screen><para>The value of the data variable is inserted into the output file. Note that the &ldquo;\&rdquo; character must be escaped <indexterm><primary>escaped</primary></indexterm>with an addition '\'. For example, in order to insert the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>function,\penalty, you would use the following:</para><screen><![CDATA[(make formatting-instruction data:
]]><![CDATA["\\penalty")
]]></screen><para>Now, in order to get hypertext <indexterm><primary>hypertext</primary></indexterm>links in PDF,<indexterm><primary>PDF</primary></indexterm> the ulink element <indexterm><primary>element</primary></indexterm>is redefined in <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink> with the help of formatting-instruction <indexterm><primary>formatting-instruction</primary></indexterm>(see <ulink url="http://www.jclark.com/jade/transform.htm">Using Jade for SGML transformations</ulink> for the class <indexterm><primary>class</primary></indexterm>&quot;formatting-instruction&quot;<indexterm><primary>formatting-instruction</primary></indexterm> and <xref linkend="DSSSL-stylesheets"> and <xref linkend="explain-DSSSL-stylesheets"> for the <ulink url="lyxtox-print.dsl">lyxtox-print.dsl</ulink> file):</para><screen><![CDATA[;; *** URLs ***
]]><![CDATA[;; Original : dblink.dsl
]]><![CDATA[(element ulink
]]><![CDATA[ (sosofo-append
]]><![CDATA[  ;; If you allow process-children here, you will get the text printed once more!
]]><![CDATA[  ;; (process-children)             ;; Write the text with its format (anchor in HTML)
]]><![CDATA[  (make formatting-instruction      ;; Write : " \href{" + theUrl + "}{" + theText + "}"
]]><![CDATA[    data: (string-append " \\href{" (attribute-string (normalize "url")) "}{" (data-of (current-node)) "}")
]]><![CDATA[  )
]]><![CDATA[ )
]]><![CDATA[)
]]></screen><para>The text to be edited is accessed by <emphasis>data-of (current-node)</emphasis>. Because this text requires special formatting <indexterm><primary>formatting</primary></indexterm>(italics?), we must call the <emphasis>(process-children)</emphasis> function. The address is returned by <emphasis> attribute-string <indexterm><primary>attribute-string</primary></indexterm>(normalize &ldquo;url&rdquo;)</emphasis>. To construct the string, we concatenate using the command <emphasis>string-append</emphasis>, and assign the result to data in the sosofo.<indexterm><primary>sosofo</primary></indexterm> This nicely produces hypertext <indexterm><primary>hypertext</primary></indexterm>links in PDF.<indexterm><primary>PDF</primary></indexterm></para><para>However, the &lt;ulink&gt; element <indexterm><primary>element</primary></indexterm>is not only used for URLs, but also for the index generation (see <xref linkend="explain-index">). Since we redefined it above, it is going to be used for the index too (remember, the changes you do in the stylesheets, as discussed in <xref linkend="explain-DSSSL-stylesheets">, will take precedence over the defaults). We thus have to copy the code from dbindex.dsl <indexterm><primary>dbindex.dsl</primary></indexterm>for &lt;ulink&gt; elements that are children of &lt;primaryie&gt;, &lt;secondaryie&gt; or &lt;tertiaryie&gt;, which is the case for the index:</para><screen><![CDATA[;; These three elements are from "dbindex.dsl".
]]><![CDATA[;; Must be placed here because of the redifinition of "ulink".
]]><![CDATA[;; Otherwise the Index entries will point to HTML files,
]]><![CDATA[;; instead of page numbers.
]]><![CDATA[(element (primaryie ulink)
]]><![CDATA[  (indexentry-link (current-node)))
]]><![CDATA[(element (secondaryie ulink)
]]><![CDATA[  (indexentry-link (current-node)))
]]><![CDATA[(element (tertiaryie ulink)
]]><![CDATA[  (indexentry-link (current-node)))
]]></screen></sect2>
<sect2 id="explain-thumbnails"><title>Thumbnails </title><para>The thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>package by Heiko Oberdiek<indexterm><primary>Oberdiek</primary></indexterm> installs the <application>Perl</application> program thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>on your system. With the help of thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>and Ghostscript <indexterm><primary>Ghostscript</primary></indexterm>(which should also be installed), you can create thumbnails <indexterm><primary>thumbnails</primary></indexterm>for the PDF <indexterm><primary>PDF</primary></indexterm>document (to be seen when you click on the &ldquo;thumbnails&rdquo; register card in Acrobat® <indexterm><primary>Acrobat®</primary></indexterm>Reader). Thumbnails are embedded <indexterm><primary>embedded</primary></indexterm>images of the document's pages, drawn in small size and resolution.<indexterm><primary>resolution</primary></indexterm> Their purpose is to facilitate navigation through the document <indexterm><primary>document</primary></indexterm>(of course only if the PDF <indexterm><primary>PDF</primary></indexterm>viewer supports them).</para><para>You need at least Ghostscript <indexterm><primary>Ghostscript</primary></indexterm>5.50 in order to be able to use thumbpdf.<indexterm><primary>thumbpdf</primary></indexterm> You need to declare its use in the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file (see <xref linkend="jadetex_cfg"> and <xref linkend="explain-configuring-pdfjadetex">) as follows:</para><screen><![CDATA[\usepackage[pdftex]{thumbpdf}
]]></screen><para>The PDF <indexterm><primary>PDF</primary></indexterm>document with thumbnails <indexterm><primary>thumbnails</primary></indexterm>is created in a three-pass <indexterm><primary>three-pass</primary></indexterm>process: </para><orderedlist><listitem><para>The PDF <indexterm><primary>PDF</primary></indexterm>file without thumbnails <indexterm><primary>thumbnails</primary></indexterm>is created first.</para></listitem><listitem><para>thumbpdf <indexterm><primary>thumbpdf</primary></indexterm>is called and given as argument the basename <indexterm><primary>basename</primary></indexterm>of the PDF <indexterm><primary>PDF</primary></indexterm>file. It creates the thumbnails <indexterm><primary>thumbnails</primary></indexterm>in a file with the same basename <indexterm><primary>basename</primary></indexterm>and the ending .tpt.</para></listitem><listitem><para>The PDF <indexterm><primary>PDF</primary></indexterm>file is created again. Through the \ usepackage <indexterm><primary>usepackage</primary></indexterm>instruction above, pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>searches for a .tpt file in the current directory and uses it to embed <indexterm><primary>embed</primary></indexterm>the thumbnails <indexterm><primary>thumbnails</primary></indexterm>in the PDF <indexterm><primary>PDF</primary></indexterm>file.</para></listitem></orderedlist><para>If the parameter <indexterm><primary>parameter</primary></indexterm>use_coolthumbs is set to 1 in lyxtox <indexterm><primary>lyxtox</primary></indexterm>(that's currently the default), the thumbnails <indexterm><primary>thumbnails</primary></indexterm>will be generated using the coolthumbs script (see <xref linkend="coolthumbs">), which in turn will call The GIMP to create smooth, anti-aliased thumbnails.<indexterm><primary>thumbnails</primary></indexterm> See the <ulink url="http://www.ringlord.com/publications/latex-pdf-howto">Linux LaTeX-PDF HOW-TO</ulink> for the details of the inner workings of coolthumbs.</para><para>See also <xref linkend="explain-document-creation-PDF"> for the PDF <indexterm><primary>PDF</primary></indexterm>document creation process.</para></sect2>
<sect2 id="explain-configuring-pdfjadetex"><title>Configuring pdfjadetex </title><para>The file <ulink url="jadetex.cfg">jadetex.cfg</ulink> is used whenever you want to override jadetex's or pdfjadtex's default behavior. This file just goes in the current working directory (i.e. where jadetex <indexterm><primary>jadetex</primary></indexterm>is being run from). It seems that pretty much any <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code can go in there, but here are some common things. </para><itemizedlist><listitem><para>The <ulink url="http://www.ctan.org/tex-archive/help/Catalogue/entries/hyperref.html">hyperref</ulink> package expands the cross-referencing <indexterm><primary>cross-referencing</primary></indexterm>capabilities of <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>introducing \special commands that can be interpreted <indexterm><primary>interpreted</primary></indexterm>by a driver (like pdfjadetex) to produce hypertext <indexterm><primary>hypertext</primary></indexterm>links to places in the same document <indexterm><primary>document</primary></indexterm>(cross-references), other PDF <indexterm><primary>PDF</primary></indexterm>documents, or even WWW <indexterm><primary>WWW</primary></indexterm>pages. You declare its use in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg with</para><screen><![CDATA[\hypersetup{
]]></screen><para>inserting various options after the curly <indexterm><primary>curly</primary></indexterm>bracket. See <xref linkend="explain-hyperref">.</para></listitem><listitem><para>Two-Sided Pages: sometimes, you will want jadetex <indexterm><primary>jadetex</primary></indexterm>to start chapters on the recto <indexterm><primary>recto</primary></indexterm>side, and try to keep the total count of pages even. This is no longer the default behaviour,<indexterm><primary>behaviour</primary></indexterm> so if you want to revert to it, put the following in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg:</para><screen><![CDATA[\def\PageTwoSide{1} \def\TwoSideStartOnRight{1}
]]></screen></listitem><listitem><para>PDF Outlines (bookmarks): PDF <indexterm><primary>PDF</primary></indexterm>outlines <indexterm><primary>outlines</primary></indexterm>are a nested,<indexterm><primary>nested</primary></indexterm> tree-like <indexterm><primary>tree-like</primary></indexterm>list of the hierarchy <indexterm><primary>hierarchy</primary></indexterm>of chapters, sections, etc, each trre node being a link to the relevant chapter or section. These are displayed on the left side of Acrobat® <indexterm><primary>Acrobat®</primary></indexterm>Reader. To enable the listing of bookmarks,<indexterm><primary>bookmarks</primary></indexterm> put this in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg:<indexterm><primary>jadetex.cfg</primary></indexterm></para><screen><![CDATA[pdfpagemode=UseOutlines
]]></screen></listitem><listitem><para>If you happen to have a &quot;Citation Reference&quot; or a &quot;Cross Reference&quot; inside of a &quot;Section&quot; (for example &quot;5 The Proof <indexterm><primary>Proof</primary></indexterm>[somebook]&quot;), then you will need to give the linktocpage <indexterm><primary>linktocpage</primary></indexterm>option to pdftex,<indexterm><primary>pdftex</primary></indexterm> otherwise you will get an error when generating the Table of Contents saying </para><screen><![CDATA["pdfTeX error (ext4): link annotations can't be nested"
]]></screen><para>Put the following in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg:</para><screen><![CDATA[\usepackage[pdftex,linktocpage]{hyperref}
]]></screen></listitem><listitem><para>Computer Modern (CM) fonts:<indexterm><primary>fonts</primary></indexterm> The ae <indexterm><primary>ae</primary></indexterm>package provides virtual EC <indexterm><primary>EC</primary></indexterm>fonts based on the CM ones, so that the Type1 <indexterm><primary>Type1</primary></indexterm>CM fonts <indexterm><primary>fonts</primary></indexterm>can be used in the output file. However, not all EC <indexterm><primary>EC</primary></indexterm>characters are available in this way. The aecompl <indexterm><primary>aecompl</primary></indexterm>package defines the missing characters as bitmapped <indexterm><primary>bitmapped</primary></indexterm>fonts.<indexterm><primary>fonts</primary></indexterm> To use them you should have the following in jadetex.<indexterm><primary>jadetex</primary></indexterm>cfg:</para><screen><![CDATA[\usepackage[T1]{fontenc} 
]]><![CDATA[\usepackage{ae} 
]]><![CDATA[\usepackage{aecompl} 
]]></screen><para>In this way the output will use CM fonts <indexterm><primary>fonts</primary></indexterm>for all except some rarely used characters</para></listitem></itemizedlist></sect2>
<sect2 id="explain-further-enhancements"><title>Further enhancements </title><para>The PDF <indexterm><primary>PDF</primary></indexterm>format offers some possibilities that further enhance its use: </para><itemizedlist><listitem><para>Optimization: The document <indexterm><primary>document</primary></indexterm>can be optimized for browsing , so that it needs only be partially downloaded to be viewed.</para></listitem><listitem><para>Passwords: Using programs like pdlin <footnote><para>Download the freely available version (for Windows, <productname>Linux</productname> und Solaris) under <ulink url="http://www.pdf-tools.com/en/products_evaluation.html">http://www.pdf-tools.com/en/products_evaluation.html</ulink>; free use is limited to evaluation purposes only, though - you will need a licence for productive work.</para></footnote> you can set passwords and permissions regarding printing, changing, selecting and adding text.</para></listitem></itemizedlist><para>These enhancements are not used in my scripts, but they certainly could be incorporated if needed.</para><para>For more information on the creation on powerful PDF <indexterm><primary>PDF</primary></indexterm>documents see <ulink url="http://www.ibnm.uni-hannover.de/Mitarbeiter/beuerman/LaTeX2PDF.pdf">Erstellung von pdf-Dokumenten mit LaTeX</ulink>.</para><para>The <ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/manual-print.dsl">manual-print.dsl</ulink> file, used for the print versions of the <ulink url="http://www.linux-mandrake.com">Mandrake Linux</ulink> distribution,<indexterm><primary>distribution</primary></indexterm> contains examples of customizations <indexterm><primary>customizations</primary></indexterm>that are beyond the scope<indexterm><primary>scope</primary></indexterm> of this document,<indexterm><primary>document</primary></indexterm> but may very well be useful in a heavy production <indexterm><primary>production</primary></indexterm>environment. These include:</para><itemizedlist><listitem><para>Definition of language</para></listitem><listitem><para>Foreign text or abbreviations<indexterm><primary>abbreviations</primary></indexterm></para></listitem><listitem><para>Long titles </para></listitem><listitem><para>Glossary entries</para></listitem><listitem><para>Inline <indexterm><primary>Inline</primary></indexterm>graphics</para></listitem><listitem><para>Character fonts<indexterm><primary>fonts</primary></indexterm></para></listitem></itemizedlist><para>and other goodies that make reading of this document <indexterm><primary>document</primary></indexterm>strongly recommended for the interested reader.</para></sect2>
</sect1>
<sect1 id="optimal-PS"><title>Optimal PS</title><para>We discuss some PS-specific <indexterm><primary>PS-specific</primary></indexterm>topics here - currently only how to embed <indexterm><primary>embed</primary></indexterm>Computer Modern fonts <indexterm><primary>fonts</primary></indexterm>in a PS <indexterm><primary>PS</primary></indexterm>document.</para><sect2 id="embedding-Computer-Modern-fonts"><title>Embedding Computer Modern fonts</title><para>The reason behind embedding <indexterm><primary>embedding</primary></indexterm>the Type1 <indexterm><primary>Type1</primary></indexterm>Computer Modern fonts <indexterm><primary>fonts</primary></indexterm>in PostScript®<indexterm><primary>PostScript®</primary></indexterm> (PS) documents is the same as for PDF <indexterm><primary>PDF</primary></indexterm>ones (see <xref linkend="explain-Type-1">): the resolution <indexterm><primary>resolution</primary></indexterm>of the bitmapped <indexterm><primary>bitmapped</primary></indexterm>fonts <indexterm><primary>fonts</primary></indexterm>that are used by default by TeX/LaTeX matches that of the printer on the system you create the document.<indexterm><primary>document</primary></indexterm> This is rarely the same resolution <indexterm><primary>resolution</primary></indexterm>of the monitor or printer the reader will use. This change in resolution <indexterm><primary>resolution</primary></indexterm>results in terrible quality when displaying these fonts <indexterm><primary>fonts</primary></indexterm>on a screen. or printing it on a printer, whose resolution <indexterm><primary>resolution</primary></indexterm>does not match the one of the bitmapped <indexterm><primary>bitmapped</primary></indexterm>font. </para><tip>
<title>Tip:</title> 
<para> 
In recent TeX/LaTeX distributions, freely available Type1 versions of the CM fonts are provided. These appear under the collective name of <emphasis>bluesky</emphasis>.  The bluesky fonts can be obtained from  <ulink url="http://www.ctan.org">CTAN</ulink>, if not already installed  on your system.
</para> 
</tip>
<para>You can embed <indexterm><primary>embed</primary></indexterm>the CM fonts <indexterm><primary>fonts</primary></indexterm>in the PS <indexterm><primary>PS</primary></indexterm>document using an aproppriate printer with the -P option:</para><screen><![CDATA[PRINTER="cmz"
]]><![CDATA[export PRINTER
]]></screen><para>I use this comfortable method in the <ulink url="lyxtox">lyxtox</ulink> script. This will make dvips <indexterm><primary>dvips</primary></indexterm>(which is directly called in the current lyxtox <indexterm><primary>lyxtox</primary></indexterm>script, or indirectly called by sgmltools,<indexterm><primary>sgmltools</primary></indexterm> in older versions of lyxtox,<indexterm><primary>lyxtox</primary></indexterm> see <xref linkend="explain-document-creation-PS">) to read the configuration file config.cmz <indexterm><primary>config.cmz</primary></indexterm>(under /var/lib/texmf/dvips/config/config.cmz on my system). On my system, this file contains only one line:</para><screen><![CDATA[p +psfonts.cmz
]]></screen><para>and looking at the psfonts. cmz <indexterm><primary>cmz</primary></indexterm>file (located in /usr/share/texmf/dvips/bluesky/psfonts.cmz, notice the name &ldquo;bluesky&rdquo; in the directory path), I can see that all the necessary mappings from short names to full ones are there. Here are some lines of psfonts.cmz:</para><screen><![CDATA[cmb10           CMB10           <cmb10.pfb
]]><![CDATA[cmbsy10         CMBSY10         <cmbsy10.pfb
]]><![CDATA[cmbx10          CMBX10          <cmbx10.pfb
]]><![CDATA[cmbx12          CMBX12          <cmbx12.pfb
]]><![CDATA[cmbx5           CMBX5           <cmbx5.pfb
]]><![CDATA[cmbx6           CMBX6           <cmbx6.pfb
]]><![CDATA[cmbx7           CMBX7           <cmbx7.pfb
]]><![CDATA[cmbx8           CMBX8           <cmbx8.pfb
]]><![CDATA[cmbx9           CMBX9           <cmbx9.pfb
]]><![CDATA[cmbxsl10        CMBXSL10        <cmbxsl10.pfb
]]></screen><para>If no map file like the above can be found, you probably miss something from your distribution,<indexterm><primary>distribution</primary></indexterm> unless you installed TeX/LaTex by hand, in which case you know what you are doing and might try the following (see <ulink url="http://www.physics.ohio-state.edu/~yurh/doc/tex2pdf/localcopy/oneTeX2PDF.html">LaTeX to PDF Guide</ulink>):</para><para>Search for a file pdftex.<indexterm><primary>pdftex</primary></indexterm>map (see <xref linkend="pdftex_cfg">) in your <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>distribution <indexterm><primary>distribution</primary></indexterm>(located in /var/lib/texmf/dvips/config/pdftex.map on my system). Run a <application>Perl</application> script as follows: </para><screen><![CDATA[perl -ne '($font, @rest) = split(/ /);
]]><![CDATA[                  $uc = $font;
]]><![CDATA[                  $uc =~ tr/a-z/A-Z/;
]]><![CDATA[                  print "$font $uc @rest";
]]><![CDATA[                 ' PATH-TO-PDFTEX-MAP/pdftex.map
]]><![CDATA[                 > cm.map
]]></screen><para>The created cm.map <indexterm><primary>cm.map</primary></indexterm>file instructs dvips <indexterm><primary>dvips</primary></indexterm>to embed <indexterm><primary>embed</primary></indexterm>the Type1 <indexterm><primary>Type1</primary></indexterm>outline fonts<indexterm><primary>fonts</primary></indexterm> for the Computer Modern fonts <indexterm><primary>fonts</primary></indexterm>into the resulting PostScript® <indexterm><primary>PostScript®</primary></indexterm>file. </para><para>Add to your presonal .dvipsrc the following line </para><screen><![CDATA[p +PATH-TO-CM-MAP/cm.map 
]]></screen><para>This tells dvips <indexterm><primary>dvips</primary></indexterm>to use the font map you just created in addition to the system-wide <indexterm><primary>system-wide</primary></indexterm>configuration files.</para><para>The LyX <indexterm><primary>LyX</primary></indexterm>User's Guide (available through the menu: Help--&gt;User's Guide) contains a whole chapter devoted to the configuration of dvips <indexterm><primary>dvips</primary></indexterm>and Ghostscript <indexterm><primary>Ghostscript</primary></indexterm>for LyX <indexterm><primary>LyX</primary></indexterm>(Section 2.6, as of LyX <indexterm><primary>LyX</primary></indexterm>1.2.0), which is definitely recommended reading.</para></sect2>
</sect1>
</chapter>
<chapter id="HTML-validation"><title>HTML validation</title><para>The <ulink url="http://www.w3c.org">W3C</ulink>  is maintaining a HTML validator service at <ulink url="http://validator.w3.org/check">The W3C Validator</ulink>. If you try it using various URLs from pages on the Internet that were created using the methods described in this document (i.e. DocBook SGML, openjade etc.), you may be surprised that so many of them will return the following error from W3C when validated<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_frown.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_frown.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_frown.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_frown.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject>:</para>
<screen><![CDATA[I was not able to extract a character encoding labeling from 
]]><![CDATA[any of the valid sources for such information. Without encoding 
]]><![CDATA[information it is impossible to validate the document.
]]></screen><para>This is because their authors did not take the trouble to examine the created HTML <indexterm><primary>HTML</primary></indexterm>documents and enhance them to conform to the HTML <indexterm><primary>HTML</primary></indexterm>standards.<indexterm><primary>standards</primary></indexterm> There is, in fact, some amount of work involved, if you want your HTML<indexterm><primary>HTML</primary></indexterm> documents to obey the standards <indexterm><primary>standards</primary></indexterm>set by the W3C <indexterm><primary>W3C</primary></indexterm>- but this work too is automated in the scripts presented here! Let's have a look how this is done:</para><para>The above error from the W3C <indexterm><primary>W3C</primary></indexterm>HTML Validator <indexterm><primary>Validator</primary></indexterm>comes from the fact that the documents, as produced by openjade <indexterm><primary>openjade</primary></indexterm>and the configuration settings discussed so far, do not include something like</para><screen><![CDATA[<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
]]></screen><para>But even if they did, the all-important DOCTYPE <indexterm><primary>DOCTYPE</primary></indexterm>statement </para><screen><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
]]></screen><para>would also be missing, making validation <indexterm><primary>validation</primary></indexterm>against a HTML <indexterm><primary>HTML</primary></indexterm>DTD <indexterm><primary>DTD</primary></indexterm>impossible. This may be a deliberate &ldquo;feature&rdquo; of the tools <indexterm><primary>tools</primary></indexterm>involved in the document <indexterm><primary>document</primary></indexterm>creation chain. But it also may have its root to an option that went unnoticed by me throughout the time! If you happen to know of such an option (perhaps in the HTML<indexterm><primary>HTML</primary></indexterm> stylesheet?<indexterm><primary>stylesheet</primary></indexterm>), please don't hesitate to contact me.</para><para>The way I decided to close this gap is an idea I borrowed from Hugo van der Kooij while reading his document <indexterm><primary>document</primary></indexterm>on how to <ulink url="http://hvdkooij.xs4all.nl/docs-docbook.en.cms">setup your own docbook processing</ulink>: after the HTML <indexterm><primary>HTML</primary></indexterm>document has been created, proceed by extracting 2 parts out of it, the title part and the body <indexterm><primary>body</primary></indexterm>part, both stored in separate temporary files called title.tmp and body.<indexterm><primary>body</primary></indexterm>tmp respectively. This splitting <indexterm><primary>splitting</primary></indexterm>part is done by an <ulink url="http://www.gnu.org/software/gawk/gawk.html">awk</ulink> script called <ulink url="htmlsplit.awk">htmlsplit.awk</ulink>. You should also have created three text files </para><orderedlist><listitem><para>your replacement HTML <indexterm><primary>HTML</primary></indexterm>code up until the &lt;title&gt; tag - this is what we will call <ulink url="part1">part1</ulink>,</para></listitem><listitem><para>the title part, containing the title (or even some navigational <indexterm><primary>navigational</primary></indexterm>menu structure specific to your website, but we will not pursue it here further, see Hugo's original document <indexterm><primary>document</primary></indexterm>for this) - this is what we will call <ulink url="part2">part2</ulink>,</para></listitem><listitem><para>the footer part - which we will call <ulink url="part3">part3</ulink>.</para></listitem></orderedlist><para>Part1 looks like</para><screen><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
]]><![CDATA[<html>
]]><![CDATA[<head>
]]><![CDATA[<title>
]]></screen><para>so that is where the DOCTYPE <indexterm><primary>DOCTYPE</primary></indexterm>statement goes! Part2 <indexterm><primary>Part2</primary></indexterm>contains:</para><screen><![CDATA[</title>
]]><![CDATA[<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
]]><![CDATA[</head>
]]><![CDATA[<body bgcolor="#FFFFFF">
]]></screen><para>so there is where the encoding <indexterm><primary>encoding</primary></indexterm>information goes! I have also set the background<indexterm><primary>background</primary></indexterm> colour <indexterm><primary>colour</primary></indexterm>to fit my site's design. Part3 <indexterm><primary>Part3</primary></indexterm>contains</para><screen><![CDATA[<table width="100%">
]]><![CDATA[<tr align="center">
]]><![CDATA[<td valign="middle">
]]><![CDATA[<a href="http://validator.w3.org/check?ss=1&amp;sp=1&amp;uri=http%3A%2F%2F_DOMAIN_%2F_DIRNAME_%2F_FILENAME_">
]]><![CDATA[<img border="0" src="images/valid-html401.png" alt="Valid HTML 4.01!" height="31" width="88"></a>
]]><![CDATA[</td>
]]><![CDATA[<td valign="middle">
]]><![CDATA[<a href="http://counter.li.org">
]]><![CDATA[<img border="0" src="images/linux_user_314103.png" alt="Linux User #314103"></a>
]]><![CDATA[</td>
]]><![CDATA[<td valign="middle">
]]><![CDATA[<a href="http://www.anybrowser.org/campaign/">
]]><![CDATA[<img border="0" src="images/w3c_ab.png" alt="Best viewed with ANY browser!"></a>
]]><![CDATA[</td>
]]><![CDATA[</tr>
]]><![CDATA[</table>
]]><![CDATA[</body>
]]><![CDATA[</html>
]]></screen><para>and, as you can easily see, is a customized footer. Now we proceed to intermix all the above files in the following order into one HTML <indexterm><primary>HTML</primary></indexterm>document:</para><orderedlist><listitem><para>part1</para></listitem><listitem><para>title</para></listitem><listitem><para>part2</para></listitem><listitem><para>body</para></listitem><listitem><para>part3</para></listitem></orderedlist><para>At the end we get a HTML <indexterm><primary>HTML</primary></indexterm>document that is customized to the design of our site <emphasis>and</emphasis> can easily be checked for compliance to the HTML <indexterm><primary>HTML</primary></indexterm>standards! </para><tip>
<title>HTML Parameters and Chunking</title> 
<para>
You can achieve a similar result by setting the html-header-tags parameter accordingly in the HTML DSSSL stylesheet (<xref linkend="DSSSL-stylesheets">, <xref linkend="explain-DSSSL-stylesheets">). The html-header-tags parameter should contain a list of the the HTML HEAD tags that should be generated. The format is a list of lists, each interior list consists of  a tag name and a set of attribute/value pairs: '(("META" ("NAME" "name") ("CONTENT" "content"))).
</para>  
<screen>
<![CDATA[(define %html-header-tags%]]>
<![CDATA[ ;; What additional HEAD tags should be generated?]]>
<![CDATA[ '())]]>
</screen>
<para>
Of course, you would have to change the html-header-tags parameter in the .dsl file each time before processing a new document. You would thus need some kind of placeholders that could be identified and changed with sed to the actually needed values. However, this amounts to the same effort that we are currently investing with our method, which also substitutes various placeholders in parts 1-3. Obviously, such a flexibility must come at some cost. Feel free to experiment with the other <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/html/r1532.htm">HTML Parameters for Chunking</ulink> too!
</para>
</tip>
<para>The footer file, <ulink url="part3">part3</ulink>, deserves some extra attention, since it illustrates the kind of customization<indexterm><primary>customization</primary></indexterm> and control over your HTML <indexterm><primary>HTML</primary></indexterm>output that you can achieve with this method: it contains the HTML <indexterm><primary>HTML</primary></indexterm>code that prints three icons <indexterm><primary>icons</primary></indexterm>in a row - a W3C <indexterm><primary>W3C</primary></indexterm><ulink url="http://validator.w3.org/check">HTML validation</ulink> icon,<indexterm><primary>icon</primary></indexterm> a <ulink url="http://counter.li.org">Linux Counter</ulink> icon <indexterm><primary>icon</primary></indexterm>and an icon <indexterm><primary>icon</primary></indexterm>from the <ulink url="http://www.anybrowser.org/campaign/">"any browser" </ulink>campaign. There are three placeholders <indexterm><primary>placeholders</primary></indexterm>in the link for the HTML <indexterm><primary>HTML</primary></indexterm>validation <indexterm><primary>validation</primary></indexterm>icon:<indexterm><primary>icon</primary></indexterm> _DOMAIN_,<indexterm><primary>_DOMAIN_</primary></indexterm> _DIRNAME_ <indexterm><primary>_DIRNAME_</primary></indexterm>and _FILENAME_.<indexterm><primary>_FILENAME_</primary></indexterm> These are substituted on-the-fly <indexterm><primary>on-the-fly</primary></indexterm>(using sed one-line commands) with the domain, directory and filename respectively of the file whose footer we are currently processing:<indexterm><primary>processing</primary></indexterm></para><screen><![CDATA[$SED -e "s/_DOMAIN_/$DOMAIN/g" ${DATADIR}/part3 > part3_1.tmp
]]><![CDATA[$SED -e "s/_DIRNAME_/$1/g" part3_1.tmp > part3_2.tmp
]]><![CDATA[$SED -e "s/_FILENAME_/${BASENAME}/g" part3_2.tmp > part3.tmp
]]></screen><para>The result is an icon <indexterm><primary>icon</primary></indexterm>that, when clicked, will automatically <indexterm><primary>automatically</primary></indexterm>pass the URI<indexterm><primary>URI</primary></indexterm> of the <emphasis>current</emphasis> file to <ulink url="http://validator.w3.org/check">The W3C Validator</ulink> for HTML <indexterm><primary>HTML</primary></indexterm>validation!</para><note>
<title>Please note:</title> 
<para> 
A file containing <emphasis>graphical</emphasis> callouts (see <xref linkend="callouts"> and <xref linkend="LyX-callouts">) will NOT be validated! You will get an error saying
<screen>
document type does not allow element "IMG" here
</screen>
In fact, any HTML standard after 2.0 explicitly forbids  &lt;img&gt;  from occuring <emphasis>anywhere</emphasis> inside the parse tree of a  &lt;pre&gt; element - and that's where exactly the graphical callouts most often happen to occur! For example, the <ulink url="http://www.w3.org/TR/REC-html32">HTML 3.2 reference specification</ulink>  states: <quote>PRE has the same content model as paragraphs, excluding images and elements that produce changes in font size, e.g. IMG, BIG, SMALL, SUB, SUP and FONT</quote>. If you want your document to be fully compliant, you will have to suppress the use of graphics for the callouts by setting %callout-graphics% to false in you stylesheet:
<screen>
(define %callout-graphics%
;; Use graphics in callouts?
#f)
</screen>
</para> 
<para>
Also note that admonitions (see <xref linkend="admonitions"> and <xref linkend="LyX-admonitions">) will be positioned using valign="center", instead of the right one valign="middle", thus leading again to non validation. But this is easily corrected by the sed script <ulink url="sedscr_val">sedscr_val</ulink> that is run near the end of the <ulink url="lyxtox">lyxtox</ulink> script.
</para>
</note>
</chapter>
<chapter id="accessibility"><title>Accessibility</title><blockquote><para>A broad definition of accessibility <indexterm><primary>accessibility</primary></indexterm>covers people operating <indexterm><primary>operating</primary></indexterm>under situational limitations as well as functional limitations: </para><para><emphasis>Functional limitations</emphasis> pertain to disabilities,<indexterm><primary>disabilities</primary></indexterm> such as blindness <indexterm><primary>blindness</primary></indexterm>or limited use of the hands. Functional limitations can be visual, auditory, <indexterm><primary>auditory,</primary></indexterm>physical, or cognitive<indexterm><primary>cognitive</primary></indexterm> (which includes language and learning disabilities).</para><para><emphasis>Situational limitations</emphasis> relate to the prevailing circumstatnces, environment,<indexterm><primary>environment</primary></indexterm> or device. These limitations can affect anybody, not just people with disabilities.<indexterm><primary>disabilities</primary></indexterm> Examples include mobile devices and device limitations, such as having no mouse, or constraining circumstances, such as interacting with a web site through a computer integrated into a car's dashboard,<indexterm><primary>dashboard</primary></indexterm> wher the use of the hands and eyes is limited.</para><para>Shawn Lawton Henry, <ulink url="http://www.webaim.org/news/2002/books/glasshaus">Constructing Accessible Web Sites</ulink>.</para></blockquote><para>Something is accessible if it is able to be used by persons with disabilities.<indexterm><primary>disabilities</primary></indexterm> In the context of computing,<indexterm><primary>computing</primary></indexterm> this generally means that the software or device should be compatible <indexterm><primary>compatible</primary></indexterm>with access aids, and should be able to transform itself into a needed format (see the <ulink url="http://bobby.watchfire.com:80/bobby/html/en/glossary.jsp">Glossary of Bobby</ulink>). The efficiency <indexterm><primary>efficiency</primary></indexterm>with which information can be accessed by people with various abilities and disabilities <indexterm><primary>disabilities</primary></indexterm>ultimately determines the degree of accessibility<indexterm><primary>accessibility</primary></indexterm> - it is clear that this is a highly subjective matter. Nevertheless, various criteria <indexterm><primary>criteria</primary></indexterm>have been developed to help determine how accessible a web page is. I will follow the priorisation of accessibility <indexterm><primary>accessibility</primary></indexterm>errors as suggested by <ulink url="http://bobby.watchfire.com:80/bobby/">Bobby</ulink> in <ulink url="http://bobby.watchfire.com:80/bobby/html/en/readreport.jsp">http://bobby.watchfire.com:80/bobby/html/en/readreport.jsp</ulink>:</para><variablelist><varlistentry><term>Priority&nbsp;1&nbsp;Accessibility&nbsp;problems
</term><listitem><para>seriously affect a page's usability <indexterm><primary>usability</primary></indexterm>by people with disabilities.<indexterm><primary>disabilities</primary></indexterm> A Bobby <indexterm><primary>Bobby</primary></indexterm>Approved rating can only be granted to a site in which none of the pages contain accessibility <indexterm><primary>accessibility</primary></indexterm>errors. Bobby <indexterm><primary>Bobby</primary></indexterm>Approved status is equivalent to Conformance Level A for the Web<indexterm><primary>Web</primary></indexterm> Content Guidelines.</para></listitem></varlistentry><varlistentry><term>Priority&nbsp;2&nbsp;Accessibility&nbsp;problems
</term><listitem><para>are those which you should try to fix. Although not as vital as Priority 1 access errors, the items in this section are considered important for access. If you can pass all items in this section in addition to the Priority 1 section, including relevant User Checks, your page meets Conformance Level AA <indexterm><primary>AA</primary></indexterm>for the Web <indexterm><primary>Web</primary></indexterm>Content Guidelines. This is the preferred minimum conformance <indexterm><primary>conformance</primary></indexterm>level for an accessible site.</para></listitem></varlistentry><varlistentry><term>Priority&nbsp;3&nbsp;Accessibility&nbsp;problems
</term><listitem><para>are third-tier <indexterm><primary>third-tier</primary></indexterm>access problems which you should also consider. If you can pass all items in this section in addition to the Priority 1 and 2 sections, including relevant User Checks, your page meets Conformance Level AAA for the Web <indexterm><primary>Web</primary></indexterm>Content Guidelines.</para></listitem></varlistentry></variablelist><para>If you think this is &ldquo;fine print&rdquo; that does not have to bother you, you are wrong: no lesser than the Sydney Organizing Committee for the Olympic Games (<emphasis>SOCOG</emphasis>) thought the same and was fined to pay A$20000 in a case that was brought to an australian court - see the <ulink url="http://www.contenu.nu/socog.html">Reader's guide to Sydney Olympics accessibility complaint</ulink> for the whole story and an explanation of the court's decision, as well as <ulink url="http://www.tomw.net.au/2001/bat2001.html">Olympic Failure: A Case for Making the Web Accessible</ulink> for the web designer's point of view. </para><para>You also cannot argue that this has happened &ldquo;too far away&rdquo; from you, perhaps on another continent. The world grows together and all western <indexterm><primary>western</primary></indexterm>nations have passed legislation<indexterm><primary>legislation</primary></indexterm> that is more or less similar on this point, based on the same legal principles<indexterm><primary>principles</primary></indexterm> of unequal treatment (&ldquo;discrimination&rdquo;; &ldquo;unfavourable&rdquo; treatment) and unjustifiable hardship (&ldquo;undue&rdquo; hardship or &ldquo;burden&rdquo;). It is a matter of time until similar cases appear to the courts. I hope you understand by now the following</para><important>
<title>Important fact:</title> 
<para> 
Accessibility is NOT optional!
</para>
</important>
<para>So what can you do to improve the HTML <indexterm><primary>HTML</primary></indexterm>pages created by the tools <indexterm><primary>tools</primary></indexterm>I presented, from the accessibility <indexterm><primary>accessibility</primary></indexterm>point of view? You can pass any of your generated HTML <indexterm><primary>HTML</primary></indexterm>pages to <ulink url="http://bobby.watchfire.com/bobby/html/en/index.jsp">Bobby</ulink> for an accessibilty <indexterm><primary>accessibilty</primary></indexterm>test<footnote><para>Note, however, that Bobby itself is just an attempt at automating an accessibility test and has not evaded criticism. In <ulink url="http://contenu.nu/article.htm?id=1198">Accessible shopping</ulink>, for example, we read:</para><blockquote><para>Bobby is too primitive and unreliable and has a tendency to give false-negative results, flunking absolutely everything but the simplest text-only sites.</para></blockquote></footnote>. You will be presented with a list of errors, sorted according to priority as above. I will discuss them for a typical page that was generated with the tools<indexterm><primary>tools</primary></indexterm> I presented in the previous chapters. </para><tip>
<title>Mean tip:</title>
<para>
Not all of the accessibility errors presented in the following sections can be reproduced when testing a page that was generated with the method presented here. To get the full idea,  pass   the <ulink url="http://www.tldp.org/HOWTO/Accessibility-HOWTO/">the <productname>Linux</productname> Accessibility HOWTO</ulink> pages for a test at <ulink url="http://bobby.watchfire.com/bobby/html/en/index.jsp">Bobby</ulink>.<inlinemediaobject>   <![ %output.print.png; [   <imageobject><imagedata fileref="./images/icon_eek.png" format="PNG">   </imageobject>   ]]>   <![ %output.print.pdf; [   <imageobject><imagedata fileref="icon_eek.pdf" format="PDF" scale="65">   </imageobject>   ]]>   <![ %output.print.eps; [   <imageobject><imagedata fileref="icon_eek.eps" format="EPS">   </imageobject>    ]]>   <![ %output.print.bmp; [ <imageobject><imagedata fileref="icon_eek.bmp" format="BMP">   </imageobject>    ]]>   <textobject><phrase>eek!</phrase>   </textobject></inlinemediaobject></para></tip>
<para>For more information on accessibility,<indexterm><primary>accessibility</primary></indexterm> see <ulink url="http://bobby.watchfire.com:80/bobby/html/en/faq.jsp">the Bobby Accessibility FAQ</ulink> and the <ulink url="http://www.tldp.org/HOWTO/Accessibility-HOWTO/">the <productname>Linux</productname> Accessibility HOWTO</ulink>. </para><sect1 id="priority-1-accessibility-errors"><title>Priority 1 accessibility errors</title><para>No priority 1 accessibility <indexterm><primary>accessibility</primary></indexterm>errors seem to be there for a page that was generated with lyxtox.<indexterm><primary>lyxtox</primary></indexterm> This is good news, as it means that the pages generated this way do not pose <emphasis>serious</emphasis> obstacles to people with disabilities.<indexterm><primary>disabilities</primary></indexterm> Provided that we didn't miss anything, we can say that the pages have &ldquo; Bobby <indexterm><primary>Bobby</primary></indexterm>Approved status&rdquo;, or that they conform to Level A of the Web <indexterm><primary>Web</primary></indexterm>Content Guidelines. </para></sect1>
<sect1 id="priority-2-accessibility-errors"><title>Priority 2 accessibility errors</title><para>The explanation texts are from <ulink url="http://bobby.watchfire.com:80/bobby/">Bobby</ulink>. Clicking on any of the problems that <ulink url="http://bobby.watchfire.com:80/bobby/">Bobby</ulink> reports will produce a more detailed description of how to fix the problem. In addition to items that <ulink url="http://bobby.watchfire.com:80/bobby/">Bobby</ulink> can examine automatically,<indexterm><primary>automatically</primary></indexterm> a number of items that require manual <indexterm><primary>manual</primary></indexterm>examination are presented in the User Checks section of the Bobby <indexterm><primary>Bobby</primary></indexterm>report.</para><variablelist><varlistentry><term>Nest&nbsp;headings&nbsp;properly.
</term><listitem><para>This comes from incorrect nesting <indexterm><primary>nesting</primary></indexterm>of the H elements in the authors environment.<indexterm><primary>environment</primary></indexterm> I could not correct this, as it seems to me a stylesheet/Jade problem. Of course, you could correct it manually, or with a script, but I think it is better to correct it before it happens. </para></listitem></varlistentry></variablelist><important>
<title>Why it is bad:</title> 
<para> 
 Some users skim through a document by navigating its headings (the H1, H2, H3, H4, H5, and H6 elements). Some access aids extract the headings to create an outline of the page, allowing users to get an overview and jump quickly to a desired part. Incorrect nesting of headings will result in an incorrect outline structure which may disorient users. Screen readers rely on these tags to interpret the structure of your pages. See also <ulink url="http://diveintoaccessibility.org/day_27_using_real_headers.html">"Using real headers"</ulink> by Mark Pilgrim.
</para> 
</important>
<variablelist><varlistentry><term>Use&nbsp;a&nbsp;public&nbsp;text&nbsp;identifier&nbsp;in&nbsp;a&nbsp;DOCTYPE&nbsp;statement.
</term><listitem><para>We have corrected this already in <xref linkend="HTML-validation">. </para></listitem></varlistentry></variablelist><important>
<title>Why it is bad:</title> 
<para> 
 Include a document type declaration at the beginning of a document that refers to a published DTD (e.g., the HTML 4.01 transitional DTD). The document type declaration should be appropriate to the markup language you are using.
</para> 
</important>
</sect1>
<sect1 id="priority-3-accessibility-errors"><title>Priority 3 accessibility errors</title><variablelist><varlistentry><term>Provide&nbsp;a&nbsp;summary&nbsp;for&nbsp;tables.
</term><listitem><para>This refers to the revision history table. Again, it seems to be a stylesheet/Jade problem.</para></listitem></varlistentry><varlistentry><term>Identify&nbsp;the&nbsp;language&nbsp;of&nbsp;the&nbsp;text.
</term><listitem><para>This helps the computer or assistive device present information in a way that is appropriate to the language and also helps automatic translation software that translates text from one language into another. This should already have been fixed with the techniques of <xref linkend="HTML-validation">.</para></listitem></varlistentry></variablelist></sect1>
</chapter>
<chapter id="mathematics"><title>Mathematics</title><para>Since LyX <indexterm><primary>LyX</primary></indexterm>is a frontend <indexterm><primary>frontend</primary></indexterm>for LaTeX,<indexterm><primary>LaTeX</primary></indexterm> it is no secret that it has exceptional capabilities <indexterm><primary>capabilities</primary></indexterm>when it comes to typesetting mathematics.<indexterm><primary>mathematics</primary></indexterm> However, when it comes to transforming the .lyx document <indexterm><primary>document</primary></indexterm>to different format, the possibilities are rather limited<footnote><para>Even if the starting point is not a LyX document, the task of presenting Mathematics on the Web is not a trivial one, although (or exactly because) there is a bunch of solutions to choose from, see <ulink url="http://mathforum.org/typesetting/index.html#T">Math Typesetting for the Internet</ulink>.</para></footnote>:</para><itemizedlist><listitem><para>For HTML,<indexterm><primary>HTML</primary></indexterm> export to LaTeX <indexterm><primary>LaTeX</primary></indexterm>and then use <ulink url="http://www.latex2html.org">latex2html</ulink>. This has some disadvantages:</para><itemizedlist><listitem><para>Excessive memory usage: latex2html <indexterm><primary>latex2html</primary></indexterm>will consume a lot of memory (FIXME: is this still the case?)</para></listitem><listitem><para>Most important: We are talking about an SGML <indexterm><primary>SGML</primary></indexterm>document here and all the DocBook<indexterm><primary>DocBook</primary></indexterm> markup <indexterm><primary>markup</primary></indexterm>will be lost if you transform it back to LaTeX <indexterm><primary>LaTeX</primary></indexterm>- just think about the admonitions <indexterm><primary>admonitions</primary></indexterm>(see <xref linkend="admonitions">), callouts <indexterm><primary>callouts</primary></indexterm>(see <xref linkend="callouts">) and all the other SGML <indexterm><primary>SGML</primary></indexterm>stuff that will be impossible to transform back! </para></listitem></itemizedlist></listitem><listitem><para>For PostScript®,<indexterm><primary>PostScript®</primary></indexterm> export to LaTeX,<indexterm><primary>LaTeX</primary></indexterm> then create the .dvi file (by calling LaTeX) and then the PS <indexterm><primary>PS</primary></indexterm>file using dvips.<indexterm><primary>dvips</primary></indexterm> That's O.K., since it directly uses TeX <indexterm><primary>TeX</primary></indexterm>and the mathematics <indexterm><primary>mathematics</primary></indexterm>will be as accurately typeset as possible.</para></listitem><listitem><para>For PDF,<indexterm><primary>PDF</primary></indexterm> transform the above PostScript® <indexterm><primary>PostScript®</primary></indexterm>file to PDF <indexterm><primary>PDF</primary></indexterm>using ps2pdf,<indexterm><primary>ps2pdf</primary></indexterm> or some commercial program like the Acrobat® <indexterm><primary>Acrobat®</primary></indexterm>Distiller®.<indexterm><primary>Distiller®</primary></indexterm> Taking the roundtrip <indexterm><primary>roundtrip</primary></indexterm>to PS <indexterm><primary>PS</primary></indexterm>in order to arrive at PDF <indexterm><primary>PDF</primary></indexterm>has some serious drawbacks, though (FIXME: which ones?) After all, pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>was developed to avoid <indexterm><primary>avoid</primary></indexterm>exactly these drawbacks, so it would be nice if we could use it.</para></listitem><listitem><para>For RTF,<indexterm><primary>RTF</primary></indexterm> no way seems to exist to get mathematics <indexterm><primary>mathematics</primary></indexterm>from LyX <indexterm><primary>LyX</primary></indexterm>in this format.</para></listitem></itemizedlist><para>The above is not a satisfactory situation. Even if we <emphasis>can</emphasis> get mathematics <indexterm><primary>mathematics</primary></indexterm>in some formats, we would have to abandon the SGML <indexterm><primary>SGML</primary></indexterm>framework we have been using so far. It would be nice if we could continue to write in a DocBook <indexterm><primary>DocBook</primary></indexterm>SGML <indexterm><primary>SGML</primary></indexterm>document in LyX,<indexterm><primary>LyX</primary></indexterm> using all the excellent math <indexterm><primary>math</primary></indexterm>typestting capabilities <indexterm><primary>capabilities</primary></indexterm>of TeX/LaTeX and then export to whichever of the above formats through our usual scripts and tools <indexterm><primary>tools</primary></indexterm>like openjade,<indexterm><primary>openjade</primary></indexterm> pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>etc. In fact, as the following example already shows, we can: </para><para>
<equation id="eq2"> <title>(eq2)</title>
  <alt>\begin{equation}
{\displaystyle }\int _{a}^{b}x^{2}dx=\frac{1}{3}(b-a)^{3}\label{eq2}\end{equation}
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/11182.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/11182.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/11182.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/11182.bmp">
 ]]>

 </equation></para><para>Let's see what is going on, from the SGML <indexterm><primary>SGML</primary></indexterm>point of view, when you type an equation like <xref linkend="eq2"><footnote><para>as you can see already, cross-references to equations (and with them also equation labels and titles) do work for all formats too with the method I will describe.</para></footnote> in LyX:<indexterm><primary>LyX</primary></indexterm> when exported to SGML,<indexterm><primary>SGML</primary></indexterm> this equation yelds the following MathML<indexterm><primary>MathML</primary></indexterm> code:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1025;" format="linespecific"><![CDATA[
]]></screen><para>There are some remarks due here:</para><itemizedlist><listitem><para>The <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code that typesets the equation is enclosed between the &lt;alt&gt; tags. We will make heavy use of this fact later.</para></listitem><listitem><para>The equation is again output, this time between the &lt;math&gt; tags. This is <ulink url="http://www.w3.org/Math/">MathML</ulink>.</para></listitem><listitem><para>The whole is enclosed in the DocBook <indexterm><primary>DocBook</primary></indexterm>&lt;equation&gt; tags.</para></listitem></itemizedlist><para>As you see, LyX <indexterm><primary>LyX</primary></indexterm>is already capable of producing the (excessively verbose) <ulink url="http://www.w3.org/Math/">MathML</ulink> version of our equation. However, the technologies for delivering Math <indexterm><primary>Math</primary></indexterm>on the Web <indexterm><primary>Web</primary></indexterm>through MathML<indexterm><primary>MathML</primary></indexterm> are in constant <indexterm><primary>constant</primary></indexterm>flow (see a <ulink url="http://www.mathtype.com/en/reference/webmath/status/">MathML status report</ulink>). Furthermore, my openjade <indexterm><primary>openjade</primary></indexterm>will spit dozens of errors, one for each MathML<indexterm><primary>MathML</primary></indexterm> tag. Even if I were able to eliminate <indexterm><primary>eliminate</primary></indexterm>these through the use of some extra module, it seems that the quality of the results, be it online or printed, is going to be rather dissapointing, as the following quote by Allin Cottrell<indexterm><primary>Cottrell</primary></indexterm><footnote><para>the creator of the  <ulink url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath">DBTeXMath</ulink> method that we are going to use here</para></footnote> clearly indicates:</para><blockquote><para>A dsssl <indexterm><primary>dsssl</primary></indexterm>engine such as openjade <indexterm><primary>openjade</primary></indexterm>can turn the MathML <indexterm><primary>MathML</primary></indexterm>into <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>for you but the results are likely to be disappointing, particularly if you are used to typesetting mathematics <indexterm><primary>mathematics</primary></indexterm>using <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>itself. TeX's native mathematical <indexterm><primary>mathematical</primary></indexterm>typesetting is near-perfect, only occasionally requiring manual <indexterm><primary>manual</primary></indexterm>tweaking to achieve optimal results; it is also rather comprehensive, with the aid of the AMS (American Mathematical <indexterm><primary>Mathematical</primary></indexterm>Society) extensions <indexterm><primary>extensions</primary></indexterm>if need be. But if you take the route of MathML <indexterm><primary>MathML</primary></indexterm>to <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>via dsssl <indexterm><primary>dsssl</primary></indexterm>and jade, the specifics of the math <indexterm><primary>math</primary></indexterm>typesetting must be handled by the dsssl <indexterm><primary>dsssl</primary></indexterm>stylesheet.<indexterm><primary>stylesheet</primary></indexterm> David Carlisle<indexterm><primary>Carlisle</primary></indexterm> put some work into this a few years back (for which we can be grateful), but he didn't finish the job and nobody else has done so since. Thus if you send MathML <indexterm><primary>MathML</primary></indexterm>through jade to <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>you are likely to find (a) that those elements that are recognized by the stylesheets are typeset less adeptly than by <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>itself (with clumsy-looking <indexterm><primary>clumsy-looking</primary></indexterm>spacing), while (b) various important elements may not be recognized at all. For example in my field of statistics the overbar (denoting the arithmetic mean) is a common modifier,<indexterm><primary>modifier</primary></indexterm> but it is simply ignored. Other formulations common in statistics are also ignored, or are not dealt with properly, so this route is not really usable for me.</para></blockquote><para>Allin Cottrell<indexterm><primary>Cottrell</primary></indexterm> has introduced the <ulink url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath">DBTeXMath</ulink> method, which I have slightly modified and incorporated in the method I presented so far. In the following sections I will first describe the necessary steps and software, then the explanation of the details.</para><sect1 id="DBTeXMath"><title>DBTeXMath</title><para>You probably already have almost all the necessary software installed on your system for the <ulink url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath">DBTeXMath</ulink> method to work on it, but let's have a look at it anyway:</para><itemizedlist><listitem><para>Perl: The method is heavily based on some post-processing <indexterm><primary>post-processing</primary></indexterm>done by <application>Perl</application> scripts, so <application>Perl</application> is a must. Any modern version should do, so just install the <application>Perl</application> package and the <application>Perl</application> modules of your distribution.<indexterm><primary>distribution</primary></indexterm> </para></listitem><listitem><para>The three .dsl files (stylesheets) as discussed in <xref linkend="DSSSL-stylesheets">. They already contain all necessary changes to process Mathematics,<indexterm><primary>Mathematics</primary></indexterm> so you will just need to copy them to the aproppriate locations - but you have done that already in <xref linkend="DSSSL-stylesheets">.</para></listitem><listitem><para>TeX, <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>(see <xref linkend="TeX-LaTeX">), dvips <indexterm><primary>dvips</primary></indexterm>and convert <indexterm><primary>convert</primary></indexterm>(see <xref linkend="dvips-Ghostscript-Imagemagik">) are also used heavily, but you already have installed those, didn't you?</para></listitem></itemizedlist><para>So far, you might not have to install anything additional, but the following is definitely new:</para><itemizedlist><listitem><para>The <ulink url="unescape_math.pl">unescape_math.pl</ulink> and <ulink url="texmath2pngbmp.pl">texmath2pngbmp.pl</ulink><footnote><para>The original script was called texmath2png. I added &ldquo;bmp&rdquo; to the name, because it now converts to BMP format too.</para></footnote> scripts. Please use the ones provided here and not the original ones, as I have made some changes to them. Copy them somewhere in your system, preferably in /usr/local/bin and <emphasis>make them executable</emphasis>. Adapt the <ulink url="lyxtox">lyxtox</ulink> to contain the right paths <indexterm><primary>paths</primary></indexterm>(see <xref linkend="explain-program-locations">).</para></listitem><listitem><para>The <ulink url="awkscr&amp;lowbar;math">awkscr_math</ulink> awk <indexterm><primary>awk</primary></indexterm>script in the working directory. Of course, you need awk <indexterm><primary>awk</primary></indexterm>(<xref linkend="sed-and-awk">) too, but you already needed it in <xref linkend="HTML-validation"> for the <ulink url="htmlsplit.awk">htmlsplit.awk</ulink> script.</para></listitem></itemizedlist></sect1>
<sect1 id="LyX-writing-Mathematics"><title>Writing Mathematics in LyX</title><para>You write Mathematics <indexterm><primary>Mathematics</primary></indexterm>in LyX <indexterm><primary>LyX</primary></indexterm>just as you would write it anyway, i.e. as if it were going to be processed by TeX <indexterm><primary>TeX</primary></indexterm>and not Jade.<indexterm><primary>Jade</primary></indexterm> The whole combined power of TeX/LaTeX/LyX lies at your fingertips! <indexterm><primary>fingertips!</primary></indexterm>So let 's try some math <indexterm><primary>math</primary></indexterm>here! This is a numbered displayed equation:</para><para>
<equation id="eq3"> <title>(eq3)</title>
  <alt>\begin{equation}
f(x)=\left\{ \begin{array}{cc}
 \log _{8}x & x &gt; 0\\
 0 & x=0\\
 \sum _{i=1}^{5}\alpha _{i}+\sqrt{-\frac{1}{x}} & x &lt; 0\end{array}
\right.\label{eq3}\end{equation}
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/17115.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/17115.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/17115.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/17115.bmp">
 ]]>

 </equation></para><para>An example of an unnumbered equation:</para><para>
<equation id="eq4"> <title>(eq4)</title>
  <alt>\[
\int _{-\infty }^{\infty }\frac{dx}{1+x^{2}}=\pi \]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/11320.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/11320.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/11320.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/11320.bmp">
 ]]>

 </equation></para><para>And here is an example of an inline <indexterm><primary>inline</primary></indexterm>formula: 
 <inlineequation>
  <alt>$
\sum _{n=0}^{\infty }\frac{1}{n!}=e$
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/14398.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/14398.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/14398.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/14398.bmp">
 ]]>

 </inlineequation>, or again 
 <inlineequation>
  <alt>$
\int _{a}^{x}f(t)dt:=F(x)$
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/17828.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/17828.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/17828.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/17828.bmp">
 ]]>

 </inlineequation>.</para><para>This is a partially numbered displayed equation:</para><para>
<equation id="eq5"> <title>(eq5)</title>
  <alt>\begin{eqnarray}
1 & = & 4-3\label{mathed:fourth-eqn}\\
2 & = & 7-5\\
1 & = & e^{2\pi i}\nonumber \\
16 & \equiv  & 2\, (mod\, 7)\label{mathed:fifth-eqn}
\end{eqnarray}
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/12302.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/12302.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/12302.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/12302.bmp">
 ]]>

 </equation></para><para>while in this one all equations <indexterm><primary>equations</primary></indexterm>are numbered:</para><para>
<equation id="eq6"> <title>(eq6)</title>
  <alt>\begin{eqnarray}
1 & = & 3-2\label{mathed:second-equation}\\
2 & = & 4-2\\
4 & \leq  & 7.
\end{eqnarray}
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/19968.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/19968.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/19968.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/19968.bmp">
 ]]>

 </equation></para><para>Now, let's do some more advanced examples:</para><para>
<equation id="eq7"> <title>(eq7)</title>
  <alt>\[
f(x):=\left\{ \begin{array}{ll}
 \frac{1}{q}, & \mathrm{if}\, x=\frac{p}{q}\, (\mathrm{in}\, \mathrm{lowest}\, \mathrm{terms})\\
 0, & \mathrm{if}\, x\, \mathrm{is}\, \mathrm{irrational}\end{array}
\right.\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/10911.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/10911.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/10911.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/10911.bmp">
 ]]>

 </equation></para><para>How about these: a matrix</para><para>
<equation id="eq8"> <title>(eq8)</title>
  <alt>\[
\left(\begin{array}{ccc}
 1 & 2 & 3\\
 4 & 5 & 6\\
 7 & 8 & 9\end{array}
\right),\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/11647.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/11647.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/11647.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/11647.bmp">
 ]]>

 </equation></para><para>a partially filled matrix</para><para>
<equation id="eq9"> <title>(eq9)</title>
  <alt>\[
\left(\begin{array}{ccc}
 \lambda _{1} &  & \\
  & \ddots  & \\
  &  & \lambda _{n}\end{array}
\right),\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/13022.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/13022.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/13022.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/13022.bmp">
 ]]>

 </equation></para><para>a continued fraction</para><para>
<equation id="eq10"> <title>(eq10)</title>
  <alt>\[
\frac{1}{\left(1+\left(\frac{1}{1+\left(\frac{1}{1+x}\right)}\right)\right)},\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/14073.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/14073.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/14073.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/14073.bmp">
 ]]>

 </equation></para><para>a limit</para><para>
<equation id="eq11"> <title>(eq11)</title>
  <alt>\[
\lim _{x\rightarrow 0}f(x)=L\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/10888.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/10888.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/10888.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/10888.bmp">
 ]]>

 </equation></para><para>and some inequalities</para><para>
<equation id="eq12"> <title>(eq12)</title>
  <alt>\[
E &lt; mc^{2},\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/11407.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/11407.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/11407.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/11407.bmp">
 ]]>

 </equation></para><para>
<equation id="eq13"> <title>(eq13)</title>
  <alt>\[
a &lt; b &gt; c,\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/18446.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/18446.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/18446.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/18446.bmp">
 ]]>

 </equation></para><para>
<equation id="eq14"> <title>(eq14)</title>
  <alt>\[
a\leq b\geq c.\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/14363.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/14363.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/14363.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/14363.bmp">
 ]]>

 </equation></para><para>Here is an inline <indexterm><primary>inline</primary></indexterm>inequality, with a proof of non-negativity of relative entropy (
 <inlineequation>
  <alt>$
D(p\Vert q)\geq 0$
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/13575.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/13575.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/13575.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/13575.bmp">
 ]]>

 </inlineequation>): show that 
 <inlineequation>
  <alt>$
\ln x\leq x-1$
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/18631.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/18631.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/18631.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/18631.bmp">
 ]]>

 </inlineequation>, for 
 <inlineequation>
  <alt>$
0 &lt; x &lt; \infty .$
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/18581.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/18581.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/18581.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/18581.bmp">
 ]]>

 </inlineequation> Then observe that (here comes an inequality array):</para><para>
<equation id="eq15"> <title>(eq15)</title>
  <alt>\begin{eqnarray*}
-D(p\Vert q) & = & \sum _{x}p(x)\ln {\frac{q(x)}{p(x)}}\\
 & \leq  & \sum _{x}p(x)({\frac{q(x)}{p(x)}}-1)\\
 & \leq  & 0
\end{eqnarray*}
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/10750.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/10750.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/10750.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/10750.bmp">
 ]]>

 </equation></para><para>If you are looking at the PDF <indexterm><primary>PDF</primary></indexterm>or PS <indexterm><primary>PS</primary></indexterm>version of this document,<indexterm><primary>document</primary></indexterm> everything will look perfect, because it was typeset directly by <application>TeX</application>.<indexterm><primary>TeX</primary></indexterm> But if you are reading the HTML <indexterm><primary>HTML</primary></indexterm>or RTF <indexterm><primary>RTF</primary></indexterm>version, then you might have noticed that the equation numbering is not continuous. Rather it starts all over from (1) in each multiline equation. This is a bug of the method we use: each equation, be it inline <indexterm><primary>inline</primary></indexterm>or displayed, one line, or multi-line,<indexterm><primary>multi-line</primary></indexterm> will be processed by <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>as a separate document <indexterm><primary>document</primary></indexterm>(only for HTML <indexterm><primary>HTML</primary></indexterm>and RTF), starting the numbering from 1 over and over again. Till some <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>Guru <indexterm><primary>Guru</primary></indexterm>(anyone reading?) out there tells me how to work around this, the simplest solution for equation numbering is to follow the rules<indexterm><primary>rules</primary></indexterm> below:</para><orderedlist><listitem><para>Don't put more than one labels in a multi-line <indexterm><primary>multi-line</primary></indexterm>equation (an equation array in <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>jargon). If you absolutely need to, split the equation in two, containing only one label <indexterm><primary>label</primary></indexterm>each.</para></listitem><listitem><para>Start each equation label <indexterm><primary>label</primary></indexterm>with &ldquo;eq&rdquo;, followed by a number, like &ldquo;eq1&rdquo;, &ldquo;eq2&rdquo;, &ldquo;eq78&rdquo; etc. My scripts number each displayed equation (i.e. not the inline <indexterm><primary>inline</primary></indexterm>ones) consequtively through the whole document,<indexterm><primary>document</primary></indexterm> automatically<indexterm><primary>automatically</primary></indexterm> assigning an id and a title to them in the SGML <indexterm><primary>SGML</primary></indexterm>code. These ids and titles are always of the form &ldquo;eqxxx&rdquo; where xxx is the number of the equation and refer to the <emphasis>whole</emphasis> equation, not some line of it. On the other hand, LyX <indexterm><primary>LyX</primary></indexterm>knows only of equation labels assigned to some line of some equation. If you followed the previous rule and if you name the one and only label<indexterm><primary>label</primary></indexterm> of your equation with the &ldquo;eqxxx&rdquo; label <indexterm><primary>label</primary></indexterm>displayed in its title, then you can refer to it from LyX <indexterm><primary>LyX</primary></indexterm>like any other cross-reference <indexterm><primary>cross-reference</primary></indexterm>and everything will work perfectly!</para></listitem><listitem><para>The best way to implement the previous rule is to just process your document<indexterm><primary>document</primary></indexterm> once without any labels in equations.<indexterm><primary>equations</primary></indexterm> You will see that all versions will have concise and continuous numbering in the equation <emphasis>titles</emphasis>. You will see titles like &ldquo;Equation 11-1. (eq2)&rdquo;. The &ldquo;11-1&rdquo; comes from Jade <indexterm><primary>Jade</primary></indexterm>and means &ldquo;the first equation of chapter 11&rdquo;. The &ldquo;(eq2)&rdquo; is the title, assigned automatically <indexterm><primary>automatically</primary></indexterm>by my scripts. Now, if you want to label <indexterm><primary>label</primary></indexterm>this equation in LyX,<indexterm><primary>LyX</primary></indexterm> label <indexterm><primary>label</primary></indexterm>only one line of it (first rule) and label <indexterm><primary>label</primary></indexterm>it &ldquo;eq2&rdquo; (second rule<footnote><para>of course, you take away the quotes</para></footnote>). </para></listitem></orderedlist></sect1>
<sect1 id="magic-behind-the-math"><title>The magic behind the math</title><para>It's not the math behind the magic - so you don't have to be afraid of being drown in formulas! Just read on to delve into the details of math document processing that goes behind the scenes while you are drinking that (hopefully not cold) cup of coffee. <inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_wink.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_wink.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_wink.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_wink.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
<para>The idea behind the <ulink url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath">DBTeXMath</ulink> method used here relies on the fact that, as we saw in the code example in <xref linkend="mathematics"> above, all the TeX <indexterm><primary>TeX</primary></indexterm>code for typesetting the equation is contained between the &lt;alt&gt; tags inside the &lt;equation&gt; tags. The &lt;alt&gt; tag is somehow &ldquo;misused&rdquo; for this purpose, but we will not bother about this for the moment (see the discussion in <xref linkend="problems-of-the-DBTeXMath-method">). DBTeXMath <indexterm><primary>DBTeXMath</primary></indexterm>tweaks the stylesheets in order to let the TeX <indexterm><primary>TeX</primary></indexterm>code </para><itemizedlist><listitem><para>be processed and converted in bitmapped <indexterm><primary>bitmapped</primary></indexterm>images of PNG <indexterm><primary>PNG</primary></indexterm>and BMP <indexterm><primary>BMP</primary></indexterm>format, for HTML,<indexterm><primary>HTML</primary></indexterm> resp. RTF,<indexterm><primary>RTF</primary></indexterm> or</para></listitem><listitem><para>be processed and typeset directly for PDF <indexterm><primary>PDF</primary></indexterm>and PS.<indexterm><primary>PS</primary></indexterm></para></listitem></itemizedlist><para>The code between the &lt;math&gt; tags is completely ignored - in fact, it is deleted. The steps in more detail:</para><sect2 id="explain-SGML-math-code-correction"><title>SGML math code correction</title><para>SGML <indexterm><primary>SGML</primary></indexterm>math code as exported by LyX <indexterm><primary>LyX</primary></indexterm>is, once again, not perfect and the first step consists in correcting it, just as we did in <xref linkend="explain-runsed-sed-sedscr">. We will change the SGML <indexterm><primary>SGML</primary></indexterm>math code to fit our needs using again <ulink url="runsed">runsed</ulink> and <ulink url="sedscr">sedscr</ulink>. But this time, we are going to need an awk <indexterm><primary>awk</primary></indexterm>script too, <ulink url="awkscr&amp;lowbar;math">awkscr_math</ulink>. We'll see in <xref linkend="explain-SGML-math-solution"> why.</para><sect3 id="explain-SGML-math-problems"><title>Problems</title><para>Regarding Mathematics <indexterm><primary>Mathematics</primary></indexterm>code, there are four distinct problems in LyX' SGML:<indexterm><primary>SGML</primary></indexterm></para><orderedlist><listitem><para>LyX <indexterm><primary>LyX</primary></indexterm>produces only an &lt;alt&gt;/&lt;/alt&gt; tag pair (with the TeX <indexterm><primary>TeX</primary></indexterm>code in it) and a &lt;math&gt;/&lt;/math&gt; tag pair with the <ulink url="http://www.w3.org/Math/">MathML</ulink> representation <indexterm><primary>representation</primary></indexterm>of the equation. This is not enough. The &lt;graphic fileref=&rdquo;equationimagefile&rdquo;&gt; is missing. Openjade <indexterm><primary>Openjade</primary></indexterm>will complain that the end tag for &lt;equation&gt; was reached, but the element <indexterm><primary>element</primary></indexterm>was &ldquo;not complete&rdquo;. And of course it is right, since the &lt;alt&gt; tag was meant as a <emphasis>textual</emphasis> representation <indexterm><primary>representation</primary></indexterm>of the image (see <xref linkend="problems-of-the-DBTeXMath-method">), while the &lt;graphic&gt; tag is expected to hold the visual representation<indexterm><primary>representation</primary></indexterm> of it in the form of some image file. Clearly, we will have to create the &lt;graphic fileref=...&gt; tags from the scratch. That's the first problem.</para></listitem><listitem><para>The second problem is that LyX <indexterm><primary>LyX</primary></indexterm>exports &lt;equation&gt; even for inline <indexterm><primary>inline</primary></indexterm>equations! The right tag would be &lt;inlineequation&gt; for inline <indexterm><primary>inline</primary></indexterm>equations <indexterm><primary>equations</primary></indexterm>(see <ulink url="http://www.oreilly.com/catalog/docbook/chapter/book/inlineequation.html">inlineequation</ulink>), &lt;equation&gt; for an equation with title (see <ulink url="http://www.oreilly.com/catalog/docbook/chapter/book/equation.html">equation</ulink>) and &lt;informalequation&gt; for one without (see <ulink url="http://www.oreilly.com/catalog/docbook/chapter/book/informalequation.html">informalequation</ulink>). This is very unfortunate, because it makes all equations <indexterm><primary>equations</primary></indexterm>&ldquo;displayed&rdquo;, i.e. drawn on a separate line. That's the second problem.</para></listitem><listitem><para>The third problem is that the MathML <indexterm><primary>MathML</primary></indexterm>code it produces cannot be dealt with by openjade <indexterm><primary>openjade</primary></indexterm>(at least not with the standard modules I have on my system) and thus produces parse errors. Furthermore, we are not going to need it, since the TeX <indexterm><primary>TeX</primary></indexterm>code inside the &lt;alt&gt; tags will suffice completely for us. We will thus have to delete everything between the &lt;math&gt;/&lt;/math&gt; tags. That's the third problem.</para></listitem><listitem><para>The fourth problem regards inequalities in Math <indexterm><primary>Math</primary></indexterm>Mode. Just writing</para><para>
<equation id="eq16"> <title>(eq16)</title>
  <alt>\[
a &lt; b &gt; c\]
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/13307.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/13307.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/13307.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/13307.bmp">
 ]]>

 </equation></para><para>will produce and error</para><screen><![CDATA[E: element "B" undefined
]]></screen><para>because the parser <indexterm><primary>parser</primary></indexterm>will see the brackets around 
 <inlineequation>
  <alt>$
b$
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/17811.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/17811.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/17811.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/17811.bmp">
 ]]>

 </inlineequation> and think that it is an SGML <indexterm><primary>SGML</primary></indexterm>element.<indexterm><primary>element</primary></indexterm> That's the fourth problem.</para></listitem></orderedlist></sect3>
<sect3 id="explain-SGML-math-solution"><title>Solution</title><para>We will start with the second problem from <xref linkend="explain-SGML-math-problems"> above, since it is the only one that needs both sed and awk <indexterm><primary>awk</primary></indexterm>to be solved. It is also a nice example of a problem that cannot be solved with only one of them<footnote><para>at least not easily: we would probably need two consecutive invocations of sed, or employ some complicated branching. Contrary to my usual predilection, I chose to make it as simple as possible, rather than complex and wonderful. ;-) The next LyX release may render it obsolete anyway.</para></footnote>. In order to solve it, an observation was crucial: <indexterm><primary>crucial:</primary></indexterm>whenever a displayed equation occurs, LyX <indexterm><primary>LyX</primary></indexterm>ends the preceding line with &lt;/para&gt;&lt;para&gt;. The idea is therefore to the &lt;equation&gt; tag that follows a line ending in &lt;/para&gt;&lt;para&gt; to something different than &lt;equation&gt;, so that we can safely say that the rest of remaining &lt;equation&gt; tags denotes actually <emphasis>inline</emphasis> equations <indexterm><primary>equations</primary></indexterm>and change them accordingly. </para><para>The following code in <ulink url="sedscr">sedscr</ulink> checks if the line ends in &lt;/para&gt;&lt;para&gt; and if so, gets the next line in the pattern space (N command). It then changes the &lt;equation&gt; to &lt;informalequation&gt;<footnote><para>It doesn't matter to what you change it to, as long as it is different from &lt;equation&gt;.</para></footnote>, prints the line and deletes the pattern space completely:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1026;" format="linespecific"><![CDATA[
]]></screen><para>The rest is accomplished in the awk <indexterm><primary>awk</primary></indexterm>script <ulink url="awkscr_math">awkscr_math</ulink>. We know by now that whatever &lt;equation&gt; tags may have remained, they denote the start of inline <indexterm><primary>inline</primary></indexterm>equations.<indexterm><primary>equations</primary></indexterm> We thus change &lt;equation&gt; to &lt;inlineequation&gt; and &lt;/equation&gt; in &lt;/inlineequation&gt;, but only between &lt;equation&gt;/&lt;/equation&gt; tags. This is done by the following code in <ulink url="awkscr_math">awkscr_math</ulink>:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1027;" format="linespecific"><![CDATA[
]]></screen><para>Finally, we can transform whatever &lt;informalequation&gt; tags remain back to &lt;equation&gt;:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1028;" format="linespecific"><![CDATA[
]]></screen><para>By the way, we also did something that is impossible to do in sed: we added a dynamic id and title, both composed of the string &ldquo;eq&rdquo; and a dynamically increased counter. The id is the same as the &ldquo;label&rdquo; in LyX,<indexterm><primary>LyX</primary></indexterm> the title is what will be displayed in the equation title. By letting the title be equal to the id, we are able to see what id an equation has in the SGML <indexterm><primary>SGML</primary></indexterm>code (because it will be displayed in the title) and set the LyX <indexterm><primary>LyX</primary></indexterm>label <indexterm><primary>label</primary></indexterm>for that equation to be the same (see <xref linkend="LyX-writing-Mathematics">), thus making cross-refernces to equations <indexterm><primary>equations</primary></indexterm>possible<footnote><para>you can only cross-reference an equation only if you previously set a label to it, but the LyX label cannot (and will not) be exported to SGML, since it refers to a line in a possibly multi-line equation - what id should then be exported to SGML form an equation with three lines, all carrying a label in LyX? </para></footnote>.</para><para>The first problem, create the &lt;graphic fileref=...&gt; tags, requires a decision: which filename to take? A first idea, to use the label <indexterm><primary>label</primary></indexterm>from the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>codebetween the &lt;alt&gt; tags, as long as there is one, is not viable: what if the TeX<indexterm><primary>TeX</primary></indexterm> code describes more than one equations <indexterm><primary>equations</primary></indexterm>(an eqnarray), each one labeled with its own label?<indexterm><primary>label</primary></indexterm> I decided to use random filenames in all situations, rather than running into such problems. Due to the random part, such a substitution <indexterm><primary>substitution</primary></indexterm>calls for awk,<indexterm><primary>awk</primary></indexterm> rather than sed.</para><para>The random numbers,<indexterm><primary>numbers</primary></indexterm> which will be the filenames to use, are currently drawn between 10000 and 20000. If you want to change these limits, you can do it in the BEGIN part of <ulink url="awkscr_math">awkscr_math</ulink>:</para><screen><![CDATA[BEGIN {
]]><![CDATA[num_min = 10000
]]><![CDATA[num_max = 20000
]]><![CDATA[num_ran = 0
]]><![CDATA[num_dif = num_max - num_min
]]><![CDATA[num_eq = 0
]]><![CDATA[srand()
]]><![CDATA[}
]]></screen><para>But sometimes, this randomness <indexterm><primary>randomness</primary></indexterm>is not needed:</para><tip>
<title>How to get identical filenames for the equations from run to run</title> 
<para>
If you want the same sequence of random numbers each time you run the script (thus producing the same  filenames from run to run), you should comment the seed function srand().
</para> 
</tip>
<para>The following code creates the &lt;graphic fileref=...&gt; tag with a random filename in the fileref <indexterm><primary>fileref</primary></indexterm>attribute after the closing &lt;/alt&gt; tag:</para><screen><![CDATA[ ]]><inlinegraphic fileref="&file1029;" format="linespecific"><![CDATA[
]]></screen><para>More precisely, it substitutes &lt;/alt&gt; with something like</para><screen><![CDATA[ ]]><inlinegraphic fileref="&file1030;" format="linespecific"><![CDATA[
]]></screen><para>Some remarks: </para><itemizedlist><listitem><para>The number used for the filename (10404) is randomly generated (num_ran, in the previous code example). </para></listitem><listitem><para>The directory for the images of the equations <indexterm><primary>equations</primary></indexterm>is images/math. If you need to change it, you will have to do so everywhere in <ulink url="awkscr_math">awkscr_math</ulink>.</para></listitem><listitem><para>We make again use of the output.print.xxx <indexterm><primary>output.print.xxx</primary></indexterm>entities <indexterm><primary>entities</primary></indexterm>to denote code that has to be IGNOREd or INCLUDEd , depending on the format we are rendering,<indexterm><primary>rendering</primary></indexterm> see <xref linkend="explain-figures"> and <xref linkend="explain-runsed-sed-sedscr">.</para></listitem><listitem><para>We specify a PNG <indexterm><primary>PNG</primary></indexterm>file even for PDF <indexterm><primary>PDF</primary></indexterm>and PS <indexterm><primary>PS</primary></indexterm>processing.<indexterm><primary>processing</primary></indexterm> That's not important. These formats will not take into account the &lt;graphic&gt; element <indexterm><primary>element</primary></indexterm>when processed (the stylesheets will take care of this). Nevertheless, we must put a &lt;graphic&gt; tag with some filename there, otherwise openjade <indexterm><primary>openjade</primary></indexterm>will complain.</para></listitem><listitem><para>The important information is that the file 10404.png shall be used to display the equation when the output.print.png <indexterm><primary>output.print.png</primary></indexterm>entity is included (i.e. only in HTML) and that 10404.bmp shall be used when the output.print.bmp <indexterm><primary>output.print.bmp</primary></indexterm>entity<indexterm><primary>entity</primary></indexterm> is included (i.e. only in RTF).</para></listitem></itemizedlist><para>The above substitution <indexterm><primary>substitution</primary></indexterm>takes place in the following 4 situations (which cover all math <indexterm><primary>math</primary></indexterm>situations in LyX' SGML) in <ulink url="awkscr_math">awkscr_math</ulink>:</para><itemizedlist><listitem><para>Between &ldquo;&lt;alt&gt;\[&rdquo; and &ldquo;&lt;/alt&gt;&rdquo;.</para></listitem><listitem><para>Between &ldquo;&lt;alt&gt;$&rdquo; and &ldquo;&lt;/alt&gt;&rdquo;.</para></listitem><listitem><para>Between &ldquo;&lt;alt&gt;\begin{equation}&rdquo; and &ldquo;&lt;/alt&gt;&rdquo;.</para></listitem><listitem><para>Between &ldquo;&lt;alt&gt;\begin{eqnarray}&rdquo; and &ldquo;&lt;/alt&gt;&rdquo;.</para></listitem></itemizedlist><para>This solves our first problem.</para><para>While we are at it, we substitute the &ldquo;&lt;&rdquo; and &ldquo;&gt;&rdquo; symbols <indexterm><primary>symbols</primary></indexterm>(that appear in inequalities between the alt tags) with their SGML <indexterm><primary>SGML</primary></indexterm>entities<footnote><para>The IF statement in the code avoids the substitution for the brackets that surround the alt tags themselves.</para></footnote>:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1031;" format="linespecific"><![CDATA[
]]></screen><para>When <ulink url="texmath2pngbmp.pl">texmath2pngbmp.pl</ulink> is executed, it will see those entities <indexterm><primary>entities</primary></indexterm>and will substitute them with their numeric equivalents:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1032;" format="linespecific"><![CDATA[
]]></screen><para>This solves the fourth problem.</para><para>The third problem is easier solved: the following code in <ulink url="awkscr&amp;lowbar;math">awkscr_math</ulink> will substitute everything between &lt;math&gt; and &lt;/math&gt; with the empty string (thus creating an empty line):</para><screen><![CDATA[]]><inlinegraphic fileref="&file1033;" format="linespecific"><![CDATA[
]]></screen><para>That empty lines do not get printed, is easily seen from the last code block in <ulink url="awkscr_math">awkscr_math</ulink>:</para><screen><![CDATA[!/^$/{
]]><![CDATA[    print
]]><![CDATA[}
]]></screen><para>which will print every line that is not empty.</para></sect3>
</sect2>
<sect2 id="explain-math-HTML-RTF"><title>HTML and RTF</title><para>The HTML <indexterm><primary>HTML</primary></indexterm>and RTF <indexterm><primary>RTF</primary></indexterm>document math <indexterm><primary>math</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>is done partially in the stylesheets<footnote><para>Both HTML stylesheets contain the same code for Mathematics.</para></footnote> (<xref linkend="DSSSL-stylesheets">) and partially in the <ulink url="texmath2pngbmp.pl">texmath2pngbmp.pl</ulink> script. </para><sect3 id="explain-math-processing-in-HTML-stylesheets"><title>Math processing in the HTML stylesheets</title><para>The following code in the HTML <indexterm><primary>HTML</primary></indexterm>stylesheets </para><screen><![CDATA[(root
]]><![CDATA[ (make sequence
]]><![CDATA[;   (literal
]]><![CDATA[;    (debug (node-property 'gi
]]><![CDATA[;                         (node-property 'document-element (current-node)))))
]]><![CDATA[;(define (docelem node)
]]><![CDATA[;  (node-propety 'document-element 
]]><![CDATA[;    (node-property 'grove-root node)))
]]><![CDATA[   (process-children)
]]><![CDATA[   (process-math)
]]><![CDATA[   (with-mode manifest
]]><![CDATA[     (process-children))
]]><![CDATA[   (if html-index
]]><![CDATA[       (with-mode htmlindex
]]><![CDATA[         (process-children))
]]><![CDATA[       (empty-sosofo))))
]]></screen><para>(found in the docbook.dsl <indexterm><primary>docbook.dsl</primary></indexterm>file of the original DocBook <indexterm><primary>DocBook</primary></indexterm>stylesheet <indexterm><primary>stylesheet</primary></indexterm>package) initiates exactly the same processing <indexterm><primary>processing</primary></indexterm>as in the standard stylesheets, with one addition: the (process-math) instruction will start an additional processing step, after the standard one. The process-math <indexterm><primary>process-math</primary></indexterm>routine is further specified in the code as follows:</para><screen><![CDATA[;; Write equation info to equation-list.sgml
]]><![CDATA[(define (process-math)
]]><![CDATA[  (make entity
]]><![CDATA[    system-id: "equation-list.sgml"
]]><![CDATA[    (make element gi: "equation-set"
]]><![CDATA[          attributes: (list
]]><![CDATA[                       (list "latexopt" $latexopt$)
]]><![CDATA[                       (list "density" $density$)
]]><![CDATA[                       (list "usepackage" $usepackage$))
]]><![CDATA[          (with-mode htmlmath (process-children)))))
]]></screen><para>This will create a new SGML <indexterm><primary>SGML</primary></indexterm>file, <ulink url="equation-list.sgml">equation-list.sgml</ulink>, in the current directory, that will contain an element <indexterm><primary>element</primary></indexterm>of type &quot;equation-set&quot;<indexterm><primary>equation-set</primary></indexterm>. That's simply a container <indexterm><primary>container</primary></indexterm>of equations <indexterm><primary>equations</primary></indexterm>and some <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>options that may be passed to it from the stylesheet:<indexterm><primary>stylesheet</primary></indexterm> it contains the <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>options in &ldquo;latexopt&rdquo;, &ldquo;density&rdquo; and &ldquo;usepackage&rdquo;, as well as the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>equation code, enclosed between &lt;texequation&gt;/&lt;/texequation&gt; tags<footnote><para>More precisely, the equation-list.sgml file is itself an SGML document, which should validate against the following DTD:</para><screen><![CDATA[<!DOCTYPE equation-set [
]]><![CDATA[<!ELEMENT equation-set - - (texequation+)>
]]><![CDATA[<!ATTLIST equation-set
]]><![CDATA[latexopt CDATA #IMPLIED
]]><![CDATA[density CDATA #IMPLIED
]]><![CDATA[usepackage CDATA #IMPLIED>
]]><![CDATA[<!ELEMENT texequation - - (#PCDATA)>
]]><![CDATA[<!ATTLIST texequation fileref CDATA #REQUIRED>
]]><![CDATA[]>
]]></screen></footnote>. Here's how the equation-list.sgml file may look like<footnote><para>You can see the equation-list.sgml file for this document here: <ulink url="equation-list.sgml">equation-list.sgml</ulink>.</para></footnote>:</para><screen><![CDATA[<equation-set
]]><![CDATA[latexopt="12pt"
]]><![CDATA[density="96x96"
]]><![CDATA[usepackage=""
]]><![CDATA[><texequation
]]><![CDATA[fileref="images/math/11074.png"
]]><![CDATA[>\[
]]><![CDATA[\sum _{n=1}^{\infty }\frac{x^{n}}{n}=\ln \left(\frac{1}{1-x}\right)\]
]]><![CDATA[  </texequation
]]><![CDATA[><texequation
]]><![CDATA[fileref="images/math/15280.png"
]]><![CDATA[>\begin{equation}
]]><![CDATA[f(x)=\left\{ \begin{array}{cc}
]]><![CDATA[ \log _{8}x &#38; x&#62;0\\
]]><![CDATA[ 0 &#38; x=0\\
]]><![CDATA[ \sum _{i=1}^{5}\alpha _{i}+\sqrt{-\frac{1}{x}} &#38; x&#60;0\end{array}
]]><![CDATA[\right.\label{eq3}\end{equation}
]]><![CDATA[  </texequation
]]><![CDATA[></equation-set
]]><![CDATA[>
]]></screen><para>How is the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code extracted from the &lt;alt&gt; elements and inserted in equation-list.sgml? This is the core work and is done by the following code in the HTML <indexterm><primary>HTML</primary></indexterm>stylesheets:</para><screen><![CDATA[;; How to write out an equation into the equation listing file
]]><![CDATA[(define (write-eqn nd)
]]><![CDATA[  (let ((texmath (select-elements (children (current-node))
]]><![CDATA[                                  (normalize "alt")))
]]><![CDATA[        (graphic (select-elements (children (current-node))
]]><![CDATA[                                  (normalize "graphic"))))
]]><![CDATA[    (make element gi: "texequation"
]]><![CDATA[          attributes:
]]><![CDATA[          (list
]]><![CDATA[           (list "fileref" (attribute-string (normalize "fileref") graphic)))
]]><![CDATA[          (literal (data texmath)))))
]]><![CDATA[;; Special processing mode to extract equations
]]><![CDATA[(mode htmlmath
]]><![CDATA[  (default
]]><![CDATA[    (let ((infeqns (select-elements (descendants (current-node))
]]><![CDATA[                                    (normalize "informalequation")))
]]><![CDATA[          (eqns (select-elements (descendants (current-node))
]]><![CDATA[                                 (normalize "equation")))
]]><![CDATA[          (inleqns (select-elements (descendants (current-node))
]]><![CDATA[                                    (normalize "inlineequation"))))
]]><![CDATA[      (with-mode htmlmath
]]><![CDATA[        (process-node-list
]]><![CDATA[         (node-list infeqns eqns inleqns)))))
]]><![CDATA[  (element equation (write-eqn (current-node)))
]]><![CDATA[  (element informalequation (write-eqn (current-node)))
]]><![CDATA[  (element inlineequation (write-eqn (current-node))))
]]></screen><para>Basically, what the above code does is the following: It processes only text found in the &lt;alt&gt; element <indexterm><primary>element</primary></indexterm>and only code found inside &lt;informalequation&gt;, &lt;equation&gt; or &lt;inlineequation&gt; tags. It puts this code (the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code of an equation) between &lt;texequation&gt; tags in <ulink url="equation-list.sgml">equation-list.sgml</ulink>. It also lists the fileref <indexterm><primary>fileref</primary></indexterm>attribute of the &lt;graphic&gt; element.<indexterm><primary>element</primary></indexterm> </para><para>This completes the Mathematics <indexterm><primary>Mathematics</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>done by openjade.<indexterm><primary>openjade</primary></indexterm> We will use the <ulink url="equation-list.sgml">equation-list.sgml</ulink> file to create PNG <indexterm><primary>PNG</primary></indexterm>and BMP <indexterm><primary>BMP</primary></indexterm>images of each equation.</para></sect3>
<sect3 id="explain-math-processing-with-texmath2pngbmp"><title>Math processing with texmath2pngbmp.pl</title><para>The <ulink url="texmath2pngbmp.pl">texmath2pngbmp.pl</ulink> is called after openjade <indexterm><primary>openjade</primary></indexterm>has processed the SGML <indexterm><primary>SGML</primary></indexterm>file with the stylesheet<indexterm><primary>stylesheet</primary></indexterm> for one HTML <indexterm><primary>HTML</primary></indexterm>file. It takes one argument, the file to process. It expects a file with the structure of <ulink url="equation-list.sgml">equation-list.sgml</ulink> (see <xref linkend="explain-math-processing-in-HTML-stylesheets">). It basically does the following:</para><itemizedlist><listitem><para>It parses the <ulink url="equation-list.sgml">equation-list.sgml</ulink> file. It extracts &ldquo;latexopt&rdquo;, &ldquo;density&rdquo; and &ldquo;usepackage&rdquo; .</para></listitem><listitem><para>For every text found between &lt;texequation&gt; tags, it creates a new <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>file. In the preample,<indexterm><primary>preample</primary></indexterm> it sets the options found in &ldquo;latexopt&rdquo;, &ldquo;density&rdquo; and &ldquo;usepackage&rdquo;. In the main part, it inserts the text, which is nothing else that the TeX<indexterm><primary>TeX</primary></indexterm> code describing an equation <footnote><para>It also unescapes some characters in the <application>TeX</application> code:</para><screen><![CDATA[sub unescape {
]]><![CDATA[    $eqn =~ s/&#38;/&/g;
]]><![CDATA[    $eqn =~ s/&#62;/\>/g;
]]><![CDATA[    $eqn =~ s/&#60;/\</g;
]]><![CDATA[} 
]]></screen></footnote>.</para></listitem><listitem><para>It then calls </para><itemizedlist><listitem><para>LaTeX <indexterm><primary>LaTeX</primary></indexterm>to process the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>file, </para></listitem><listitem><para>dvips <indexterm><primary>dvips</primary></indexterm>to create the the PostScript® <indexterm><primary>PostScript®</primary></indexterm>file from the .dvi file created by LaTeX,<indexterm><primary>LaTeX</primary></indexterm> </para></listitem><listitem><para>convert to convert <indexterm><primary>convert</primary></indexterm>the PS <indexterm><primary>PS</primary></indexterm>file to PNG <indexterm><primary>PNG</primary></indexterm>format with the right density <indexterm><primary>density</primary></indexterm>(the full name of the PNG <indexterm><primary>PNG</primary></indexterm>file was extracted from <ulink url="equation-list.sgml">equation-list.sgml</ulink>)</para></listitem><listitem><para>convert (once again) to convert <indexterm><primary>convert</primary></indexterm>the PS <indexterm><primary>PS</primary></indexterm>file to BMP <indexterm><primary>BMP</primary></indexterm>format (the full name was calculated from the path <indexterm><primary>path</primary></indexterm>and basename <indexterm><primary>basename</primary></indexterm>of the PNG <indexterm><primary>PNG</primary></indexterm>file<footnote><para>This is new here. The original texmath2png.pl file did not compute BMP versions of the equation images. </para></footnote>.</para></listitem></itemizedlist><screen><![CDATA[system ("latex $textmp");
]]><![CDATA[system ("dvips -o $textmp.eps $textmp -E");
]]><![CDATA[system ("convert -density $den $textmp.eps $figfile");
]]><![CDATA[system ("convert $textmp.eps $filepath"."$filebasename.bmp");
]]></screen></listitem></itemizedlist><para>At the end of the processing, PNG and BMP images are in images/math, while the HTML and RTF documents contain links to them for each equation. We are ready! We can enjoy Mathematics on the Web in <application>TeX</application> quality!<inlinemediaobject> <![ %output.print.png; [ <imageobject> <imagedata fileref="./images/icon_smile.png" format="PNG"> </imageobject> ]]> <![ %output.print.pdf; [ <imageobject> <imagedata fileref="icon_smile.pdf" format="PDF" scale="65"> </imageobject> ]]> <![ %output.print.eps; [ <imageobject> <imagedata fileref="icon_smile.eps" format="EPS"> </imageobject> ]]> <![ %output.print.bmp; [ <imageobject> <imagedata fileref="icon_smile.bmp" format="BMP"> </imageobject> ]]> <textobject> <phrase>Inline graphic</phrase> </textobject> </inlinemediaobject> </para>
<note>
<title>Note:</title>
<para>
We only need to call <ulink url="texmath2pngbmp.pl">texmath2pngbmp.pl</ulink> once. The PNG and BMP equation images for the whole SGML file will be created in the right directory and need not be recreated for each HTML or RTF run, since our trick with the output.print.xxx entities will take care for each run to INCLUDE the graphic element  with the right filenames in the fileref attribute (see <xref linkend="explain-SGML-math-solution">, <xref linkend="explain-runsed-sed-sedscr">, <xref linkend="explain-figures">).
</para>
</note>
</sect3>
</sect2>
<sect2 id="explain-math-PDF-PS"><title>PDF and PS</title><para>The PDF <indexterm><primary>PDF</primary></indexterm>and PS <indexterm><primary>PS</primary></indexterm>document math <indexterm><primary>math</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>is done partially in the print stylesheet<footnote><para>The print stylesheets, <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink> and <ulink url="lyxtox-print-ps.dsl">lyxtox-print-ps.dsl</ulink> both contain the same code for Mathematics. This can be probably modularized further in some next version of the scripts.</para></footnote> (<xref linkend="DSSSL-stylesheets">) and partially in the <ulink url="unescape_math.pl">unescape_math.pl</ulink> script. It differs substantially from the HTML <indexterm><primary>HTML</primary></indexterm>and RTF <indexterm><primary>RTF</primary></indexterm>math <indexterm><primary>math</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>(<xref linkend="explain-math-HTML-RTF">): instead of creating images for each equation, the stylesheet <indexterm><primary>stylesheet</primary></indexterm>instructs openjade <indexterm><primary>openjade</primary></indexterm>to directly output the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code in the .tex file it produces. We then unescape <indexterm><primary>unescape</primary></indexterm>some characters in that .tex file and pass it to pdfjadetex<indexterm><primary>pdfjadetex</primary></indexterm> or jadetex <indexterm><primary>jadetex</primary></indexterm>for the creation of the PDF,<indexterm><primary>PDF</primary></indexterm> resp. DVI <indexterm><primary>DVI</primary></indexterm>file<footnote><para>The PS version is then only one step away, with the aid of dvips.</para></footnote>. </para><sect3 id="explain-math-processing-in-print-stylesheet"><title>Math processing in the print stylesheet</title><para>The code for math <indexterm><primary>math</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>in the print stylesheet <indexterm><primary>stylesheet</primary></indexterm>does basically one simple thing: it outputs the text found between the &lt;alt&gt; tags (the TeX<indexterm><primary>TeX</primary></indexterm> code of the equation) in &lt;equation&gt;, &lt;informalequation&gt; and &lt;inlineequation&gt; elements of the input file. It encloses that text between begintexliteral and endtexliteral tags:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1034;" format="linespecific"><![CDATA[
]]></screen><para>It also specifies that we plan to use the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>backend:</para><screen><![CDATA[(define tex-backend
]]><![CDATA[  ;; REFENTRY tex-backend
]]><![CDATA[  ;; PURP Are we using the <application>TeX</application> backend?
]]><![CDATA[  ;; DESC
]]><![CDATA[  ;; This parameter exists so that '-V tex-backend' can be used on the
]]><![CDATA[  ;; command line to explicitly select the <application>TeX</application> backend.
]]><![CDATA[  ;; /DESC
]]><![CDATA[  ;; AUTHOR N/A
]]><![CDATA[  ;; /REFENTRY
]]><![CDATA[  #t)
]]><![CDATA[
]]></screen><para>When openjade <indexterm><primary>openjade</primary></indexterm>processes the an SGML <indexterm><primary>SGML</primary></indexterm>file containing equations,<indexterm><primary>equations</primary></indexterm> it will follow the above DSSSL <indexterm><primary>DSSSL</primary></indexterm>code and produce something like:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1035;" format="linespecific"><![CDATA[
]]></screen><para>This is the literal <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code for <xref linkend="eq2">, enclosed in begintexliteral-endtexliteral tags. As you can see, openjade <indexterm><primary>openjade</primary></indexterm>&quot;escapes&quot; some characters (for instance, turning a backslash into \char92{} and a caret into \char94{}), so that unless we take special measures we will end up with a typeset version of the <emphasis>source</emphasis> for the equation rather than  the typeset equation. It is here that the <ulink url="unescape_math.pl">unescape_math.pl</ulink> script comes into play.</para></sect3>
<sect3 id="explain-unescaping-TeX-equation-code"><title>Unescaping <application>TeX</application> equation code</title><para>The <ulink url="unescape_math.pl">unescape_math.pl</ulink> script is a simple <application>Perl</application> script that reads the input file (the .tex file created by openjade <indexterm><primary>openjade</primary></indexterm>through the print stylesheet <indexterm><primary>stylesheet</primary></indexterm>as in <xref linkend="explain-math-processing-in-print-stylesheet">) line by line and &ldquo;unescapes&rdquo; some characters found between begintexliteral and endtexliteral. More precisely, the order of operations for each line is the following:</para><orderedlist><listitem><para>If the line contains begintexliteral, we are entering <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>math code. Delete begintexliteral.</para></listitem><listitem><para>If we are still in <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>math code, unescape <indexterm><primary>unescape</primary></indexterm>the code. This is basically a substitution <indexterm><primary>substitution</primary></indexterm>of a few characters:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1036;" format="linespecific"><![CDATA[
]]></screen></listitem><listitem><para>If the line contains endtexliteral, we are leaving <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>math code. Delete endtexliteral.</para></listitem></orderedlist><para>The code of the above simple algorithm <indexterm><primary>algorithm</primary></indexterm>is </para><screen><![CDATA[]]><inlinegraphic fileref="&file1037;" format="linespecific"><![CDATA[
]]></screen><para>After applying <ulink url="unescape_math.pl">unescape_math.pl</ulink> to the .tex file, the above &ldquo;escaped&rdquo; <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code for <xref linkend="eq2"> becomes:</para><screen><![CDATA[]]><inlinegraphic fileref="&file1038;" format="linespecific"><![CDATA[
]]><![CDATA[
]]></screen><para>which will be perfectly typeset by <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>in the subsequent call of (pdf)jadetex.</para><note>
<title>Note:</title>
<para>
In the original unescape_math.pl script, step 2 of the algorithm was performed as step 3, after the  endtexliteral substitution. This is a bug that comes on the surface when we have one line containing both equation code and endtexliteral. In such a case, the original sequence of steps will only delete endtexliteral, leaving the equation code still "escaped".
</para>
</note>
<para>After this &ldquo;unescaping&rdquo;, we get a .tex file that we can either process to a PDF <indexterm><primary>PDF</primary></indexterm>one through pdfjadetex<indexterm><primary>pdfjadetex</primary></indexterm><footnote><para>Actually, pdfjadetex has to be called up to three times consecutively to produce table of contents, cross-references etc. correctly. <ulink url="lyxtox">lyxtox</ulink> already does this for you.</para></footnote></para><screen><![CDATA[$PDFJADETEX $1.tex
]]></screen><para>or to a PS <indexterm><primary>PS</primary></indexterm>one through jadetex<indexterm><primary>jadetex</primary></indexterm><footnote><para>Actually, jadetex has to be called up to three times consecutively to produce table of contents, cross-references etc. correctly. <ulink url="lyxtox">lyxtox</ulink> already does this for you.</para></footnote> and dvips:<indexterm><primary>dvips</primary></indexterm></para><screen><![CDATA[$JADETEX $1.tex
]]><![CDATA[$DVIPS -o $1.ps $1.dvi
]]></screen></sect3>
</sect2>
</sect1>
<sect1 id="problems-of-the-DBTeXMath-method"><title>Problems of the DBTeXMath method</title><para>The DBTexMath <indexterm><primary>DBTexMath</primary></indexterm>method provides us with an easy way to get perfectly typeset Mathematics <indexterm><primary>Mathematics</primary></indexterm>in all 4 formats: HTML,<indexterm><primary>HTML</primary></indexterm> PDF,<indexterm><primary>PDF</primary></indexterm> PS <indexterm><primary>PS</primary></indexterm><emphasis>and</emphasis> RTF.<indexterm><primary>RTF</primary></indexterm> Moreover, it does this in the context of SGML <indexterm><primary>SGML</primary></indexterm>processing <indexterm><primary>processing</primary></indexterm>- we are not forced to leave our usual procedures and/or markup,<indexterm><primary>markup</primary></indexterm> it integrates nicely in our scripts.</para><para>Nevertheless, such an approach <indexterm><primary>approach</primary></indexterm>to mathematical <indexterm><primary>mathematical</primary></indexterm>document processing <indexterm><primary>processing</primary></indexterm>is not free from problems:</para><itemizedlist><listitem><para>The most important objection comes from a theoretical viewpoint: the &lt;alt&gt; tag is what its name suggests - a tag for an <emphasis>alternative</emphasis> description of the equation. This is not exactly what the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code is, especially from the accessibility<indexterm><primary>accessibility</primary></indexterm> point of view (see <xref linkend="accessibility">). In a <ulink url="http://lists.oasis-open.org/archives/docbook-apps/200112/msg00069.html">message to the docbook-apps mailing list</ulink>, Michael Smith points out the following:</para><blockquote><para>The DocBook <indexterm><primary>DocBook</primary></indexterm>TC intended the contents of &lt;alt&gt; to be a <emphasis>human-readable</emphasis> text description, using ISO <indexterm><primary>ISO</primary></indexterm>entities <indexterm><primary>entities</primary></indexterm>for any math <indexterm><primary>math</primary></indexterm>symbols <indexterm><primary>symbols</primary></indexterm>that couldn't be represented with normal characters.</para><para>But maybe if you use &lt;alt role=&quot;tex&quot;&gt;, you could tweak <indexterm><primary>tweak</primary></indexterm>the stylesheets so that to the HTML <indexterm><primary>HTML</primary></indexterm>output they add some generated text like:</para><screen><![CDATA[<img alt="TeX version of equation: [TeX stuff]">
]]></screen><para>That way, to people reading or hearing the alt text in a browser,<indexterm><primary>browser</primary></indexterm> it'll at least be unambiguous to them that what's they're reading/ hearing is <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>math -- which, depending on the complexity <indexterm><primary>complexity</primary></indexterm>of the equation, they may or may not find &quot;human-readable&quot;<indexterm><primary>human-readable</primary></indexterm><footnote><para>Inserting &ldquo;role=tex&rdquo; to the &lt;alt&gt; tag can be done very easily in the <ulink url="awkscr_math">awkscr_math</ulink> script.</para></footnote>.</para></blockquote></listitem><listitem><para>Labels on displayed equations <indexterm><primary>equations</primary></indexterm>for the HTML <indexterm><primary>HTML</primary></indexterm>and RTF <indexterm><primary>RTF</primary></indexterm>formats will always start at 1, no matter how many equations <indexterm><primary>equations</primary></indexterm>you have. I briefly discussed this in <xref linkend="LyX-writing-Mathematics">, along with some measures to alleviate the problem. Until some <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>Guru <indexterm><primary>Guru</primary></indexterm>(anyone reading?) out there tells me how to work around this, you might want to crop every image of a displayed equation to 90% in the x direction with the -crop option to convert:<indexterm><primary>convert</primary></indexterm></para><screen><![CDATA[convert -crop 90x100% images/math/17202.png
]]></screen><para>This will eliminate <indexterm><primary>eliminate</primary></indexterm>the equation labels from the image. If you follow the rules <indexterm><primary>rules</primary></indexterm>in <xref linkend="LyX-writing-Mathematics">, you will still be able to reference equations <indexterm><primary>equations</primary></indexterm>concisely and correctly through all chapters and in all formats.</para></listitem><listitem><para>Your text should not contain begintexliteral or endtexliteral, otherwise the <ulink url="unescape_math.pl">unescape_math.pl</ulink> script will try to unescape <indexterm><primary>unescape</primary></indexterm>some characters between them (and will also delete them). Well, I can live with that one...</para></listitem></itemizedlist></sect1>
</chapter>
<chapter id="localization"><title>Localization</title><para>So here you are, after 200 pages of information bombardement, your eyes wide open in expectation of the last firework: &ldquo;will it work with my language?&rdquo;, you ask. This chapter deals with the answer to this question.</para><para>FIXME: Add: What is internationalization, what localization?<indexterm><primary>localization</primary></indexterm></para><para>Here is &ldquo;the problem at hand&rdquo;, as described vividly in <ulink url="http://www.valdyas.org/linguistics/printing_unicode.html">Messing about with Unicode, XML, XSL, DSSSL, Tex, Omega, Fop and the rest of the mess</ulink>:</para><blockquote><para>Let's say you have a source of data that is going to be published. The data comprises text from many, many languages. English. Dutch. Chinese, sure. Malayalam, perhaps. Tibetan, of course. And it contains some pretty weird symbols.<indexterm><primary>symbols</primary></indexterm> Like a shwa -- a topsy-turvy e: . In order to subsume all this data in one character encoding,<indexterm><primary>encoding</primary></indexterm> everything is encoded in Unicode: the current standard for multi-lingual, unified text encoding.<indexterm><primary>encoding</primary></indexterm></para><para>You would like to print your text, publish your text on the web, and perhaps also to prepare it for further editing in a word-processing package. And you don't want to lose your Chinese characters, your IPA signs, or your mathematical <indexterm><primary>mathematical</primary></indexterm>symbols.</para></blockquote><warning>
<title>Work in progress!</title> 
<para> 
This chapter is work in progress, so the information in it is incomplete - and may even be inaccurate! Many problems may have disappeared, as distributions made the transition to UTF-8. Others may have surfaced. If you have any hints regarding this complex subject, please contact me, or post in <ulink url="http://www.karakas-online.de/forum/linux.html">my <productname>Linux</productname> Forum</ulink>.
</para> 
</warning>
<para>One thing that makes this endeavour so difficult, is that it is comprised of many, many steps, each one with its own inputs, output and tools.<indexterm><primary>tools</primary></indexterm> To understand the process, we have to dissect it in those steps:</para><itemizedlist><listitem><para>You type something on the console with your keyboard. Each key on your keyboard carries a symbol on it, but this does not mean that when you press it you will see that symbol on the screen. What you see on the screen depends on the keyboard mapping and your console fonts,<indexterm><primary>fonts</primary></indexterm> see <xref linkend="shell-localization">. In a <acronym>GUI</acronym> <indexterm><primary>GUI</primary></indexterm>environment <indexterm><primary>environment</primary></indexterm>(and an X terminal, instead of a text console), the <acronym>GUI</acronym> <indexterm><primary>GUI</primary></indexterm>may apply its own mappings and LyX <indexterm><primary>LyX</primary></indexterm>must know about them too. See <xref linkend="keyboard-localization">, <xref linkend="LyX-keyboard-mapping-configuration">.</para></listitem><listitem><para>Finally, some hexadecimal code arrives at LyX <indexterm><primary>LyX</primary></indexterm>as a result of your key pressing. Will LyX <indexterm><primary>LyX</primary></indexterm>display what you expect? This depends on LyX' language configuration, see <xref linkend="LyX-layout-language-options">.</para></listitem><listitem><para>Suppose you managed to type something <emphasis>and</emphasis> see it displayed correctly in LyX <indexterm><primary>LyX</primary></indexterm>in the language of your choice. You save the document <indexterm><primary>document</primary></indexterm>and run <ulink url="lyxtox">lyxtox</ulink> as in <xref linkend="lyxtox">. This will kickstart an avalanche of commands, which will ultimately do the following:</para></listitem><listitem><para>Export the document <indexterm><primary>document</primary></indexterm>from LyX <indexterm><primary>LyX</primary></indexterm>to DocBook <indexterm><primary>DocBook</primary></indexterm>SGML.<indexterm><primary>SGML</primary></indexterm> Depending on its language configuration, LyX <indexterm><primary>LyX</primary></indexterm>will</para><orderedlist><listitem><para>use the right encoding <indexterm><primary>encoding</primary></indexterm>for the symbols,<indexterm><primary>symbols</primary></indexterm> letters etc you typed and</para></listitem><listitem><para>set the language attribute <indexterm><primary>attribute</primary></indexterm>(&ldquo;lang&rdquo;) in the 
 <inlineequation>
  <alt>$
 &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/16884.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/16884.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/16884.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/16884.bmp">
 ]]>

 </inlineequation>article
 <inlineequation>
  <alt>$
 &gt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/15818.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/15818.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/15818.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/15818.bmp">
 ]]>

 </inlineequation> or 
 <inlineequation>
  <alt>$
 &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/17883.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/17883.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/17883.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/17883.bmp">
 ]]>

 </inlineequation>book
 <inlineequation>
  <alt>$
 &gt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/13155.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/13155.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/13155.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/13155.bmp">
 ]]>

 </inlineequation> element <indexterm><primary>element</primary></indexterm>of the exported file. For language set to english, this will produce the lines</para><screen><![CDATA[<article lang="en"><!-- DocBook file was created by LyX 1.2
]]><![CDATA[  See http://www.lyx.org/ for more information -->
]]></screen><para>near the top of the exported document.<indexterm><primary>document</primary></indexterm> This information is used by the DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheets, see <xref linkend="DSSSL-stylesheet-localization">.</para></listitem></orderedlist></listitem><listitem><para>sed and awk <indexterm><primary>awk</primary></indexterm>will correct the exported SGML <indexterm><primary>SGML</primary></indexterm>document. Will sed and awk <indexterm><primary>awk</primary></indexterm>understand your Dutch and Chinese? Or your Malayalam? See <xref linkend="sed-localization"> and <xref linkend="awk-localization">.</para></listitem><listitem><para>Openjade <indexterm><primary>Openjade</primary></indexterm>will transform the corrected SGML <indexterm><primary>SGML</primary></indexterm>document to various formats, including HTML,<indexterm><primary>HTML</primary></indexterm> <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>and RTF.<indexterm><primary>RTF</primary></indexterm> Will Openjade <indexterm><primary>Openjade</primary></indexterm>understand the encoding <indexterm><primary>encoding</primary></indexterm>of the input file? How will Openjade represent it internally? And which encoding <indexterm><primary>encoding</primary></indexterm>will Openjade <indexterm><primary>Openjade</primary></indexterm>use for the output in HTML,<indexterm><primary>HTML</primary></indexterm> <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>and RTF?<indexterm><primary>RTF</primary></indexterm> See <xref linkend="openjade-localization">.</para></listitem><listitem><para>Lynx <indexterm><primary>Lynx</primary></indexterm>will read the HTML <indexterm><primary>HTML</primary></indexterm>(one file) version and produce the TXT <indexterm><primary>TXT</primary></indexterm>out of it. Will lynx <indexterm><primary>lynx</primary></indexterm>produce a correct TXT <indexterm><primary>TXT</primary></indexterm>document <indexterm><primary>document</primary></indexterm>from the (hopefully correct) HTML?<indexterm><primary>HTML</primary></indexterm> See <xref linkend="lynx-localization">.</para></listitem><listitem><para>Perl scripts transform the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>version. Will <application>Perl</application> work as expected in the languages of our example? See <xref linkend="perl-localization">.</para></listitem><listitem><para>Pdfjadetex transforms the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>source into a PDF <indexterm><primary>PDF</primary></indexterm>document. Will pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>understand that its input <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>source is in some other encoding?<indexterm><primary>encoding</primary></indexterm> How can we tell it? Jadetex transforms the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>source (actually a different <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>source from the above, produced by openjade <indexterm><primary>openjade</primary></indexterm>using the <ulink url="lyxtox-print-ps.dsl">lyxtox-print-ps.dsl</ulink> DSSSL <indexterm><primary>DSSSL</primary></indexterm>stylesheet) to a DVI <indexterm><primary>DVI</primary></indexterm>document. Will jadetex <indexterm><primary>jadetex</primary></indexterm>understand that its input <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>source is in some other encoding?<indexterm><primary>encoding</primary></indexterm> How can we tell it? Pdfjadetex and jadetex <indexterm><primary>jadetex</primary></indexterm>are <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>macro packages <indexterm><primary>packages</primary></indexterm>and as such they use the underlying <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>installation. Will <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>cope with all those languages? See <xref linkend="TeX-localization">.</para></listitem><listitem><para>dvips <indexterm><primary>dvips</primary></indexterm>reads the DVI <indexterm><primary>DVI</primary></indexterm>document produced by jadetex <indexterm><primary>jadetex</primary></indexterm>and outputs a PS <indexterm><primary>PS</primary></indexterm>file. What must dvips <indexterm><primary>dvips</primary></indexterm>know about localization <indexterm><primary>localization</primary></indexterm>to work with our multilanguage document?<indexterm><primary>document</primary></indexterm> See <xref linkend="dvips-localization">.</para></listitem><listitem><para>Will openjade <indexterm><primary>openjade</primary></indexterm>produce the right HTML,<indexterm><primary>HTML</primary></indexterm> <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>and RTF?<indexterm><primary>RTF</primary></indexterm> Will pdfjadetex <indexterm><primary>pdfjadetex</primary></indexterm>produce a PDF <indexterm><primary>PDF</primary></indexterm>file in the right encoding?<indexterm><primary>encoding</primary></indexterm> With the right fonts <indexterm><primary>fonts</primary></indexterm>embedded <indexterm><primary>embedded</primary></indexterm>in the document?<indexterm><primary>document</primary></indexterm> Will jadetex <indexterm><primary>jadetex</primary></indexterm>produce a DVI <indexterm><primary>DVI</primary></indexterm>document with the right encoding <indexterm><primary>encoding</primary></indexterm>and the right fonts?<indexterm><primary>fonts</primary></indexterm> Will dvips <indexterm><primary>dvips</primary></indexterm>produce a correct PS <indexterm><primary>PS</primary></indexterm>document from the localized DVI?<indexterm><primary>DVI</primary></indexterm> Will lynx <indexterm><primary>lynx</primary></indexterm>produce the right TXT <indexterm><primary>TXT</primary></indexterm>from the localized HTML?<indexterm><primary>HTML</primary></indexterm> What are the open problems related to localization?<indexterm><primary>localization</primary></indexterm> See <xref linkend="open-localization-problems">.</para></listitem></itemizedlist><para>Questions over questions...Now let's put the puzzle pieces together!</para><note>
<title>LyX User Guide</title>
<para>
The following sections are taken from the LyX User Guide: 
</para>
<itemizedlist>
<listitem>
<para>
<xref linkend="keyboard-localization">, with its subsections <xref linkend="xmodmap-and-xkeycaps">, <xref linkend="modifiers-and-mode-switch"> and <xref linkend="keyboard-hints-and-tips"> and
</para>
</listitem>
<listitem>
<para>
<xref linkend="LyX-localization"> with its subsections  <xref linkend="LyX-layout-language-options">, <xref linkend="LyX-keyboard-mapping-configuration">, <xref linkend="LyX-character-tables">, <xref linkend="lyx-international-spellcheck-support">.
</para>
</listitem>
</itemizedlist>
</note>
<sect1 id="shell-localization"><title>Shell localization</title><para>FIXME: What is locale?</para><para>FIXME: what is charset? What is encoding?<indexterm><primary>encoding</primary></indexterm></para><para>FIXME: include localization <indexterm><primary>localization</primary></indexterm>through locale and .bashrc.</para></sect1>
<sect1 id="sed-localization"><title>sed localization</title><para>From the <ulink url="http://www.opengroup.org/onlinepubs/007908799/xcu/sed.html">sed manual page</ulink>, we see that the following environment <indexterm><primary>environment</primary></indexterm>variables affect the execution of sed:</para><variablelist><varlistentry><term>LANG
</term><listitem><para>Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility <indexterm><primary>utility</primary></indexterm>will behave as if none of the variables had been defined.</para></listitem></varlistentry><varlistentry><term>LC_ALL
</term><listitem><para>If set to a non-empty string value, override the values of all the other internationalisation variables.</para></listitem></varlistentry><varlistentry><term>LC_COLLATE
</term><listitem><para>Determine the locale for the behaviour <indexterm><primary>behaviour</primary></indexterm>of ranges, equivalence classes and multi-character collating elements within regular expressions.<indexterm><primary>expressions</primary></indexterm></para></listitem></varlistentry><varlistentry><term>LC_CTYPE
</term><listitem><para>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- versus multi-byte characters in arguments and input files), and the behaviour <indexterm><primary>behaviour</primary></indexterm>of character classes within regular expressions.<indexterm><primary>expressions</primary></indexterm></para></listitem></varlistentry><varlistentry><term>LC_MESSAGES
</term><listitem><para>Determine the locale that should be used to affect the format and contents of diagnostic <indexterm><primary>diagnostic</primary></indexterm>messages written to standard error.</para></listitem></varlistentry><varlistentry><term>NLSPATH
</term><listitem><para>Determine the location of message catalogues <indexterm><primary>catalogues</primary></indexterm>for the processing<indexterm><primary>processing</primary></indexterm> of LC_MESSAGES .</para></listitem></varlistentry></variablelist></sect1>
<sect1 id="awk-localization"><title>awk localization</title><para>From the <ulink url="http://www.opengroup.org/onlinepubs/007908799/xcu/awk.html">awk manual page</ulink>, we see that the following environment <indexterm><primary>environment</primary></indexterm>variables affect the execution of awk:<indexterm><primary>awk</primary></indexterm></para><variablelist><varlistentry><term>LANG
</term><listitem><para>Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility <indexterm><primary>utility</primary></indexterm>will behave as if none of the variables had been defined.</para></listitem></varlistentry><varlistentry><term>LC_ALL
</term><listitem><para>If set to a non-empty string value, override the values of all the other internationalisation variables.</para></listitem></varlistentry><varlistentry><term>LC_COLLATE
</term><listitem><para>Determine the locale for the behaviour <indexterm><primary>behaviour</primary></indexterm>of ranges, equivalence classes and multi-character collating elements within regular expressions<indexterm><primary>expressions</primary></indexterm> and in comparisons of string values.</para></listitem></varlistentry><varlistentry><term>LC_CTYPE
</term><listitem><para>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- versus multi-byte characters in arguments and input files), the behaviour <indexterm><primary>behaviour</primary></indexterm>of character classes within regular expressions,<indexterm><primary>expressions</primary></indexterm> the identification <indexterm><primary>identification</primary></indexterm>of characters as letters, and the mapping of upper- and lower-case characters for the toupper and tolower functions.</para></listitem></varlistentry><varlistentry><term>LC_MESSAGES
</term><listitem><para>Determine the locale that should be used to affect the format and contents of diagnostic <indexterm><primary>diagnostic</primary></indexterm>messages written to standard error.</para></listitem></varlistentry><varlistentry><term>LC_NUMERIC
</term><listitem><para>Determine the radix character used when interpreting numeric input, performing conversions between numeric and string values and formatting<indexterm><primary>formatting</primary></indexterm> numeric output. Regardless of locale, the period character (the decimal-point character of the <acronym>POSIX</acronym> locale) is the decimal-point character recognised in processing<indexterm><primary>processing</primary></indexterm> awk <indexterm><primary>awk</primary></indexterm>programs (including assignments in command-line arguments).</para></listitem></varlistentry><varlistentry><term>NLSPATH
</term><listitem><para>Determine the location of message catalogues <indexterm><primary>catalogues</primary></indexterm>for the processing<indexterm><primary>processing</primary></indexterm> of LC_MESSAGES .</para></listitem></varlistentry><varlistentry><term>PATH
</term><listitem><para><indexterm><primary>PATH</primary></indexterm>Determine the search path <indexterm><primary>path</primary></indexterm>when looking for commands executed by system(expr), or input and output pipes.<indexterm><primary>pipes</primary></indexterm> See the XBD specification,<indexterm><primary>specification</primary></indexterm> Environment Variables.</para></listitem></varlistentry></variablelist><para>In addition, all environment <indexterm><primary>environment</primary></indexterm>variables will be visible via the awk <indexterm><primary>awk</primary></indexterm>variable ENVIRON.</para></sect1>
<sect1 id="perl-localization"><title>Perl localization</title><para>FIXME: Get the information from the <ulink url="http://www.perl.com/doc/manual/html/pod/perllocale.html">Perl manual on locale handling</ulink></para></sect1>
<sect1 id="keyboard-localization"><title>Keyboard localization</title><para>To use LyX <indexterm><primary>LyX</primary></indexterm>properly, you <emphasis>must</emphasis> set X up correctly. This is especially vital if you're using the international support features of LyX <indexterm><primary>LyX</primary></indexterm>and want to use non-English keyboard mappings. Unfortunately, almost nobody bothers to do this, especially those who've installed <productname>Linux</productname> on a PC. Administrators of large systems can be guilty of this, too, so don't assume that you're safe if you're using a large system. Any user can instruct X how to use his or her keyboard. You needn't rely on your sysadmin for this - in fact, you <emphasis>shouldn't</emphasis>! The following two programs are all you need to set up your keyboard the way you want it.</para><sect2 id="xmodmap-and-xkeycaps"><title>xmodmap and xkeycaps</title><para>First of all read the man pages for these two programs. They are your best friends when you are trying to set up X key mapping correctly. If you don't have them, install them.</para><sect3 id="xmodmap"><title>xmodmap</title><para>This document <indexterm><primary>document</primary></indexterm>contains no information on how to use <indexterm><primary>typewriter</primary></indexterm>xmodmap. There is a sample <indexterm><primary>typewriter</primary></indexterm>.Xmodmap file in <emphasis>Customization</emphasis>. To load the new X keyboard mappings, place the command <indexterm><primary>typewriter</primary></indexterm>xmodmap&nbsp;.Xmodmap somewhere in your startup scripts [for example, <indexterm><primary>typewriter</primary></indexterm>.cshrc, <indexterm><primary>typewriter</primary></indexterm>.profile, <indexterm><primary>typewriter</primary></indexterm>.login, or <indexterm><primary>typewriter</primary></indexterm>.xinitrc are all possibilities].</para></sect3>
<sect3 id="xkeycaps"><title>xkeycaps</title><para>This program is a dream come true! It brings up a graphical version of your keyboard, allows you to make modifications, and then spits those modifications out to the standard output in a form readable by <indexterm><primary>typewriter</primary></indexterm>xmodmap. It is very useful when you're trying to design a new <indexterm><primary>typewriter</primary></indexterm>.Xmodmap file, though it will require you to do a bit of cut-and-pasting.</para></sect3>
</sect2>
<sect2 id="modifiers-and-mode-switch"><title>Modifiers and Mode_switch</title><para>LyX <indexterm><primary>LyX</primary></indexterm>supports three modifiers: Shift [S-], Control [C-], and Meta [M-]. Moreover, if one of the keys of your keyboard is configured as a Compose key, then you can use it to enter some characters not available on your keyboard. This compose key can be used either as a modifier <indexterm><primary>modifier</primary></indexterm>(like Shift or Control) or as a prefix key. Here are some examples of what you can do with a Compose key:</para><itemizedlist><listitem><para>Compose+e+' 
 <inlineequation>
  <alt>$
\rightarrow $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/15478.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/15478.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/15478.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/15478.bmp">
 ]]>

 </inlineequation> é</para></listitem><listitem><para>Compose+O+R 
 <inlineequation>
  <alt>$
\rightarrow $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/10437.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/10437.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/10437.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/10437.bmp">
 ]]>

 </inlineequation> ®</para></listitem><listitem><para>Compose+1+2 
 <inlineequation>
  <alt>$
\rightarrow $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/18389.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/18389.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/18389.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/18389.bmp">
 ]]>

 </inlineequation> ½</para></listitem><listitem><para>Compose+&lt;+&lt; 
 <inlineequation>
  <alt>$
\rightarrow $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/15171.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/15171.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/15171.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/15171.bmp">
 ]]>

 </inlineequation> «</para></listitem></itemizedlist><para>This input method is particularly handy when you use accented characters only from time to time. It works by default for latin1 <indexterm><primary>latin1</primary></indexterm>characters, but other input methods will be used if you setup your locale correctly.</para></sect2>
<sect2 id="keyboard-hints-and-tips"><title>Helpful Hints and Tips</title><para>First, open up two xterminals. Use one to edit a new <indexterm><primary>typewriter</primary></indexterm>.Xmodmap file and run <indexterm><primary>typewriter</primary></indexterm>xkeycaps from the other. Using <indexterm><primary>typewriter</primary></indexterm>xkeycaps, remap your keyboard the way you want it. There's a button in <indexterm><primary>typewriter</primary></indexterm>xkeycaps to output the new keymap. Once you hit it, <indexterm><primary>typewriter</primary></indexterm>xkeycaps will spit a bunch of stuff on the xterm you executed it from. Just copy and paste all of that into your <indexterm><primary>typewriter</primary></indexterm>.Xmodmap file, and you're done.<footnote><para>You could also save yourself some typing by executing xkeycaps &gt; .Xmodmap. This will create a usable map file. Of course, if you hit the &ldquo;output keymap&rdquo; button in xkeycaps more than once, the resulting map file will be a mess. As with all things, xkeycaps is a tool, and only as intelligent as the person on the other end.</para></footnote></para><para>Also, there are some things you can do to help you get oriented. Try executing the command <indexterm><primary>typewriter</primary></indexterm>xmodmap -v -pm. This will show you all of the currently active modifiers. Also try <indexterm><primary>typewriter</primary></indexterm>xmodmap -v -pke | more to see which keycode numbers <indexterm><primary>numbers</primary></indexterm>are mapped to which symbolic <indexterm><primary>symbolic</primary></indexterm>names. It will also give you some idea of the syntax of the <indexterm><primary>typewriter</primary></indexterm>.Xmodmap file.</para><para>There's one thing you'll need to check. Make sure that your Delete and BackSpace keys are <emphasis>not</emphasis> defined as the same key symbol by X! Note that giving these two keys unique symbol names will not necessarily alter the behavior of your programs. Some programs bind Delete and BackSpace to the same operation. Emacs is one. Other programs, however, use Delete and BackSpace for different operations. LyX <indexterm><primary>LyX</primary></indexterm>is one of these programs, and if you have Delete and BackSpace labeled with the same key symbol name, you'll have trouble using LyX.<indexterm><primary>LyX</primary></indexterm></para></sect2>
</sect1>
<sect1 id="LyX-localization"><title>LyX localization</title><para>This section describes how to use LyX <indexterm><primary>LyX</primary></indexterm>with any language you want. LyX <indexterm><primary>LyX</primary></indexterm>comes with a default configuration which supports the English language on a U.S.-style keyboard, with a standard U.S. paper <indexterm><primary>paper</primary></indexterm>size and the spell checker set to U.S. English. You can change any or all of these settings as desired, and you can make the changes apply to the current session only, or use them as your new default configuration.</para><para>If you have a keyboard suited to the language you are using (for example, a german keyboard for writing in German), and you have correctly configured your X environment,<indexterm><primary>environment</primary></indexterm> all you need to do for LyX <indexterm><primary>LyX</primary></indexterm>is tell it your language, the character encoding,<indexterm><primary>encoding</primary></indexterm> and desired paper <indexterm><primary>paper</primary></indexterm>size. Refer to <xref linkend="LyX-layout-language-options"> for more information.</para><para>If, however, you have a U.S.-style keyboard and want to write in a different language than English, you can use an alternate keymap. For example, if you have a U.S.-style keyboard but want to write in Italian, you should configure LyX <indexterm><primary>LyX</primary></indexterm>to use an Italian keymap. Refer to <xref linkend="keyboard-localization"> for details. </para><para>Finally, you may just want to change a few key mappings or create an entirely different keymap (for Vulcan, for instance). You may, for example, normally write in Italian on a U.S. keyboard but want to include an occasional quotation in German. In such a case, you can write your own keyboard mapping or modify an existing one to support the characters you want. </para><para>The details of how to customize LyX <indexterm><primary>LyX</primary></indexterm>to your own language are <emphasis>way</emphasis> beyond the scope <indexterm><primary>scope</primary></indexterm>of this manual.<indexterm><primary>manual</primary></indexterm> You can not only alter the keyboard layout,<indexterm><primary>layout</primary></indexterm> you can also change the names of the menus buttons, etc., to reflect your language. If you want to learn more about writing keymap files and tailoring LyX<indexterm><primary>LyX</primary></indexterm> to your native tongue, please see the <emphasis>Customization</emphasis> manual <indexterm><primary>manual</primary></indexterm>for details.</para><sect2 id="LyX-layout-language-options"><title>Layout Language Options</title><para>The Document&nbsp;Layout dialog lets you set the language and character encoding <indexterm><primary>encoding</primary></indexterm>for your language. Access this dialog by selecting Layout&lyxarrow;Document.</para><para>Choose your language by clicking on the arrow in the Language combobox of the Document&nbsp;Layout dialog. The default is U.S. English. Scroll to find the language you want and then click on your choice. The language name appears in the window.<footnote><para>In <application>LaTeX</application> terms, selecting a language other than default adds Babel support. If you do not have Babel installed, refer to the different <application>LaTeX</application> distributions for it.</para></footnote></para><para>The Encoding box lets you choose the character encoding <indexterm><primary>encoding</primary></indexterm>map you want to use. The default is the <indexterm><primary>typewriter</primary></indexterm>ASCII encoding <indexterm><primary>encoding</primary></indexterm>which is typically sufficient for U.S. English. A superset <indexterm><primary>superset</primary></indexterm>of the <indexterm><primary>typewriter</primary></indexterm>ASCII encoding <indexterm><primary>encoding</primary></indexterm>is the <indexterm><primary>typewriter</primary></indexterm>Latin1 encoding,<indexterm><primary>encoding</primary></indexterm> which includes the characters required by the various Western European languages. The third choice, <indexterm><primary>typewriter</primary></indexterm>Latin2, is for support of Eastern European languages. Click on the dialog and then click on the encoding <indexterm><primary>encoding</primary></indexterm>you want to use, and it appears in the window. (Refer to <xref linkend="LyX-keyboard-mapping-configuration"> for the character encodings.)</para><para>To change the paper <indexterm><primary>paper</primary></indexterm>size, select Layout&lyxarrow;Paper. Then use the Papersize combobox to select a paper <indexterm><primary>paper</primary></indexterm>size. The default is the U.S. Letter paper <indexterm><primary>paper</primary></indexterm>size.</para><para>To use any language, papersize,<indexterm><primary>papersize</primary></indexterm> or encoding <indexterm><primary>encoding</primary></indexterm>change you made, click on the OK button. Your new configuration will now be used as long as you are in the current LyX <indexterm><primary>LyX</primary></indexterm>session. </para></sect2>
<sect2 id="LyX-keyboard-mapping-configuration"><title>Keyboard mapping configuration</title><para>The preferences <indexterm><primary>preferences</primary></indexterm>dialog allows you to choose up to two keyboard mappings. This allows you to choose the keymap of your choice for your U.S.-style keyboard. You can choose primary and secondary keyboard languages and then select which one you want to use. </para><para>Click on the down arrow for the Primary combobox and choose the language keymap you want by clicking on it. The name them appears in the Primary window. Do the same in the Secondary window for a secondary language if you want one. You can then select either your primary or secondary keymap in the Mapping section of the menu, or select No&nbsp;key&nbsp;mapping if you do not want to use an alternate keymap. </para><para>The Character set window allows you to use different character sets if your language uses more than one. Greek, for example, uses two, and a Greek user can enter <indexterm><primary>typewriter</primary></indexterm>iso-8859-7 in this window and the appropriate character map (a <indexterm><primary>typewriter</primary></indexterm>.cdef file), if available, is loaded. </para><para>Note that one of the choices for both primary and secondary keymaps is Other. You can use this to select a custom keymap which you've created yourself. For example, current distributions of LyX <indexterm><primary>LyX</primary></indexterm>provide an <indexterm><primary>typewriter</primary></indexterm>american-2 keymap file in the <indexterm><primary>typewriter</primary></indexterm>$LYX_DIR/kbd directory. This keymapping supports some accented characters for other languages in addition to the U.S. keymap. To use the <indexterm><primary>typewriter</primary></indexterm>american-2 keymap, select the Options&lyxarrow;Keyboard menu, select other in the primary selection box, enter the name of the keymap (<indexterm><primary>typewriter</primary></indexterm>american-2) and click on OK. You should now be able to enter accent characters using the new keymap.</para></sect2>
<sect2 id="LyX-character-tables"><title>Character Tables</title><para>Here is a table with all the characters in the <indexterm><primary>typewriter</primary></indexterm>Latin1 character set. You should be able to print all these characters directly from the keyboard without using too many modifier <indexterm><primary>modifier</primary></indexterm>keys (if your keyboard is set up correctly, that is). Note that you must set your font encoding <indexterm><primary>encoding</primary></indexterm>(in the Encoding combobox of the Layout&lyxarrow;Document dialog) to latin1 to use this keyset, and to latin2 to use the <indexterm><primary>typewriter</primary></indexterm>Latin2 keyset. </para><para><table id="tab-latin1-character-set"><title>latin1 character set</title><tgroup cols="17" colsep="1" rowsep="1">
<colspec colname="col0" align="center">
<colspec colname="col1" align="center">
<colspec colname="col2" align="center">
<colspec colname="col3" align="center">
<colspec colname="col4" align="center">
<colspec colname="col5" align="center">
<colspec colname="col6" align="center">
<colspec colname="col7" align="center">
<colspec colname="col8" align="center">
<colspec colname="col9" align="center">
<colspec colname="col10" align="center">
<colspec colname="col11" align="center">
<colspec colname="col12" align="center">
<colspec colname="col13" align="center">
<colspec colname="col14" align="center">
<colspec colname="col15" align="center">
<colspec colname="col16" align="center">
<tbody>
<row>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>00</para></entry>
<entry align="center" valign="top"><para>10</para></entry>
<entry align="center" valign="top"><para>20</para></entry>
<entry align="center" valign="top"><para>30</para></entry>
<entry align="center" valign="top"><para>40</para></entry>
<entry align="center" valign="top"><para>50</para></entry>
<entry align="center" valign="top"><para>60</para></entry>
<entry align="center" valign="top"><para>70</para></entry>
<entry align="center" valign="top"><para>80</para></entry>
<entry align="center" valign="top"><para>90</para></entry>
<entry align="center" valign="top"><para>A0</para></entry>
<entry align="center" valign="top"><para>B0</para></entry>
<entry align="center" valign="top"><para>C0</para></entry>
<entry align="center" valign="top"><para>D0</para></entry>
<entry align="center" valign="top"><para>E0</para></entry>
<entry align="center" valign="top"><para>F0</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>00</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>0</para></entry>
<entry align="center" valign="top"><para>@</para></entry>
<entry align="center" valign="top"><para>P</para></entry>
<entry align="center" valign="top"><para>'</para></entry>
<entry align="center" valign="top"><para>p</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>°</para></entry>
<entry align="center" valign="top"><para>À</para></entry>
<entry align="center" valign="top"><para>Ð</para></entry>
<entry align="center" valign="top"><para>à</para></entry>
<entry align="center" valign="top"><para>ð</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>01</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>!</para></entry>
<entry align="center" valign="top"><para>1</para></entry>
<entry align="center" valign="top"><para>A</para></entry>
<entry align="center" valign="top"><para>Q</para></entry>
<entry align="center" valign="top"><para>a</para></entry>
<entry align="center" valign="top"><para>q</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¡</para></entry>
<entry align="center" valign="top"><para>±</para></entry>
<entry align="center" valign="top"><para>Á</para></entry>
<entry align="center" valign="top"><para>Ñ</para></entry>
<entry align="center" valign="top"><para>á</para></entry>
<entry align="center" valign="top"><para>ñ</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>02</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>&ldquo;</para></entry>
<entry align="center" valign="top"><para>2</para></entry>
<entry align="center" valign="top"><para>B</para></entry>
<entry align="center" valign="top"><para>R</para></entry>
<entry align="center" valign="top"><para>b</para></entry>
<entry align="center" valign="top"><para>r</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¢</para></entry>
<entry align="center" valign="top"><para>²</para></entry>
<entry align="center" valign="top"><para>Â</para></entry>
<entry align="center" valign="top"><para>Ò</para></entry>
<entry align="center" valign="top"><para>â</para></entry>
<entry align="center" valign="top"><para>ò</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>03</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>#</para></entry>
<entry align="center" valign="top"><para>3</para></entry>
<entry align="center" valign="top"><para>C</para></entry>
<entry align="center" valign="top"><para>S</para></entry>
<entry align="center" valign="top"><para>c</para></entry>
<entry align="center" valign="top"><para>s</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>£</para></entry>
<entry align="center" valign="top"><para>³</para></entry>
<entry align="center" valign="top"><para>Ã</para></entry>
<entry align="center" valign="top"><para>Ó</para></entry>
<entry align="center" valign="top"><para>ã</para></entry>
<entry align="center" valign="top"><para>ó</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>04</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>$</para></entry>
<entry align="center" valign="top"><para>4</para></entry>
<entry align="center" valign="top"><para>D</para></entry>
<entry align="center" valign="top"><para>T</para></entry>
<entry align="center" valign="top"><para>d</para></entry>
<entry align="center" valign="top"><para>t</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¤</para></entry>
<entry align="center" valign="top"><para>´</para></entry>
<entry align="center" valign="top"><para>Ä</para></entry>
<entry align="center" valign="top"><para>Ô</para></entry>
<entry align="center" valign="top"><para>ä</para></entry>
<entry align="center" valign="top"><para>ô</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>05</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>%</para></entry>
<entry align="center" valign="top"><para>5</para></entry>
<entry align="center" valign="top"><para>E</para></entry>
<entry align="center" valign="top"><para>U</para></entry>
<entry align="center" valign="top"><para>e</para></entry>
<entry align="center" valign="top"><para>u</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¥</para></entry>
<entry align="center" valign="top"><para>µ</para></entry>
<entry align="center" valign="top"><para>Å</para></entry>
<entry align="center" valign="top"><para>Õ</para></entry>
<entry align="center" valign="top"><para>å</para></entry>
<entry align="center" valign="top"><para>õ</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>06</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>&amp;</para></entry>
<entry align="center" valign="top"><para>6</para></entry>
<entry align="center" valign="top"><para>F</para></entry>
<entry align="center" valign="top"><para>V</para></entry>
<entry align="center" valign="top"><para>f</para></entry>
<entry align="center" valign="top"><para>v</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¦</para></entry>
<entry align="center" valign="top"><para>¶</para></entry>
<entry align="center" valign="top"><para>Æ</para></entry>
<entry align="center" valign="top"><para>Ö</para></entry>
<entry align="center" valign="top"><para>æ</para></entry>
<entry align="center" valign="top"><para>ö</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>07</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>`</para></entry>
<entry align="center" valign="top"><para>7</para></entry>
<entry align="center" valign="top"><para>G</para></entry>
<entry align="center" valign="top"><para>W</para></entry>
<entry align="center" valign="top"><para>g</para></entry>
<entry align="center" valign="top"><para>w</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>§</para></entry>
<entry align="center" valign="top"><para>·</para></entry>
<entry align="center" valign="top"><para>Ç</para></entry>
<entry align="center" valign="top"><para>×</para></entry>
<entry align="center" valign="top"><para>ç</para></entry>
<entry align="center" valign="top"><para>÷</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>08</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>(</para></entry>
<entry align="center" valign="top"><para>8</para></entry>
<entry align="center" valign="top"><para>H</para></entry>
<entry align="center" valign="top"><para>X</para></entry>
<entry align="center" valign="top"><para>h</para></entry>
<entry align="center" valign="top"><para>x</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¨</para></entry>
<entry align="center" valign="top"><para>¸</para></entry>
<entry align="center" valign="top"><para>È</para></entry>
<entry align="center" valign="top"><para>Ø</para></entry>
<entry align="center" valign="top"><para>è</para></entry>
<entry align="center" valign="top"><para>ø</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>09</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>)</para></entry>
<entry align="center" valign="top"><para>9</para></entry>
<entry align="center" valign="top"><para>I</para></entry>
<entry align="center" valign="top"><para>Y</para></entry>
<entry align="center" valign="top"><para>i</para></entry>
<entry align="center" valign="top"><para>y</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>©</para></entry>
<entry align="center" valign="top"><para>¹</para></entry>
<entry align="center" valign="top"><para>É</para></entry>
<entry align="center" valign="top"><para>Ù</para></entry>
<entry align="center" valign="top"><para>é</para></entry>
<entry align="center" valign="top"><para>ù</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>0A</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>*</para></entry>
<entry align="center" valign="top"><para>:</para></entry>
<entry align="center" valign="top"><para>J</para></entry>
<entry align="center" valign="top"><para>Z</para></entry>
<entry align="center" valign="top"><para>j</para></entry>
<entry align="center" valign="top"><para>z</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>ª</para></entry>
<entry align="center" valign="top"><para>º</para></entry>
<entry align="center" valign="top"><para>Ê</para></entry>
<entry align="center" valign="top"><para>Ú</para></entry>
<entry align="center" valign="top"><para>ê</para></entry>
<entry align="center" valign="top"><para>ú</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>0B</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>+</para></entry>
<entry align="center" valign="top"><para>;</para></entry>
<entry align="center" valign="top"><para>K</para></entry>
<entry align="center" valign="top"><para>[</para></entry>
<entry align="center" valign="top"><para>k</para></entry>
<entry align="center" valign="top"><para>{</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>«</para></entry>
<entry align="center" valign="top"><para>»</para></entry>
<entry align="center" valign="top"><para>Ë</para></entry>
<entry align="center" valign="top"><para>Û</para></entry>
<entry align="center" valign="top"><para>ë</para></entry>
<entry align="center" valign="top"><para>û</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>0C</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>,</para></entry>
<entry align="center" valign="top"><para>&lt;</para></entry>
<entry align="center" valign="top"><para>L</para></entry>
<entry align="center" valign="top"><para>\</para></entry>
<entry align="center" valign="top"><para>l</para></entry>
<entry align="center" valign="top"><para>|</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¬</para></entry>
<entry align="center" valign="top"><para>¼</para></entry>
<entry align="center" valign="top"><para>Ì</para></entry>
<entry align="center" valign="top"><para>Ü</para></entry>
<entry align="center" valign="top"><para>ì</para></entry>
<entry align="center" valign="top"><para>ü</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>0D</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>-</para></entry>
<entry align="center" valign="top"><para>=</para></entry>
<entry align="center" valign="top"><para>M</para></entry>
<entry align="center" valign="top"><para>]</para></entry>
<entry align="center" valign="top"><para>m</para></entry>
<entry align="center" valign="top"><para>}</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>­</para></entry>
<entry align="center" valign="top"><para>½</para></entry>
<entry align="center" valign="top"><para>Í</para></entry>
<entry align="center" valign="top"><para>Ý</para></entry>
<entry align="center" valign="top"><para>í</para></entry>
<entry align="center" valign="top"><para>ý</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>0E</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>.</para></entry>
<entry align="center" valign="top"><para>&gt;</para></entry>
<entry align="center" valign="top"><para>N</para></entry>
<entry align="center" valign="top"><para>^</para></entry>
<entry align="center" valign="top"><para>n</para></entry>
<entry align="center" valign="top"><para>~</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>®</para></entry>
<entry align="center" valign="top"><para>¾</para></entry>
<entry align="center" valign="top"><para>Î</para></entry>
<entry align="center" valign="top"><para>Þ</para></entry>
<entry align="center" valign="top"><para>î</para></entry>
<entry align="center" valign="top"><para>þ</para></entry>
</row>
<row>
<entry align="center" valign="top"><para>0F</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>/</para></entry>
<entry align="center" valign="top"><para>?</para></entry>
<entry align="center" valign="top"><para>O</para></entry>
<entry align="center" valign="top"><para>_</para></entry>
<entry align="center" valign="top"><para>o</para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para></para></entry>
<entry align="center" valign="top"><para>¯</para></entry>
<entry align="center" valign="top"><para>¿</para></entry>
<entry align="center" valign="top"><para>Ï</para></entry>
<entry align="center" valign="top"><para>ß</para></entry>
<entry align="center" valign="top"><para>ï</para></entry>
<entry align="center" valign="top"><para>ÿ</para></entry>
</row>
</tbody>
</tgroup></table></para><para>There are a few things you need to know about <xref linkend="tab-latin1-character-set">. This manual <indexterm><primary>manual</primary></indexterm>is set up --- by hand, mind you --- to print all of these characters. That ain't the default. Nowhere near, in fact. Here are some of the details you'll need to bear in mind when using characters from the <indexterm><primary>typewriter</primary></indexterm>Latin1 character set:</para><itemizedlist><listitem><para>The characters at entries A2,<indexterm><primary>A2</primary></indexterm> A4, A5, A6 and AD -- the cent, the yen, the generic-currency-symbol, the broken vertical <indexterm><primary>vertical</primary></indexterm>bar, and the short dash -- are just plain missing in the default encodings. We don't know where they are or why this is the case.</para></listitem><listitem><para>Even if you've selected latin1 in the Document&nbsp;Layout dialog, users who have only the <indexterm><primary>typewriter</primary></indexterm>OT1-fonts for <application>LaTeX</application> <indexterm><primary>LaTeX</primary></indexterm>[or who have the <indexterm><primary>typewriter</primary></indexterm>T1-fonts but aren't using them] will still be missing a few characters: D0, F0, DE, FE, AB, and BB -- the uppercase and lowercase eth and thorn, and the french quotes -- won't show up<footnote><para>This is also true if you do use the T1 encoding, but instruct Openjade to use the Computer Modern family of fonts (in the T1 encoding this time, of course) through the setting of the %body-font-family%, %mono-font-family%, %title-font-family%, %admon-font-family% and %guilabel-font-family% DSSSL variables in the <ulink url="lyxtox-print-pdf.dsl">lyxtox-print-pdf.dsl</ulink> stylesheet (see <xref linkend="explain-DSSSL-stylesheets">) - as you can see very well in the PDF version of this document.</para></footnote>.</para></listitem><listitem><para>Users of <indexterm><primary>typewriter</primary></indexterm>OT1-fonts can, however, get the french quotes [characters AB and BB] if they include the either the package <indexterm><primary>typewriter</primary></indexterm>umlaute.sty or <indexterm><primary>typewriter</primary></indexterm>german.sty in their documents.<footnote><para>This only holds when you want to input these quotes by yourself. The automatic quote feature described in the &ldquo;Quotes&rdquo; Subsection of the LyX User's Guide (in the Section &ldquo;A Few Words about Typography&rdquo;), will generate automatically <application>LaTeX</application> code adapted to available fonts and packages.</para></footnote></para></listitem><listitem><para>If you use OT1 <indexterm><primary>OT1</primary></indexterm>font encoding,<indexterm><primary>encoding</primary></indexterm> i.e. if the <ulink url="jadetex.cfg">jadetex.cfg</ulink> file contains the line</para><screen><![CDATA[\usepackage[OT1]{fontenc}
]]></screen><para>(in which case it wouldn't make sense to use neither of the ae<indexterm><primary>ae</primary></indexterm>, aecompl<indexterm><primary>aecompl</primary></indexterm>, aeguill<indexterm><primary>aeguill</primary></indexterm>, umlaute<indexterm><primary>umlaute</primary></indexterm> or german packages<indexterm><primary>packages</primary></indexterm>, which are for the T1 <indexterm><primary>T1</primary></indexterm>encoding, i.e. you would have commented the lines:</para><screen><![CDATA[\usepackage{ae} 
]]><![CDATA[\usepackage{aecompl} 
]]><![CDATA[\usepackage{ae,aecompl} 
]]><![CDATA[\usepackage{german} 
]]><![CDATA[\usepackage{umlaute}
]]></screen><para>or those line would simply not be there), then in this case you <emphasis>must</emphasis> input the following characters in math <indexterm><primary>math</primary></indexterm>mode (see also the table &ldquo;How to Typeset Special Characters&rdquo; in <ulink url="http://makingtexwork.sourceforge.net/mtw/ch01.html">What Is TeX?</ulink>):</para><itemizedlist><listitem><para>
 <inlineequation>
  <alt>$
 &lt;  &lt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/18982.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/18982.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/18982.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/18982.bmp">
 ]]>

 </inlineequation> : two &ldquo;lower than&rdquo; signs, one after another<footnote><para>Not to be confused with the french quotes symbol (the &ldquo;guillemet&rdquo;).</para></footnote>. Enter math <indexterm><primary>math</primary></indexterm>mode and type the two signs.</para></listitem><listitem><para>
 <inlineequation>
  <alt>$
 &gt;  &gt; $
  </alt>
 <![ %output.print.png; [
 <graphic fileref="images/math/19607.png">
 ]]>
 <![ %output.print.pdf; [
 <graphic fileref="images/math/19607.png">
 ]]>
 <![ %output.print.eps; [
 <graphic fileref="images/math/19607.png">
 ]]>
 <![ %output.print.bmp; [
 <graphic fileref="images/math/19607.bmp">
 ]]>

 </inlineequation> : two &ldquo;greater than&rdquo; signs, one after another<footnote><para>Not to be confused with the french quotes symbol (the &ldquo;guillemet&rdquo;).</para></footnote>. Enter math <indexterm><primary>math</primary></indexterm>mode and type the two signs.</para></listitem><listitem><para>&lt; : &ldquo;lower than&rdquo; sign. Enter math <indexterm><primary>math</primary></indexterm>mode and type the sign.</para></listitem><listitem><para>&gt; : &ldquo;greater than&rdquo; sign. Enter math <indexterm><primary>math</primary></indexterm>mode and type the sign.</para></listitem><listitem><para>\: backslash. Enter math <indexterm><primary>math</primary></indexterm>mode and type &ldquo;\backslash&rdquo;.</para></listitem><listitem><para>_: underscore. Enter math <indexterm><primary>math</primary></indexterm>mode and type &ldquo;\textunderscore&rdquo;. From <ulink url="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=underscore">How to use the underscore character</ulink>:</para></listitem></itemizedlist><blockquote><para>The underscore character is ordinarily used in <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>to indicate a subscript in maths mode; if you type in the course of ordinary text, <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>will complain. If you're writing a document <indexterm><primary>document</primary></indexterm>which will contain a large number of underscore characters, the prospect of typing <indexterm><primary>typing</primary></indexterm>\ (or, worse, \textunderscore) for every one of them will daunt most ordinary people.</para><para>Moderately skilled macro <indexterm><primary>macro</primary></indexterm>programmers can readily generate a quick hack to permit typing <indexterm><primary>typing</primary></indexterm>to mean 'text underscore'. However, the code is somewhat tricky, and more importantly there are significant points where it's easy to get it wrong. There is therefore a package <emphasis>underscore</emphasis> which provides a general solution to this requirement.</para><para>There is a problem, though: OT1 <indexterm><primary>OT1</primary></indexterm>text fonts <indexterm><primary>fonts</primary></indexterm>don't contain an underscore character, unless they're in the typewriter <indexterm><primary>typewriter</primary></indexterm>version of the encoding <indexterm><primary>encoding</primary></indexterm>(used by fixed-width fonts <indexterm><primary>fonts</primary></indexterm>such as cmtt). So either you must ensure that your underscore characters only occur in text set in a typewriter <indexterm><primary>typewriter</primary></indexterm>font, or you must use a fuller encoding,<indexterm><primary>encoding</primary></indexterm> such as T1,<indexterm><primary>T1</primary></indexterm> which has an underscore character in every font.</para></blockquote><itemizedlist><listitem><para>|: vertical <indexterm><primary>vertical</primary></indexterm>bar. Enter math <indexterm><primary>math</primary></indexterm>mode and type the sign.</para></listitem></itemizedlist></listitem></itemizedlist><para>The following is a full list of all of the accented characters LyX <indexterm><primary>LyX</primary></indexterm>can display directly. It includes not only the accented characters from the previous table, but also the characters from <indexterm><primary>typewriter</primary></indexterm>ISO8859--2 through <indexterm><primary>typewriter</primary></indexterm>4. </para><itemizedlist><listitem><para>From <indexterm><primary>typewriter</primary></indexterm>ISO8859--1:</para><para>¨ Ä Ë Ï Ö Ü ä ë ï ö ü ÿdiaeresis</para><para>^ Â Ê Î Ô Û â ê î ô ûcircumflex</para><para>` À È Ì Ò Ù à è ì ò ùgrave</para><para>´ Á É Í Ó Ú Ý á é í ó ú ýacute</para><para>~ Ã Ñ Õ ã ñ õtilde</para><para>¸Ççcedilla</para><para>¯macron<footnote><para>The dead macron in usually not needed, as you will use a non--dead key for this instead. For example, S-M-minus, or if .Xmodmap is correct, S-M-macron.</para></footnote></para></listitem><listitem><para>From <indexterm><primary>typewriter</primary></indexterm>ISO8859--2 through <indexterm><primary>typewriter</primary></indexterm>4:</para><para>\^{H}\^{J}\^{h}\^{\j}\^{C}\^{G}\^{S}\^{c}\^{g}\^{s}circumflex</para><para>\'{S}\'{Z}\'{s}\'{z}\'{R}\'{L}\'{C}\'{N}\'{r}\'{l}\'{c}\'{n}acute</para><para>\~{I}\~{\i}\~{U}\~{u}tilde</para><para>\c{S}\c{s}\c{T}\c{t}\c{R}\c{L}\c{G}\c{r}\c{l}\c{g}\c{N}\c{K}\c{n}\c{k}cedilla<footnote><para>These characters might not look very nice on screen, but they will be just fine when run through <application>LaTeX</application> and printed.</para></footnote></para><para>\={E}\={e}\={A}\={I}\={O}\={U}\={a}\={\i}\={o}\={u}macron</para><para>\H{O}\H{U}\H{o}\H{u}hungarian umlaut</para></listitem></itemizedlist><para>All the characters above are actively supported by <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>fonts. In addition <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>allows diacritical marks on almost all characters . Also make sure you're using the <indexterm><primary>typewriter</primary></indexterm>T1 font-encoding and have the package <indexterm><primary>typewriter</primary></indexterm>umlaute.sty with the definition file <indexterm><primary>typewriter</primary></indexterm>iso.def installed.</para></sect2>
<sect2 id="lyx-international-spellcheck-support"><title>International Spellcheck Support</title><para>LyX <indexterm><primary>LyX</primary></indexterm>uses the <indexterm><primary>typewriter</primary></indexterm>ispell spelling checker. You should configure <indexterm><primary>typewriter</primary></indexterm>ispell to work with your system if it does not already. To get the appropriate language dictionary, refer to the <indexterm><primary>typewriter</primary></indexterm>Where file included with the <indexterm><primary>typewriter</primary></indexterm>ispell package. Note that some dictionaries do not support the <indexterm><primary>typewriter</primary></indexterm>Latin1 encoding.<indexterm><primary>encoding</primary></indexterm> If you have selected the <indexterm><primary>typewriter</primary></indexterm>Latin1 encoding <indexterm><primary>encoding</primary></indexterm>(in the Document&nbsp;Layout dialog) with one of these dictionaries, the spellchecker will not work for some people. Refer to the &ldquo;Spellchecking&rdquo; section of the LyX User's Guide for more details about international spellchecking.</para></sect2>
</sect1>
<sect1 id="openjade-localization"><title>Openjade localization</title><para>Openjade <indexterm><primary>Openjade</primary></indexterm>only supports a single pre-defined character repertoire. A character name of the form U-XXXX where XXXX are four upper-case hexadecimal dig- its, is recognized as referring to the Unicode character with that code. For many characters, it is also possible to use the ISO/IEC 10646 name in lower-case with words separated by hyphens.</para><para>Some common SDATA entity <indexterm><primary>entity</primary></indexterm>names from the ISO <indexterm><primary>ISO</primary></indexterm>entity sets are recognized and mapped to characters. In addition an SDATA entity <indexterm><primary>entity</primary></indexterm>name of the form U-XXXX, where XXXX are four upper-case hexadecimal digits, is mapped to the Unicode character with that code.</para><para>OpenJade <indexterm><primary>OpenJade</primary></indexterm>now supports the standard-chars, map-sdata-entity, add-name- chars, add-separator-chars and char-repertoire declaration element <indexterm><primary>element</primary></indexterm>forms, allowing a style-sheet <indexterm><primary>style-sheet</primary></indexterm>to define additional character names, sdata entity <indexterm><primary>entity</primary></indexterm>mappings, name characters (i.e. characters allowed in identifiers) and separator characters. Currently the only recognized character repertoire is the built-in repertoire. It has the public identifier <indexterm><primary>identifier</primary></indexterm>&quot;UNREGISTERED::OpenJade//Character Repertoire::OpenJade&quot;.</para></sect1>
<sect1 id="dvips-localization"><title>dvips localization</title><para>The only localization <indexterm><primary>localization</primary></indexterm>of dvips <indexterm><primary>dvips</primary></indexterm>available seems to be the redefinition of paper <indexterm><primary>paper</primary></indexterm>size, depending on the user's (or system's) locale. For example, to change the paper <indexterm><primary>paper</primary></indexterm>size to letter format (used in North America), one would do</para><screen><![CDATA[texconfig dvips paper lettersize
]]></screen><para>In <productname>SuSE</productname> Linux, this is done automatically <indexterm><primary>automatically</primary></indexterm>by the SuSEconfig.<indexterm><primary>SuSEconfig</primary></indexterm>tetex script (located in /sbin/conf.d/) by taking into account the LC_PAPER locale:</para><screen><![CDATA[function get_paper () {
]]><![CDATA[    ( 
]]><![CDATA[        . /etc/sysconfig/language &> /dev/null
]]><![CDATA[        read h w r < <(LANG=$RC_LANG locale -k LC_PAPER)
]]><![CDATA[        case "$h" in
]]><![CDATA[            height=297) echo a4     ;;
]]><![CDATA[            *)          echo letter ;;
]]><![CDATA[        esac
]]><![CDATA[    )
]]><![CDATA[}
]]><![CDATA[
]]></screen></sect1>
<sect1 id="DSSSL-stylesheet-localization"><title>DSSSL stylesheet localization</title><para>As distributed, the stylesheets use English for all generated text, but several other localization <indexterm><primary>localization</primary></indexterm>files are also provided.</para><para>Switching localizations <indexterm><primary>localizations</primary></indexterm>is achieved by writing a customization <indexterm><primary>customization</primary></indexterm>layer that references the proper localization <indexterm><primary>localization</primary></indexterm>file. The customization <indexterm><primary>customization</primary></indexterm>should look like this:</para><screen><![CDATA[<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
]]><![CDATA[<!ENTITY dbstyle PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA DSSSL>
]]><![CDATA[<!-- The path to the l10n file must be correct, of course, and should -->
]]><![CDATA[<!-- point to the print/html directory as appropriate for the preceding -->
]]><![CDATA[<!-- dbstyle -->
]]><![CDATA[<!ENTITY l10n    SYSTEM "docbook/print/dbl1dege.dsl" CDATA DSSSL>
]]><![CDATA[]>
]]><![CDATA[
]]><![CDATA[<style-sheet>
]]><![CDATA[<style-specification use="l10n docbook">
]]><![CDATA[<style-specification-body>
]]><![CDATA[
]]><![CDATA[;; Additional customization here, if desired
]]><![CDATA[
]]><![CDATA[</style-specification-body>
]]><![CDATA[</style-specification>
]]><![CDATA[
]]><![CDATA[<external-specification id="docbook" document="dbstyle">
]]><![CDATA[<external-specification id="l10n" document="l10n">
]]><![CDATA[
]]><![CDATA[</style-sheet>
]]></screen><para>Where dbl1dege.dsl is the name of the localization <indexterm><primary>localization</primary></indexterm>file you wish to use (German in this example). See <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/custom.html">Customizing the Stylesheets</ulink>. </para></sect1>
<sect1 id="TeX-localization"><title>TeX localization</title><para>Install the package latex-ucs (in <productname>SuSE</productname> <productname>Linux</productname> it is the <acronym>RPM</acronym> <indexterm><primary>RPM</primary></indexterm>package latex-ucs-20030605-18.noarch.rpm in the noarch directory of the distribution <indexterm><primary>distribution</primary></indexterm>CDs), or get it from CTAN <indexterm><primary>CTAN</primary></indexterm>from the directory macros/latex/contrib/unicode, for example from <ulink url="http://ctan.unsw.edu.au/macros/latex/contrib/unicode">CTAN latex-ucs package</ulink>.</para></sect1>
<sect1 id="lynx-localization"><title>lynx localization</title><para>From the lynx <indexterm><primary>lynx</primary></indexterm>manual <indexterm><primary>manual</primary></indexterm>page:</para><variablelist><varlistentry><term>-display_charset=MIMEname
</term><listitem><para>set the charset for the terminal output.</para></listitem></varlistentry></variablelist><para>NATIVE LANGUAGE SUPPORT</para><para>If configured and installed with Native Language Support, Lynx <indexterm><primary>Lynx</primary></indexterm>will display status and other messages in</para><para>your local language. See the file ABOUT_NLS in the source distribution,<indexterm><primary>distribution</primary></indexterm> or at your local GNU<indexterm><primary>GNU</primary></indexterm> site, for</para><para>more information about internationalization.</para><para>The following environment <indexterm><primary>environment</primary></indexterm>variables may be used to alter default settings:</para><variablelist><varlistentry><term>LANG
</term><listitem><para>This variable, if set, will override the default message language. It is an ISO <indexterm><primary>ISO</primary></indexterm>639 two-letter <indexterm><primary>two-letter</primary></indexterm>code identifying the language. Language codes are NOT the same as the country codes given in ISO <indexterm><primary>ISO</primary></indexterm>3166.</para></listitem></varlistentry><varlistentry><term>LANGUAGE
</term><listitem><para>This variable, if set, will override the default message language. This is a <acronym>GNU</acronym> <indexterm><primary>GNU</primary></indexterm>extension <indexterm><primary>extension</primary></indexterm>that has higher priority for setting the message catalog <indexterm><primary>catalog</primary></indexterm>than LANG or LC_ALL.</para></listitem></varlistentry><varlistentry><term>LC_ALL&nbsp;and&nbsp;LC_MESSAGES
</term><listitem><para>These variables, if set, specify the notion of native language formatting <indexterm><primary>formatting</primary></indexterm>style. They are POSIXly correct.</para></listitem></varlistentry><varlistentry><term>LINGUAS
</term><listitem><para>This variable, if set prior to configuration, limits the installed languages to specific values. It is a space-separated list of two-letter <indexterm><primary>two-letter</primary></indexterm>codes. Currently, it is hard-coded to a wish list.</para></listitem></varlistentry><varlistentry><term>NLSPATH
</term><listitem><para>This variable, if set, is used as the path <indexterm><primary>path</primary></indexterm>prefix for message catalogs.</para></listitem></varlistentry></variablelist><para>From the Unicode HOWTO:</para><para>Lynx-2.8 has an options screen (key 'O') which permits to set the display character set. When running in an xterm or <productname>Linux</productname> console in UTF-8 mode, set this to &quot;UNICODE UTF-8&quot;. Note that for this setting to take effect in the current browser <indexterm><primary>browser</primary></indexterm>session, you have to confirm on the &quot;Accept Changes&quot; field, and for this setting to take effect in future browser <indexterm><primary>browser</primary></indexterm>sessions, you have to enable the &quot;Save options to disk&quot; field and then confirm it on the &quot;Accept Changes&quot; field.</para><para>Now, again, all a document <indexterm><primary>document</primary></indexterm>needs is the following line between the &lt;head&gt; and &lt;/head&gt; tags:</para><para>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;</para><para>When you are viewing text files in UTF-8 encoding,<indexterm><primary>encoding</primary></indexterm> you also need to pass the command-line option &quot;-assume_local_charset=UTF-8&quot; (affects only file:/... URLs) or &quot;-assume_charset=UTF-8&quot; (affects all URLs). In lynx-2.8.2 you can alternatively, in the options screen (key 'O'), change the assumed document <indexterm><primary>document</primary></indexterm>character set to &quot;utf-8&quot;<indexterm><primary>utf-8</primary></indexterm>.</para></sect1>
<sect1 id="open-localization-problems"><title>Open localization problems</title><para>FIXME</para></sect1>
</chapter>
<chapter id="shortcomings-and-bugs"><title>Shortcomings and bugs </title><itemizedlist><listitem><para>Cross-references to elements other than sections or chapters. This seems to be a stylesheet <indexterm><primary>stylesheet</primary></indexterm>and/or Jade/Openjade limitation and not a limitation of LyX <indexterm><primary>LyX</primary></indexterm>(see the discussion of the &ldquo; xref <indexterm><primary>xref</primary></indexterm>to ANCHOR <indexterm><primary>ANCHOR</primary></indexterm>unsupported&rdquo; error in <xref linkend="errors-and-warnings">). Generally, it is a justified decision: the xref <indexterm><primary>xref</primary></indexterm>needs a text that will act as hyperling and this has to be supplied by the formatting <indexterm><primary>formatting</primary></indexterm>application. The formatting <indexterm><primary>formatting</primary></indexterm>application (Jade/Openjade here), in turn, does not in general know what text to put in xref,<indexterm><primary>xref</primary></indexterm> it just has a pointer to an id. But in the special case of figures <indexterm><primary>figures</primary></indexterm>(element &lt;mediaobject&gt;) I would like to see &ldquo;Figure&rdquo; (or some predefined text in the current language), followed by the figure number in the text to xref.<indexterm><primary>xref</primary></indexterm> If you modify the stylesheets for this, please send me your solution, so I can include it here.</para></listitem><listitem><para>Cross-references that appear in figure captions <indexterm><primary>captions</primary></indexterm>cannot be currently recognized - and this will break the automatic correction of the SGML <indexterm><primary>SGML</primary></indexterm>code for figures.<indexterm><primary>figures</primary></indexterm> In sedscr,<indexterm><primary>sedscr</primary></indexterm> we use</para><screen><![CDATA[<figure><title><graphic fileref="\([^"]*\)">[ ]*<anchor id="\([^"]*\)">
]]><![CDATA[\([^<]*\)<\/title>[ ]*<\/figure>
]]></screen><para>as the regular expression for LyX' SGML <indexterm><primary>SGML</primary></indexterm>for figures.<indexterm><primary>figures</primary></indexterm> If a cross-reference <indexterm><primary>cross-reference</primary></indexterm>is in the caption,<indexterm><primary>caption</primary></indexterm> this will break the \([^&lt;]*\) subexpression,<indexterm><primary>subexpression</primary></indexterm> which matches everything, up to the first occurence of a &ldquo;&lt;&rdquo;. It will not match up to the starting bracket of the ending title tag, but only up to the starting bracket of the cross-reference <indexterm><primary>cross-reference</primary></indexterm>(i.e. of &lt;xref linkend=&quot;reference-label&quot;&gt;).</para></listitem><listitem><para>Callouts (see <xref linkend="callouts">, <xref linkend="LyX-callouts">) will make your HTML <indexterm><primary>HTML</primary></indexterm>document NOT HTML <indexterm><primary>HTML</primary></indexterm>4.01 Transitional <indexterm><primary>Transitional</primary></indexterm>compliant! The W3C <indexterm><primary>W3C</primary></indexterm>validator will complain that</para><screen><![CDATA[document type does not allow element "IMG" here
]]></screen><para>Thus, if you want HTML <indexterm><primary>HTML</primary></indexterm>4.01 Transitional <indexterm><primary>Transitional</primary></indexterm>compliance (see <xref linkend="HTML-validation">), you will have not to use callouts.<indexterm><primary>callouts</primary></indexterm> I find callouts <indexterm><primary>callouts</primary></indexterm>very useful, so I will be happy to learn of a solution that is standards <indexterm><primary>standards</primary></indexterm>compliant and allows their use.</para></listitem><listitem><para>Figures that are &ldquo;intended&rdquo; one level deep in order to be vertically aligned with some preceding text that happens to be in the Description environment <indexterm><primary>environment</primary></indexterm>are not listed in the List of Figures that appears in the front page. This can best be illustrated with an example: see the <ulink url="http://www.karakas-online.de/EN-Book/">PHP-Nuke HOWTO</ulink>. </para><para>Examine the List of Figures below the Table of Contents in the front page.<footnote><para>You will have to scroll to the bottom (perhaps after setting the &ldquo;focus&rdquo; with a click somewhere in the text with the mouse, since it is a framed design) to see the List of Figures.</para></footnote> Now go to <ulink url="http://www.karakas-online.de/EN-Book/administration-functions.html">administration functions of PHP-Nuke</ulink>. There are a lot of figures <indexterm><primary>figures</primary></indexterm>there. Some of them are included in the List of Figures, others not. Those that are not included are the &ldquo;intended&rdquo; ones (in LyXese <indexterm><primary>LyXese</primary></indexterm>the key word is &ldquo; environment <indexterm><primary>environment</primary></indexterm>depth&rdquo; , which is set to one level deep for those figures,<indexterm><primary>figures</primary></indexterm> in order to be aligned with the text in the Description environment <indexterm><primary>environment</primary></indexterm>above them).</para><para>This is probably a bug of the stylesheets and may have been corrected already in newer versions. FIXME:<indexterm><primary>FIXME</primary></indexterm> I have to investigate this further. Any suggestions welcome.</para></listitem><listitem><para>The &lt;alt&gt; tag for images is not rendered in HTML <indexterm><primary>HTML</primary></indexterm>(see also <ulink url="http://sources.redhat.com/ml/docbook-apps/2002-q3/msg00519.html">Textobject and Alt tag</ulink>). In theory, the &lt;alt&gt; tag should contain the text that is included in the &lt;textobject&gt; tags of the &lt;mediaobject&gt; element.<indexterm><primary>element</primary></indexterm> In practice, it is not. Not with my ancient <indexterm><primary>ancient</primary></indexterm>(v. 1.72) stylesheets and not with newer ones (like v. 1.77, see <ulink url="http://sources.redhat.com/ml/docbook-apps/2002-q3/msg00539.html">Re: Textobject and Alt tag</ulink>). This has consequences for the mathematics <indexterm><primary>mathematics</primary></indexterm>(<xref linkend="mathematics">) part too: the &lt;alt&gt; tag is (mis)used by the DBTeXMath <indexterm><primary>DBTeXMath</primary></indexterm>method (<xref linkend="DBTeXMath">) to store the <application>TeX</application> <indexterm><primary>TeX</primary></indexterm>code that describes the equation displayed in the figure. Since the &lt;alt&gt; tag is not shown in HTML <indexterm><primary>HTML</primary></indexterm>(it is not present in the HTML source code of the rendered file), it will not show up in the TXT <indexterm><primary>TXT</primary></indexterm>version of the document <indexterm><primary>document</primary></indexterm>either. Thus, a mathematics <indexterm><primary>mathematics</primary></indexterm>text in the TXT <indexterm><primary>TXT</primary></indexterm>version will be lacking any information on the equations.<indexterm><primary>equations</primary></indexterm> Let's hope this will be corrected in the future. Note: I have corrected this bug using a set of dynamic sed scripts, see <xref linkend="alt-attributes-for-images">. Still, it would be interesting to know if there is a solution within the stylesheets themselves.</para></listitem><listitem><para>In PDFs the underscore is interpreted mathematically, making the character following the underscore to appear as a subscript. Moreover, if the link does not have an ending, it gets the standard ending for PDFs, namely &ldquo;.pdf&rdquo; attached to it, which is definitely wrong. Try this link: <ulink url="awkscr_insert_index_items">awkscr_insert_index_items</ulink>, in HTML and in PDF to see the difference!</para></listitem><listitem><para>The PDF files index will have multiple references to the same page. For example one index entry may have references to page 3,3,3,3,28 sort of thing. This is a known limitation of the collateindex.pl script. Quoting from <ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/indexing.html">Automatic Indexing with the DocBook DSSSL Stylesheets</ulink>:</para><blockquote><para>Any generated index is perhaps better than none, but there are still a few things that cannot be accomplished:</para><blockquote><para>1. Duplicate page numbers are not suppressed in the index. If the document contains three indexing hits on page 4, the generated index will contain &ldquo;4, 4, 4&rdquo;.</para><para>2. Ranges are not automatically constructed. If the document contains indexing hits on pages 4, 5, 6, and 7, the generated index will contain &ldquo;4, 5, 6, 7&rdquo; instead of &ldquo;4-7&rdquo;.</para></blockquote><para>This is also discussed in <ulink url="http://www.karakas-online.de/forum/viewtopic.php?t=4444">Index having multiple entries to the same page in PDF files</ulink>.</para></blockquote></listitem></itemizedlist></chapter>
<chapter id="other-methods"><title>Other methods </title><para>Various other methods exist that are related to the one presented here. This method is unique in that it uses LyX <indexterm><primary>LyX</primary></indexterm>and a lot of script &ldquo; glue <indexterm><primary>glue</primary></indexterm>code&rdquo; to hide the complexity <indexterm><primary>complexity</primary></indexterm>of writing in SGML <indexterm><primary>SGML</primary></indexterm>from the user. However, if for some reason you prefer to not use LyX,<indexterm><primary>LyX</primary></indexterm> the shell scripts, the stylesheets or some other part of this method, you might want to have a look at the following alternatives:</para><itemizedlist><listitem><para>Use a makefile <indexterm><primary>makefile</primary></indexterm>like the one in <ulink url="http://www.miwie.org/docbkmake/docbookmk.html">DocBook Makefile Templates</ulink> (in this link, if you open it and scroll up to the end, you will find the influential posting of Nik Clayton<indexterm><primary>Clayton</primary></indexterm> that outlined a working way to get images in all formats of a document<indexterm><primary>document</primary></indexterm> (see <xref linkend="explain-figures">), definitely a recommended reading).</para></listitem><listitem><para>Use the <ulink url="http://www.tldp.org/LDP/LDP-Author-Guide/tools-hints.html">makefile of the LDP</ulink>.</para></listitem><listitem><para>Use the O'Reilly <indexterm><primary>O'Reilly</primary></indexterm>stylesheets. The collection comprises an initial pass at documenting and publishing<indexterm><primary>publishing</primary></indexterm> the stylesheets used by ORA to convert <indexterm><primary>convert</primary></indexterm>DocBook documents into HTML <indexterm><primary>HTML</primary></indexterm>for CD-ROM <indexterm><primary>CD-ROM</primary></indexterm>publication, and conversion of DocBook <indexterm><primary>DocBook</primary></indexterm>into tagged <indexterm><primary>tagged</primary></indexterm>Frame for print publication <indexterm><primary>publication</primary></indexterm>and for copy returned to non-SGML-using <indexterm><primary>non-SGML-using</primary></indexterm>authors.</para><para>The stylesheets are in the form of a single SGML <indexterm><primary>SGML</primary></indexterm>document which is both a DocBook <indexterm><primary>DocBook</primary></indexterm>&lt;book&gt; documenting the stylesheets and the stylesheets themselves. </para><para>FIXME: Unfortunately, all my efforts to locate the &ldquo; O'Reilly <indexterm><primary>O'Reilly</primary></indexterm>DSSSL <indexterm><primary>DSSSL</primary></indexterm>Stylesheets&rdquo; on the Web <indexterm><primary>Web</primary></indexterm>were unsuccessfull. The links I had and those I find, all point to non-existent resources.</para></listitem><listitem><para>There have been various previous attempts at a script solution to document<indexterm><primary>document</primary></indexterm> generation, see i.e. in <ulink url="http://lists.oasis-open.org/archives/docbook/200109/msg00015.html">the docbook mailing list</ulink></para></listitem><listitem><para>In <ulink url="http://developers.cogentrts.com/cogent/prepdoc/book1.html">Preparing Cogent Documentation</ulink>, you will find another detailed discussion of the document <indexterm><primary>document</primary></indexterm>production <indexterm><primary>production</primary></indexterm>process using SGML/XML.</para></listitem></itemizedlist></chapter>
<chapter id="bibliography"><title>Bibliography </title><note> 
<title>Note</title> 
<para> 
This is not the Bibliography produced by RefDB (<xref linkend="Refdb">), but just a chapter with this misleading title, containing some links to other sources. The RefBDB Bibliography bears the name &ldquo;Reference List&rdquo; or &ldquo;References&rdquo; and is located even further down, near the end of the document.
</para> 
</note>
<itemizedlist><listitem><para><ulink url="http://www.doc.ic.ac.uk/~iwm/sgml_xml.html">SGML and XML text processing</ulink>: Contains a comprehensive list of links to everything around SGML <indexterm><primary>SGML</primary></indexterm>and XML document <indexterm><primary>document</primary></indexterm>processing.<indexterm><primary>processing</primary></indexterm> </para></listitem><listitem><para><ulink url="http://www.dpawson.co.uk/docbook/reference.html">Docbook Basics and References</ulink></para></listitem><listitem><para><ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/">DocBook Modular Stylesheets</ulink></para></listitem><listitem><para><ulink url="http://www.troubleshooters.com/tpromag/200201/200201.htm">Troubleshooting LyX for a DocBook book</ulink></para></listitem><listitem><para><ulink url="http://www.tldp.org/authors/index.html#resources">LDP Author's Resources page</ulink> - templates, links, and tools.<indexterm><primary>tools</primary></indexterm></para></listitem><listitem><para><ulink url="http://www.tldp.org/LDP/LDP-Author-Guide/html/index.html">LDP Author Guide</ulink></para></listitem><listitem><para><ulink url="http://docbook.org/tdg/en/html/quickref.html">DocBook Quick Reference (v3.1,  v4.1.2)</ulink></para></listitem><listitem><para><ulink url="http://nwalsh.com/docbook/dsssl/">Norman Walsh DSSSL</ulink></para></listitem><listitem><para><ulink url="http://docbook.org/tdg/en/html/">DocBook: The definitive Guide</ulink>. You can browse this book online <ulink url="http://docbook.org/tdg/en/html/">here</ulink> or you can download it at http://ww w.docbook.org/tdg/index.html.(aus NewbieDocDocb<indexterm><primary>NewbieDocDocb</primary></indexterm>ookGuide.htm)</para></listitem><listitem><para>For a more compact introduction to SGML <indexterm><primary>SGML</primary></indexterm>, with practical examples that cover most cases, see NewbieDocDocbookGuide.htm.<indexterm><primary>NewbieDocDocbookGuide.htm</primary></indexterm></para></listitem><listitem><para>Writing Self-Published <indexterm><primary>Self-Published</primary></indexterm>Books with Lyx (from books_with_lyx.html).</para></listitem><listitem><para>DocBook <indexterm><primary>DocBook</primary></indexterm>with LyX <indexterm><primary>LyX</primary></indexterm>(from db4lyx.pdf)</para></listitem><listitem><para><ulink url="http://docbook.sourceforge.net/release/dsssl/current/doc/indexing.html">Automatic Indexing in DocBook</ulink></para></listitem><listitem><para><ulink url="http://refdb.sourceforge.net/tutorial/c1093.html">RefDB tutorial</ulink></para></listitem><listitem><para><ulink url="http://www.miwie.org/docbook-dsssl-faq.html">DocBook DSSSL stylesheets FAQ</ulink></para></listitem><listitem><para><ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/fixingproblems.html">Customizing Document Production</ulink>, (<ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/fixingproblems.pdf">PDF version</ulink>), written by Pascal Lo Ré of <productname>Mandrake</productname>.<indexterm><primary>Mandrake</primary></indexterm></para></listitem><listitem><para><ulink url="http://www.jclark.com/jade/transform.htm">Using Jade for SGML transformations</ulink>: explains some of the mechanisms used in <ulink url="http://www.linux-mandrake.com/en/doc/project/pascal/fixingproblems.html">Customizing Document Production</ulink> and in the stylesheets described here.</para></listitem><listitem><para><ulink url="http://newbiedoc.sourceforge.net/metadoc/docbook-guide.html">NewbieDoc DocBook Guide</ulink>: the HTML <indexterm><primary>HTML</primary></indexterm>stylesheet <indexterm><primary>stylesheet</primary></indexterm>I use comes from this project, with some additions from the ldp.dsl <indexterm><primary>ldp.dsl</primary></indexterm>of the <productname>Linux</productname> Documentation Project.</para></listitem><listitem><para><ulink url="http://www.w3.org/MarkUp/SGML/">Overview of SGML resources</ulink></para></listitem><listitem><para><ulink url="http://xml.coverpages.org/sgml.html">SGML and XML</ulink> on coverpages.org</para></listitem><listitem><para><ulink url="http://www.tei-c.org/Vault/GL/P3/SG.htm">A gentle introduction to SGML</ulink></para></listitem><listitem><para><ulink url="http://www.nag.co.uk/projects/openmath/mml-files">MathML DSSSL stylesheets</ulink>: An old collection of tools <indexterm><primary>tools</primary></indexterm>for doing MathML <indexterm><primary>MathML</primary></indexterm>with DSSSL <indexterm><primary>DSSSL</primary></indexterm>and Jade.<indexterm><primary>Jade</primary></indexterm></para></listitem><listitem><para><ulink url="http://www.dpawson.co.uk/docbook/dsssl/dssslgeneral.html">General DSSSL stylesheet questions</ulink></para></listitem><listitem><para><ulink url="http://www.dpawson.co.uk/docbook">DocBook FAQ</ulink></para></listitem><listitem><para><ulink url="http://www.oasis-open.org/cover/dsssl.html">DSSSL resources on coverpages.</ulink></para></listitem><listitem><para><ulink url="http://sources.redhat.com/lists.html#docbook-tools">DocBook tools, DSSSL, sgmltool and various other mailing lists</ulink></para></listitem><listitem><para><ulink url="http://ricardo.ecn.wfu.edu/~cottrell/dbtexmath">DBTeXMath</ulink></para></listitem><listitem><para><ulink url="http://www.dessci.com/en/support/tutorials/mathml/default.htm">A gentle introduction to MathML</ulink></para></listitem><listitem><para><ulink url="http://xml.coverpages.org/mathML.html">MathML</ulink> on coverpages.org</para></listitem><listitem><para><ulink url="http://bgu.chez.tiscali.fr/doc/db4lyx/index.html">DocBook with LyX</ulink></para></listitem><listitem><para><ulink url="Lyx-DocBook-HOWTO.pdf">Lyx-DocBook-HOWTO.pdf</ulink></para></listitem><listitem><para><ulink url="http://hvdkooij.xs4all.nl/docs-docbook.en.cms">Setup your own docbook processing</ulink>: An alternative way to automate document <indexterm><primary>document</primary></indexterm>processing<indexterm><primary>processing</primary></indexterm></para></listitem><listitem><para><ulink url="http://docbook.org/wiki/moin.cgi/ConvertOtherFormatsToDocBook">Convert other formats to DocBook</ulink>, a comprehensive list of available tools <indexterm><primary>tools</primary></indexterm>for converting to DocBook<indexterm><primary>DocBook</primary></indexterm></para></listitem><listitem><para><ulink url="http://www.ibnm.uni-hannover.de/Mitarbeiter/beuerman/LaTeX2PDF.pdf">Erstellung von pdf-Dokumenten mit LaTeX</ulink></para></listitem><listitem><para><ulink url="LaTeX2PDFLaTeX.pdf">How to convert a <application>LaTeX</application> document into a PDFLaTeX document</ulink>, by Patrick S. Vogt, Basel Univ., Switzerland. FIXME:<indexterm><primary>FIXME</primary></indexterm> no URL <indexterm><primary>URL</primary></indexterm>found anymore!</para></listitem><listitem><para><ulink url="http://www.cis.ohio-state.edu/~gurari/docs/mml-00/mml-00.html">From <application>LaTeX</application> to MathML and Back with TeX4ht and PassiveTeX</ulink></para></listitem><listitem><para><ulink url="http://www.cis.ohio-state.edu/~gurari/TeX4ht/mn.html">TeX4ht: <application>LaTeX</application> and <application>TeX</application> for Hypertext</ulink>See Resources there, for more links to alternative converters.</para></listitem><listitem><para><ulink url="http://mathforum.org/typesetting/index.html#T">Math Typesetting for the Internet</ulink></para></listitem><listitem><para><ulink url="http://www.contenu.nu/socog.html">Reader's guide to Sydney Olympics accessibility complaint</ulink></para></listitem><listitem><para><ulink url="http://www.tomw.net.au/2001/bat2001.html">Olympic Failure: A Case for Making the Web Accessible</ulink></para></listitem><listitem><para><ulink url="http://bobby.watchfire.com/bobby/html/en/index.jsp">Bobby Accessibility Test</ulink></para></listitem><listitem><para><ulink url="http://developers.cogentrts.com/cogent/prepdoc/book1.html">Preparing Cogent Documentation</ulink>: Offers a detailed discussion of the document <indexterm><primary>document</primary></indexterm>production <indexterm><primary>production</primary></indexterm>process using SGML/XML.</para></listitem><listitem><para><ulink url="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/docbooksys/segmentedhtml/index.html">Installing And Using An XML/SGML DocBook Editing Suite</ulink></para></listitem></itemizedlist></chapter>
&appendix;
&bibliography;
&index;
</book>

