<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/technology/cnxml/schema/dtd/0.5/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" xmlns:m="http://www.w3.org/1998/Math/MathML" id="new">
  <name>Creating Connexions Content Using LyX</name>
  <metadata>
  <md:version>1.5</md:version>
  <md:created>2005/10/30 15:02:37 US/Central</md:created>
  <md:revised>2006/02/23 19:38:44.434 US/Central</md:revised>
  <md:authorlist>
      <md:author id="cjwinstead">
      <md:firstname>Chris</md:firstname>
      <md:othername>James</md:othername>
      <md:surname>Winstead</md:surname>
      <md:email>winstead@engineering.usu.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="cjwinstead">
      <md:firstname>Chris</md:firstname>
      <md:othername>James</md:othername>
      <md:surname>Winstead</md:surname>
      <md:email>winstead@engineering.usu.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>authoring Connexions modules</md:keyword>
    <md:keyword>CNXML</md:keyword>
    <md:keyword>LaTeX</md:keyword>
    <md:keyword>LyX</md:keyword>
    <md:keyword>MathML</md:keyword>
  </md:keywordlist>

  <md:abstract>Connexions modules can be easily developed using a technical word processor called LyX. LyX is a graphical editor designed as a front-end for creating LaTeX documents. This module introduces a Perl script, called LyX2cnx, which translates LyX files into CNXML. LyX's native file structure serves as a "meta-format" which is easily translated into LaTeX and Connexions formats. This makes it easy to create multi-purpose content that can be quickly converted to Connexions modules, LaTeX files or PDF documents. The LyX2cnx translator also handles conversion of TeX equations using calls to the freely-available Tralics Tex-to-MathML translator. This Connexions module was written using LyX and translated with LyX2cnx.</md:abstract>
</metadata>
  <content>

<section id="sec:Introduction">
<name> 
Introduction.
</name>
<para id="para1">
 Readers already familiar with LyX can skip ahead to  <cnxn target="sec:Requirements"/> for requirements/usage,  <cnxn target="sec:Supported"/> for supported features, and  <cnxn target="sec:Examples"/> for example modules. 
</para>
<para id="para2">
 Many educators in technical fields such as physics, engineering, chemistry,
 etc have prepared course materials using the LaTeX system.
 Many also find it convenient to create these documents using a free technical
 word-processor called LyX.
 The LaTeX format is significantly different from the Connexions XML format,
 which might dissuade LaTeX enthusiasts from contributing Connexions content. 
</para>
<para id="para3">
 This module offers a Perl translation script, called lyx2cnx.pl, that directly
 converts a LyX document to a Connexions XML document.
 A user should be able to simply type a document in LyX, convert it using
 lyx2cnx, then import it to Connexions as Plain XML.
 This module gives instructions for creating Connexions modules using LyX. 
</para>
<para id="para4">
 Please note that this script is an alpha version.
 It works well for my authoring habits (see the provided examples), but
 others may find it buggy.
 The author appreciates any bug reports.
 If you have a LyX file that won't convert, please send it to me and I'll
 try and work out the problem. 
</para>
</section>
<section id="sec:Lyx">
<name> 
 Introduction: What is LyX?
</name>
<para id="para5">
 LyX is a free, open-source, cross-platform GUI word-processor designed for
 authoring technical documents, similar to programs like Scientific Word.
 LyX can create PDF and Postscript output using the popular LaTeX engine
 for technical typesetting.
 By itself, LaTeX can be quite complicated.
 LyX offers the power of LaTeX with the simplicity of a word processor.
 Versions of LyX are available for Windows, Linux, Unix and Mac OSX platforms
 and can be downloaded at <link src="http://www.lyx.org">www.LyX.org</link>. 
</para>
<para id="para6">
 LyX offers a graphical equation editor, one of the best and easiest in existence.
 The philosophy of LyX is "What You See is What You Mean" (WYSIWYM), meaning the user focuses on the document's content - equations,
 figures, sections, etc - and the formatting is handled automatically by
 the LaTeX engine.
 This is very similar to the philosophy of Connexions and XML. 
</para>
<para id="para7">
 LyX is customizable, allowing the user to specify the types of content that
 are available.
 This makes it easy to represent the available Connexions content tags within
 LyX.
 The user types in blocks of text, choosing the desired content-type using
 a drop-down menu.
 There are no tags to worry about. 
</para>
<para id="para8">
 A primary motivation for using LyX as a front-end for Connexions is to enable
 offline development of multi-use content.
 Course materials can be complex and are best developed using offline editing
 tools.
 If I go to the trouble of creating a course text, I would like to be able
 to easily compile professional-quality PDF files of that content.
 MS Word is one option for doing this, except that using it is only slightly
 less painful than gouging your own eyes out. 
</para>
<para id="para9">
 LyX does everything Word does and a million things that Word can't do, and
 LyX does it all for free.
 It seamlessly integrates text editing with placement of numbered figures,
 equations and bibliography items.
 It has customizable fields for stating a document's title, author, abstract,
 keywords, and any other information deemed necessary.
 A LyX document is easily converted to LaTeX, to PostScript, and to PDF
 formats.
  <cnxn target="fig:pdf_output"/> shows the appearance of the PDF output for this module created by LyX (which
 calls pdfLaTeX in the background). 
</para>
<para id="para10">
 As this module shows, it is also easy to convert from the LyX format to
 CNXML, making LyX an ideal choice for creating multi-purpose technical
 content. 
</para>
<figure id="fig:pdf_output">
  <media type="image/png" src="pdf_output.png"/>
  <caption>
 
 An example page from the PDF version of this module as produced by LyX.
  </caption>
</figure>
 
</section>
<section id="sec:Requirements">
<name> 
Requirements and Usage.
</name>
<para id="para11">
 The lyx2cnx script requires 
<term> 
LyX
</term>  
, 
<term> 
perl
</term>  
 and 
<term> 
tralics
</term> .
 Tralics is a LaTeX-to-XML translator used for converting equations.
 The lyx2cnx script expects "tralics" to be in the system's executable search path.
 Get Tralics from the <link src="http://www-sop.inria.fr/apics/tralics/">APICS</link> 
 web site. 
</para>
<para id="para12">
 Lyx2cnx is designed to be run from the *nix command line.
 The usage is simple: 
<code> 
lyx2cnx lyxfile cnxfile
</code> .
 The script also looks for a file called 
<code> 
template.cnxml
</code>  
 in the document's directory.
 This file contains the header and footer for the Connexions module.
 To create a module in LyX, place lyx2cnx in your system's search path and
 follow these steps: 
</para>
<list id="list1" type="enumerated">
<item>Create the module in Connexions.
 Enter the title, keywords, abstract, etc.</item>
<item>Export the module as Plain XML, and save it as 
<code> 
template.cnxml
</code>  
 in a working directory on your local machine.</item>
<item>Run LyX and type your content.</item>
<item>Save your file, e.g.
 
<code> 
module.lyx
</code>  
, and run 
<code> 
lyx2cnx module.lyx module.cnxml
</code> .</item>
<item>Import 
<code> 
module.cnxml
</code>  
 as Plain XML in Connexions.</item>
<item>Upload any images included in your document (png format seems to work best).</item>
</list>
</section>
<section id="sec:Supported">
<name> 
Supported Features.
</name>
<para id="para13">
 Lyx2cnx works by translating LyX layouts directly into CNXML tags.
 At present, not all CNXML features are mapped to LyX layouts.
 In the current version, the user can create 
</para>
<list id="list2">
<item>Sections.</item>
<item>Paragraphs.</item>
<item>Figures (captioned or uncaptioned).</item>
<item>Equations (inline and displayed).</item>
<item>Lists (enumerated and bulletted; the &lt;name&gt; field is not yet supported).</item>
<item>Cross-references to Figures, Sections and Equations.</item>
<item>URLs.</item>
<item> "Term," "emphasized" and "code" text attributes.</item>
</list>
<para id="para14">
 These features are not exhaustive, but are sufficient to create good technical
 Connexions modules. 
</para>
</section>
<section id="sec:Examples">
<name> 
Example Modules.
</name>
<para id="para15">
 These modules were created using LyX and lyx2cnx: 
</para>
<list id="list3">
<item>This module [<link src="http://cnx.rice.edu/content/m13238/latest/connexions-and-lyx.tgz">LyX source (tgz)</link> 
].</item>
<item> "Mobile Carriers and the Fermi Function" [<link src="http://cnx.org/content/m13458/latest/">Module page</link> 
] [<link src="http://cnx.org/content/m13458/latest/mobile-carriers.tgz">LyX source (tgz)</link> 
].</item>
</list>
</section>
<section id="sec:paragraphs">
<name> 
Creating Sections and Paragraphs in LyX.
</name>
<para id="para16">
 Paragraphs and sections are created in much the same way as with other word
 processors.
 In the upper left corner of the LyX main window, there is a drop-down box
 containing <emphasis>Layout</emphasis> options.
 The Layout determines the content type for a line or paragraph.
 The default Layout is "Standard".
 To create a paragraph, just start typing text in Standard mode.
 Press Enter to start a new paragraph.
 To start a new Section, select the "Section" Layout from the Layout box.
 Experienced LyX users may also take advantage of numerous hot-key shortcuts
 to change layout environments. 
</para>
</section>
<section id="sec:figures">
<name> 
Creating Figures.
</name>
<para id="para17">
 In LyX, figures are placed inside of "floats." A float is a movable box containing graphics and a caption.
 When LaTeX compiles a document, it moves the float around until it finds
 a best-fit position.
 Thus the figure is said to "float".
 The user only needs to place the float in an approximate desired location,
 and LaTeX handles the rest. 
</para>
<para id="para18">
 The LyX-CNXML translator uses floats to recognize figures.
 To place a Figure within a LyX document, select Insert
<m:math><m:mo>→</m:mo></m:math>
 
Floats
<m:math><m:mo>→</m:mo></m:math>
 
Figure from the LyX menu bar.
 A box appears within your document with a caption line labeled "Figure:".
 Press return.
 Now select Insert
<m:math><m:mo>→</m:mo></m:math>
 
Graphics to place your media.
 Then return to the caption line, select Insert
<m:math><m:mo>→</m:mo></m:math>
 
Label from the menu bar, and enter text to serve as an id for your figure.
 Finally, enter the caption text just after the label. 
</para>
<para id="para19">
 <cnxn target="fig:placing_figures"/> shows an example of a Figure float in LyX.
 Namely,  <cnxn target="fig:placing_figures"/> shows the placement of itself within LyX during the preparation of this
 document.
 I apologize for any eyestrain which may result from this example. 
</para>
<para id="para20">
 Once the Figure has been placed in according to these instructions, the
 CNXML translator handles the creation of &lt;figure&gt; and &lt;media&gt; tags.
 The user is now done, except that each graphic file must be manually uploaded
 to the Connexions module workspace.
 I have noticed some bugs with file formats other than PNG, so I recommend
 using PNG images. 
</para>
<figure id="fig:placing_figures">
  <media type="image/png" src="figure_placement.png"/>
  <caption>
 
Example of Figure placement within LyX.
  </caption>
</figure>
 
</section>
<section id="sec:cxrefs">
<name> 
Using Cross-References.
</name>
<para id="para21">
 To place a cross-reference in LyX, select Insert
<m:math><m:mo>→</m:mo></m:math>
 
Cross Reference from the application's menu bar.
 This raises a menu of cross-references.
 Select the one you want.
 For example, I can follow this procedure to refer to  <cnxn target="fig:placing_figures"/> or  <cnxn target="sec:cxrefs"/>.
 Lyx2cnx converts LyX cross-references into internal links within the Connexions
 module. 
</para>
<para id="para22">
 Lyx2cnx will also strip leading words from cross-references, such as "Figure" , "Fig." , "Section" or "Sec." This is because Connexions renders a cross-reference by printing its type
 and number, e.g. "Figure 2." LaTeX, on the other hand, would just print "2." If you want to also use the module as a LaTeX source to generate PDF files,
 you should type the word "Figure" before any figure cross-reference. 
</para>
</section>
<section id="sec:eqns">
<name> 
Creating Equations.
</name>
<para id="para23">
 LyX represents equations in the TeX format.
 At present, the CNXML translator extracts all TeX equations and uses Tralics
 to convert them to XML.
 For most equations, for example 
<m:math><m:mrow><m:mi>y</m:mi><m:mo>=</m:mo><m:msup><m:mi>e</m:mi> <m:mi>x</m:mi> </m:msup></m:mrow></m:math>
 
, this method produces good results.
 The Tralics system is simple, extremely easy to download, install and use.
 It is available from the <link src="http://www-sop.inria.fr/apics/tralics/">APICS</link> 
 group's web site.
 Tralics does not produce Content MathML, but it works well as a quick solution
 for authoring draft Connexions modules.
 A method is also provided, as described below, for users to supply their
 own MathML translations, bypassing Tralics if desired. 
</para>
<para id="para24">
 To create an inline equation in LyX, press Ctrl-m.
 To make a displayed equation, press Ctrl-Shift-M.
 Access the Math Panel by selecting Insert
<m:math><m:mo>→</m:mo></m:math>
 
Math
<m:math><m:mo>→</m:mo></m:math>
 
Math_Panel from the menu bar.
 Use the Math Panel to type in the equation.
 For displayed equations, use Insert
<m:math><m:mo>→</m:mo></m:math>
 
Label to assign an id to the equation.
 If you want to use the CNXML translator to process the equation, you are
 done. 
</para>
<para id="para25">
 If you want to control how the equation appears in the final Connexions
 module, you can insert a custom translation by placing it within a Minipage
 just after the LyX equation.
 A Minipage is just what it sounds like: a page within the page you are
 writing.
 In LaTeX, a mini-page can contain everything a regular page contains.
 In LyX, a minipage can be collapsed into a small icon, which is a convenient
 way of hiding garish XML. 
</para>
<para id="para26">
 To insert a Minipage, select Insert
<m:math><m:mo>→</m:mo></m:math>
 
Minipage from the main menu bar.
 Then select the "Comment" layout and paste the desired translation into the Minipage.
 To collapse the Minipage and get it out of the way, simply click on the "Minipage" tab. 
</para>
<para id="para27">
 As an example,  <cnxn target="eq:fourier1"/>  is presented in MathML created by MathType.
  <cnxn target="eq:fourier2"/>  shows the same equation written in LyX, translated automatically by Tralics
 through the lyx2cnx script. 
</para>
<para id="para28">
 
<equation id="eq:fourier1">
<m:math display="block"> <m:semantics> <m:mrow> <m:mi>F</m:mi><m:mrow><m:mo>(</m:mo> <m:mi>ω</m:mi> <m:mo>)</m:mo></m:mrow><m:mo>=</m:mo><m:mstyle displaystyle="true"> <m:mrow><m:munderover> <m:mo>∫</m:mo> <m:mrow> <m:mo>−</m:mo><m:mi>∞</m:mi> </m:mrow> <m:mi>∞</m:mi> </m:munderover> <m:mrow> <m:mi>f</m:mi><m:mrow><m:mo>(</m:mo> <m:mi>t</m:mi> <m:mo>)</m:mo></m:mrow><m:msup> <m:mi>e</m:mi> <m:mrow> <m:mi>j</m:mi><m:mi>ω</m:mi><m:mi>t</m:mi> </m:mrow> </m:msup> <m:mi>d</m:mi><m:mi>t</m:mi> </m:mrow> </m:mrow> </m:mstyle> </m:mrow><m:annotation encoding="MathType-MTEF"/></m:semantics></m:math>
</equation>
 
 
 
<equation id="eq:fourier2">
<m:math><m:mrow><m:mi>F</m:mi><m:mfenced open="(" close=")"><m:mrow><m:mi>ω</m:mi></m:mrow></m:mfenced><m:mo>=</m:mo><m:msubsup><m:mo>∫</m:mo> <m:mrow><m:mo>-</m:mo><m:mi>∞</m:mi></m:mrow> <m:mi>∞</m:mi> </m:msubsup><m:mi>f</m:mi><m:mfenced open="(" close=")"><m:mrow><m:mi>t</m:mi></m:mrow></m:mfenced><m:msup><m:mi>e</m:mi> <m:mrow><m:mi>j</m:mi><m:mi>ω</m:mi><m:mi>t</m:mi></m:mrow> </m:msup><m:mi>d</m:mi><m:mi>t</m:mi><m:mo>.</m:mo></m:mrow></m:math>
</equation>
 
</para>
<para id="para29">
 <cnxn target="fig:equations"/> shows the appearance of these equations within LyX.
 The Minipage under  <cnxn target="eq:fourier1"/>  is collapsed, and the Minipage under  <cnxn target="eq:fourier2"/>  is expanded, showing its contents.
  <cnxn target="fig:pdfeqns"/> shows the appearance of the equations in a PDF file compiled by pdflatex
 from within LyX. 
</para>
<figure id="fig:equations">
  <media type="image/png" src="equations_lyx.png"/>
  <caption>
 
 Appearance of equations within LyX.
  </caption>
</figure>
 
<figure id="fig:pdfeqns">
  <media type="image/png" src="equations_pdf.png"/>
  <caption>
 
 Rendering of equations in the PDF file produced by LyX.
  </caption>
</figure>
 
</section>
<section id="sec:Inline_tags">
<name> 
Inline tags.
</name>
<para id="para30">
 Some inline tags, such as "emphasis" and "link" , have a natural correspondence to LyX features.
 To use the <emphasis>emphasis</emphasis> tag in LyX, simply select a block of text and select Layout
<m:math><m:mo>→</m:mo></m:math>
 
Emphasis_Style from the menu bar.
 To create a <emphasis>link</emphasis> , select Insert
<m:math><m:mo>→</m:mo></m:math>
 
URL.
 Other inline tags are less direct: 
</para>
<list id="list4">
<item>A "term" corresponds to bold font in LyX.
 This can be found in the menu bar under Layout
<m:math><m:mo>→</m:mo></m:math>
 
Bold Style.</item>
<item>A "code" field corresponds to the "typewriter" character class in LyX.
 This can be found in the menu bar under Layout
<m:math><m:mo>→</m:mo></m:math>
 
Character.</item>
</list>
</section>
<section id="sec:Lists">
<name> 
Lists.
</name>
<para id="para31">
 Itemized and enumerated lists are represented in LyX by the <emphasis>Itemize</emphasis> and <emphasis>Enumerate</emphasis> environments.
 Examples: 
</para>
<list id="list5">
<item>An item.</item>
<item>Another item, in no particular order.</item>
</list>
<list id="list6" type="enumerated">
<item>Item one.</item>
<item>And so on.</item>
</list>
<para id="para32">
 Currently, the &lt;name&gt; field is not supported, and nested lists are not supported. 
</para>
</section>
<section id="sec:Tips">
<name> 
Tips for avoiding bugs.
</name>
<para id="para33">
 Most bugs arise from the handling of labels.
 Lyx2cnx uses 
<term> 
labels
</term>  
 to assign the id for sections, figures, etc.
 LyX will let you stick a label virtually anywhere, but lyx2cnx and Connexions
 are a little picky about the placement and content of labels/ids.
 Some recommendations: 
</para>
<list id="list7">
<item>Don't put characters like `-' or `_' in section labels.
 Connexions doesn't like them.
 When you first insert a label, LyX will usually suggest a label with dashes
 in it.
 You should delete the dashes.</item>
<item>Put labels on all Section headings.
 Insert the label <emphasis>before</emphasis> the heading text.</item>
<item>Place all graphics within Figure floats.</item>
<item>Put figure captions <emphasis>underneath</emphasis> graphics inside figure floats.
 Insert the figure label <emphasis>before</emphasis> the caption text.</item>
</list>
</section>
<section id="sec:todo">
<name> 
To-do list.
</name>
<list id="list8">
<item>Implement the &lt;name&gt; tag for lists.
 This might be done by placing the list in a Table Float with a caption.</item>
<item>Implement tables.</item>
<item>Create a custom "Connexions.layout" for LyX, defining special environments such as Problem, Solution, Example,
 Definition, etc.
 I still haven't decided whether this is a good idea.</item>
<item>A GUI wrapper?</item>
</list>
</section>


</content>
  
</document>
