<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Apolitically Incorrect &#187; LyX</title>
	<atom:link href="http://www.oak-tree.us/blog/index.php/tag/lyx/feed" rel="self" type="application/rss+xml" />
	<link>http://www.oak-tree.us/blog</link>
	<description>The Rants and Raves of an Unsettled Mind</description>
	<lastBuildDate>Thu, 27 May 2010 13:36:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Customizing LyX: Character Styles and the LyX Local Layout</title>
		<link>http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles</link>
		<comments>http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles#comments</comments>
		<pubDate>Sat, 14 Nov 2009 21:00:00 +0000</pubDate>
		<dc:creator>Rob Oakes</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Writing and Literature]]></category>
		<category><![CDATA[rapidBOOKS]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[LyX]]></category>

		<guid isPermaLink="false">http://www.oak-tree.us/blog/?p=1315</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Customizing+LyX%3A+Character+Styles+and+the+LyX+Local+Layout&amp;rft.aulast=Oakes&amp;rft.aufirst=Rob&amp;rft.subject=Computer&amp;rft.subject=Writing+and+Literature&amp;rft.subject=rapidBOOKS&amp;rft.source=Apolitically+Incorrect&amp;rft.date=2009-11-14&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles&amp;rft.language=English"></span>
Imagine for a minute that you’re writing a book or technical manual.  Let’s say it’s a book on technology, maybe the open source tools used for scientific writing (to randomly pick an example).  As you write this book, you realize that you need some way to cue the reader into different parts of the text. [...]<p>Copywrite 2009: Rob Oakes.  <a href="http://www.oak-tree.us/blog">Apolitically Incorrect</a><br/><br/><a href="http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles">Customizing LyX: Character Styles and the LyX Local Layout</a></p>
]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Customizing+LyX%3A+Character+Styles+and+the+LyX+Local+Layout&amp;rft.aulast=Oakes&amp;rft.aufirst=Rob&amp;rft.subject=Computer&amp;rft.subject=Writing+and+Literature&amp;rft.subject=rapidBOOKS&amp;rft.source=Apolitically+Incorrect&amp;rft.date=2009-11-14&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles&amp;rft.language=English"></span>
<p><img style="margin: 0px 15px 10px 0px;" src="http://www.giovanniferranti.it/images/lyx_logo.png" alt="" align="left" />Imagine for a minute that you’re writing a book or technical manual.  Let’s say it’s a book on technology, maybe the open source tools used for scientific writing (to randomly pick an example).  As you write this book, you realize that you need some way to cue the reader into different parts of the text.</p>
<p>For instance, you might want all definitions to appear in bolded text so that a reader pick out key terms quickly.  Or you might want code examples to appear in a different font than the regular text, again, so they’re easy to find.  What’s the best way to do this?</p>
<p>Sure, you could just bold the definitions, or manually change the font for the code examples.  But that’s painful!  Changing typeface and size every time that you have a section of code will eventually result in a lot of lost time.  Moreover, you might make a mistake, which destroys your consistency and makes your writing look unprofessional.  There must be a better way!</p>
<p>Thankfully, there is.  It’s through the consistent use of styles.</p>
<p><span id="more-1315"></span></p>
<h2>Styles Defined</h2>
<p>A style is a collection of formatting commands with a meaningful name.  Examples in Microsoft Word include “Heading 1”, “Body”, and “Figure”.  When you use them consistently, styles allow for “logical markup” of a document.  That is to say, you tell the computer what the section, paragraph or text corresponds to and then it handles the formatting.  For this reason, styles form the basis of the “What You See Is What You Mean (WYSIWYM)” philosophy used by LyX and other “document processors&#8221;.</p>
<p>There are three major types of styles: section styles, paragraph styles and character styles.  You are likely familiar with section and paragraph styles, as they populate the main drop down box of LyX’s main toolbar. The most common section styles are: chapter, section, subsection.  Examples of paragraph styles include: standard text, quotations, and code.  But the third main type of style, “a character style” may be a stranger.  It isn’t as common as it’s two older brethren and easier to lose track of; which is a huge shame, because it is just as important.</p>
<p>Character styles, as the name implies, work on individual characters <em>within</em> the text of a paragraph.  To extend the examples given in the introduction, the most efficient way to bold a definition would be to use a pre-defined character style called “definition”.  Ditto for an in-paragraph sample of code.</p>
<p>“Now wait a minute,” you’re probably saying, “I’m not sure that I follow the difference between character styles and other text formatting commands like ‘bold’, ‘italic’, or ‘underline’!”</p>
<p>That is perfectly alright, the distinction can be a bit hazy.  Nonetheless, it is still key in understanding the difference between “logical markup” and formatting.  Let me see if I can clear it up.</p>
<p>As described above, a style is typically used to describe what a part of the document is, rather than how it should look.  Subsequently, you are unlikely to see a style called “bold”, “italic” or “center”.  Those terms describe how the text should appear; which is to say, they are formatting commands.  Bolded text uses a heavier line stroke and centered text appears in the middle of the page.  A style, on the other hand, is used to describe a “definition”.  You then associate that style with how you want “definition” to look.  It could be numbered, bolded and centered; or it might be larger than the surrounding text and italicized.  The appearance is determined by a “style sheet”.</p>
<p><em>Note: Since the use and customization of section and paragraph styles is well explained in the LyX help documentation, this article will focus on character styles.</em></p>
<h2>Using Character Styles in LyX</h2>
<p>LyX provides some common character styles through the use of its “Logical Markup” module.  These include styles for nouns, emphasizing text, and code – which may be useful for highlighting filenames or programming syntax within the body of the paragraph.</p>
<p>The character styles are not loaded by default, however.  Instead, they come as part of an optional module.  You can use them by going to the “<strong>Document-&gt;Settings-&gt;Modules”</strong> pane and adding “<strong>Logical Markup</strong>” to your document.</p>
<p><img style="display: inline; border-width: 0px;" title="LyX supports several character styles (including noun, emphasize, strong and code) through the &quot;Logical Markup&quot; module." src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/LyXModules.png" border="0" alt="LyX supports several character styles (including noun, emphasize, strong and code) through the &quot;Logical Markup&quot; module." width="600" height="436" /></p>
<p>Once the “<strong>Logical Markup</strong>” module has been loaded, you  use of apply a particular character style through the “<strong>Edit-&gt;Text Styles</strong>” menu, or by first highlighting a block of text and selecting “Text Style” from the right click context menu.</p>
<p><em>Note: The emphasize style is distinct in that it can also be toggled on and off through the “Ctrl+E” keyboard shortcut.</em></p>
<p><img style="display: inline; border-width: 0px;" title="You can add a character style to a document either through the &quot;Edit&quot; menu, or by selecting a block of text and then right clicking on it." src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/LyXCharacterStylesRightClick.png" border="0" alt="You can add a character style to a document either through the &quot;Edit&quot; menu, or by selecting a block of text and then right clicking on it." width="600" height="380" /></p>
<p>After you’ve formatted a block of text with character style, it will appear differently from the surrounding text.  It will not only use a different font, but will also be surrounded by a set of hash marks.  The example below shows a document with two instances of the “Code” character style.  Optionally, character styles have a label which you be toggled on and off.  The screen shot below shows what this looks like.  The first instance, “TEXMFLOCAL”, has the label toggled off while the instance, “/var/lib/texmf/tex/latex”, shows the same character style with the label visible.</p>
<p><img style="display: inline; border-width: 0px;" title="This example shows two blocks of text formatted with the &quot;code&quot; character style. " src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/image1.png" border="0" alt="This example shows two blocks of text formatted with the &quot;code&quot; character style. " width="581" height="79" /></p>
<h2>Customizing Character Styles</h2>
<p>But what if you need access to other character styles?  Perhaps you’re writing a novel and would like to have a dedicated style for specifying when a character is talking to himself (called internal dialogue)?  Or you’d finally get back to working on your textbook with bolded definitions.  Such styles aren’t defined by the “Logical Markup” module, or any module at all for that matter.  Nor are they likely to be used so frequently that it is worth trying to modify the built-in modules or create a new one to support them.</p>
<p>Luckily, there is a solution to this problem.  In the <a href="http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih">first article in this series</a>, I looked at how to create a template for an NIH grant proposal from an existing LaTeX document class.  In that article, the secret to using the “nih.cls” document class lay in its corresponding LyX layout file (&#8220;nih.layout&#8221;).  Also in that article, I explained how LyX layout files primarily contain information concerned with on-screen presentation.</p>
<p><em>Note: For more detail, see: <a href="http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih#bigpicture">Customizing LyX – Part 1, Understanding the Big Picture</a>.</em></p>
<p>As a first approximation, what I said in that article is mostly true.  But, naturally, the reality is more complex.  LyX layout files can also contain information about character styles.  This includes both information about how they should be presented on-screen and how the underlying LaTeX typesetting language should process them.  Moreover, that information can either live in a global layout file (like nih.layout) or in the .lyx file you are working on (meaning that it can be conveniently added to a template).  In the remainder of this post, I will show how to create custom character styles by modifying the local layout.</p>
<h3>Example: Creating a “User Interface” Character Style</h3>
<p>As you might have guessed, the example introduced above isn’t so random.  For the past several weeks, I have been working on a book about scientific and technical writing.  The book will cover a number of programs and technologies including <a href="http://www.lyx.org/">LyX</a>, LaTeX, BibTeX, <a href="http://www.mendeley.com/">Mendeley</a>, <a href="http://www.scribus.net/">Scribus</a> and <a href="http://kile.sourceforge.net/">Kile</a>.</p>
<p>Since it is geared to a somewhat technical audience, it includes both instructions on how to use program&#8217;s UI and code samples.  For my code examples, I can use the internal LyX character style.  But I’ve found that I would also like to highlight references to the UI.  There isn&#8217;t a pre-defined UI character style.</p>
<p>Fortunately, I not the first person writing a book with UI references.  If you look at the LyX user manuals, you will see that the LyX documentation team created a character style specifically for highlighting LyX menu commands.  It uses a sans serif font and I think it is rather attractive.  But, how do you go about adding it to another document?</p>
<p>It’s actually pretty straightforward:</p>
<ol>
<li>Since there isn’t a UI to modify the local layout in LyX, open your document in a text editor</li>
<li>Create a local_layout section</li>
<li>Define how you want your character style to appear (both on screen and in the LaTeX output)</li>
</ol>
<h4>Step 1: Open your document in a text editor</h4>
<p>As explained above, custom character styles live in the local_layout section (enclosed with the “\begin_local_layout” and “\end_local_layout”) near the beginning of a LyX document.  Unfortunately, there is not currently a user interface pane within LyX to edit this section.  As a result, open the document in your favorite text editor.  The figure shows what this looks like for a file called “Book Chapter – Technical.lyx”.</p>
<p><em>Note: There is nothing to be afraid of, LyX’s file format is relatively easy to parse; even for human beings.</em></p>
<p><img style="display: inline; border-width: 0px;" title="A sample LyX document for a technical book chapter." src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/LyXCharacterStylesKateExample.png" border="0" alt="A sample LyX document for a technical book chapter." width="600" height="360" /></p>
<p>“Book Chapter – Technical.lyx” has three major sections:</p>
<ul>
<li>
<div>Document: enclosed by “\begin_document” and “\end_document” (off-screen)</div>
</li>
<li>
<div>LaTeX Preamble: enclosed by “\begin_preamble” and “\end_preamble”</div>
</li>
<li>
<div>Local Layout: enclosed by “\begin_local_layout” and “end_local_layout” (off-screen)</div>
</li>
</ul>
<p>I have added some text to the LateX preamble in this example.  The command tells LyX to use the “Latin Modern” fonts instead of the LaTeX default fonts, which I find to be rather ugly:</p>
<blockquote><p>% set fonts for nicer pdf view<br />
\IfFileExists{\lmodern.sty}{\usepackage{lmodern}}{}</p></blockquote>
<p><!--adsensestart--></p>
<h4>Step 2: Create a Local Layout Section</h4>
<p>If it doesn’t already exist, insert a local_layout section.  For organizational purposes, I like for it to appear following the preamble.  Below is the full text of the layout section for “Book Chapter – Technical.lyx”:</p>
<blockquote><p>\begin_local_layout<br />
    Format 7<br />
        InsetLayout    CharStyle:UserInterface<br />
        LyxType               charstyle<br />
        LabelString           userinterface<br />
        LatexType             command<br />
        LatexName             userinterface<br />
        Font<br />
            Family              Sans<br />
        EndFont<br />
        Preamble<br />
            \newcommand*{\userinterface}[1]{{\sffamily #1}}<br />
        EndPreamble<br />
    End<br />
\end_local_layout</p></blockquote>
<p>In the example, there is some template code (also known as boilerplate), and values that you can modify in order to better customize the appearance of your character style.  The boilerplate includes “Format 7”, LyXType      charstyle”, and “LatexType    command”.  These values will be constant for all character styles, but everything else can be customized.</p>
<h4>Step 3: Define how you want the character style to look</h4>
<p>When customizing the appearance of your character style, the first thing to do is to decide what you want to call your style.  This is done by modifying the “InsetLayout” argument.  Since my book project covers many different programs, I’ve decided that I will use this character style for any reference to the ui.  That includes menus, button names, or dialog box text.  As a result, I’ve called it “CharStyle:UserInterface”.  This is what appears when I go to the “<strong>Edit-&gt;Text Style</strong>” menu and in the dialog box that appears when I right click.</p>
<p>Next, you need to decide what you would like the “label” to be.  The label appears when the “show label” option is toggled on.  In this example, it’s “userinterface”.</p>
<p>I also need to associate my character style with a LaTeX name.  Again, I’ve opted to call it “userinterface”.</p>
<p>The next block of options, “Font”, specify how the text will look on screen.  You could be extremely ornate specifying text size, typeface, and  font weight.  In this case, however, I want to go with something simple.  I&#8217;m just going to use the “Sans” font family for on-screen to display.  Boring, but functional.</p>
<p><em>Note: A complete list of available options can be found in the LyX help documentation: “Customizing LyX: Features for the Advanced User”.  See section 5.3.6.</em></p>
<p>The Preamble block tells LaTeX how it should process the character style.  Again, I don’t want to do anything fancy, so I&#8217;m just going to use the “Sans Serif” font family.  This is accomplished by the following LaTeX command:</p>
<blockquote><p>\newcommand*{\userinterface}[1]{{\\sffamily #1}}</p></blockquote>
<p><!--adsensestop--></p>
<p>The “\newcommand” syntax tells LaTeX about my custom style, while everything after is specifying the text and the font family. “\ssfamily” refers to the sans serif font family.  Other options I could have used include the roman font family (“\rmfamily”), the typewriter family (“\ttfamily”), medium text (“\mdseries”), italic (&#8220;\itshape”), or small caps (“\scshape”).</p>
<p><em>Note: For a more complete list with sample output, see </em><a href="http://theoval.cmp.uea.ac.uk/~nlct/latex/novices/fontstyle.html"><em>here</em></a><em> (Table 4.5).</em></p>
<p>When finished, save your document and exit the text editor.  When you load the document back into LyX, your style should appear in the “<strong>Edit-&gt;Text Style</strong>” menu.  The screenshot below shows how the “User Interface” character style looks in use.</p>
<p><img style="display: inline; border-width: 0px;" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/image2.png" border="0" alt="" width="584" height="123" /></p>
<h2>Miscellaneous Things and Conclusion</h2>
<p>Like the example in the previous article, I like to save documents with custom character styles as templates.  This means that I can create additional documents very easily by going to the “<strong>File”</strong> menu and choosing the “<strong>New from template”</strong> option.  The new document will have all of the template’s settings, including the LaTeX preamble and the custom character styles.  It also means that I can keep separate templates for technical documents, scientific articles, book chapters and fiction.  Each has character styles defined that make sense for that type of publication.</p>
<p>Character styles make writing long documents much easier.  It’s so much better to label a piece of text as “code” or “userinterface” than it is to remember the exact formatting specifications.  Moreover, it makes the document more consistent and provides an easy path to change formatting at a later date.  As a first time author, I have no complaints about anything that makes my writing easier, more organized, and flexible.<br />
<h3>Similar Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.oak-tree.us/blog/index.php/2009/11/30/latex-cv-part2" rel="bookmark" title="November 30, 2009">Typeset Your Curriculum Vitae &ndash; Part 2: Extending and Customizing an Existing Document Class</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/11/25/latex-cv-part1" rel="bookmark" title="November 25, 2009">Typeset Your Curriculum Vitae &ndash; Part 1: The xetexCV Document Class</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2008/12/11/ironpython-wpf-tutorials" rel="bookmark" title="December 11, 2008">IronPython – Windows Presentation Foundation Tutorials</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/07/30/time-traveler" rel="bookmark" title="July 30, 2009">A Better Previous Versions: Time Traveler</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/05/09/barn-architecture" rel="bookmark" title="May 9, 2009">Barn Architecture</a></li>
</ul>
<p><!-- Similar Posts took 12.270 ms --></p>
<p>Copywrite 2009: Rob Oakes.  <a href="http://www.oak-tree.us/blog">Apolitically Incorrect</a><br/><br/><a href="http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles">Customizing LyX: Character Styles and the LyX Local Layout</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing LyX: Create an NIH Grant Proposal Template</title>
		<link>http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih</link>
		<comments>http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih#comments</comments>
		<pubDate>Mon, 02 Nov 2009 22:21:54 +0000</pubDate>
		<dc:creator>Rob Oakes</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Writing and Literature]]></category>
		<category><![CDATA[rapidBOOKS]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[LyX]]></category>

		<guid isPermaLink="false">http://www.oak-tree.us/blog/?p=1291</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Customizing+LyX%3A+Create+an+NIH+Grant+Proposal+Template&amp;rft.aulast=Oakes&amp;rft.aufirst=Rob&amp;rft.subject=Computer&amp;rft.subject=Writing+and+Literature&amp;rft.subject=rapidBOOKS&amp;rft.source=Apolitically+Incorrect&amp;rft.date=2009-11-02&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih&amp;rft.language=English"></span>
LyX is a wonderful writing program.  It’s easy to use and produces beautifully typeset output.  More importantly, though, it lets an author focus on the content and structure of his writing; rather than the formatting.  It isn’t so easy to customize, though, which limits its usefulness in a big way.  What if you need to [...]<p>Copywrite 2009: Rob Oakes.  <a href="http://www.oak-tree.us/blog">Apolitically Incorrect</a><br/><br/><a href="http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih">Customizing LyX: Create an NIH Grant Proposal Template</a></p>
]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Customizing+LyX%3A+Create+an+NIH+Grant+Proposal+Template&amp;rft.aulast=Oakes&amp;rft.aufirst=Rob&amp;rft.subject=Computer&amp;rft.subject=Writing+and+Literature&amp;rft.subject=rapidBOOKS&amp;rft.source=Apolitically+Incorrect&amp;rft.date=2009-11-02&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih&amp;rft.language=English"></span>
<p><img style="margin: 0px 20px 0px 0px; display: inline;" src="http://www.giovanniferranti.it/images/lyx_logo.png" alt="" align="left" />LyX is a wonderful writing program.  It’s easy to use and produces beautifully typeset output.  More importantly, though, it lets an author focus on the content and structure of his writing; rather than the formatting.  It isn’t so easy to customize, though, which limits its usefulness in a big way.  What if you need to create a new layout or take advantage of one of the thousands of specialized  LaTeX styles?  How, exactly, do you go about doing that?</p>
<p>That’s why this article was written.  Recently, I was asked to help with a National Institutes of Health (NIH) R21 grant proposal.  After some talk amongst the different investigators, it was decided that we would use LaTeX and LyX to draft it.  Unfortunately, we hit a rather substantial hurdle early in the process:  LyX doesn’t have an NIH grant template.</p>
<p>After additional debate, we decided to proceed with LyX anyway.  But in the process, I found myself saddled with an additional job.  In addition to responsibilities as research flunky and copy editor, I was tasked with creating a LyX and LaTeX template for our NIH grant.  This article will summarize the steps I took and describe how to create a custom template using an available style on <a href="http://www.ctan.org/">CTAN</a>.</p>
<p><img style="display: inline; border-width: 0px;" title="image" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/image.png" border="0" alt="image" width="659" height="179" /></p>
<p><em>Note: All of the files in this tutorial can downloaded </em><a href="http://www.oak-tree.us/stuff/LyX/nih.zip"><em>here</em></a><em> (.zip).</em><br />
<span id="more-1291"></span><!--adsensestart--></p>
<h2>Understanding the Big Picture</h2>
<p><a name="bigpicture"></a>Before laying out the procedure, I will start with the theory. That includes understanding how LyX and LaTeX interact, as well as what files they use for their respective jobs.</p>
<h3>An Introduction to LyX and LaTeX</h3>
<p>As you probably already know, LyX is a document preparation system which supports LaTeX, DocBook, and other typesetting technologies.  Writing with LyX is easier than using regular LaTeX or DocBook because it abstracts away the markup language and most of the associated pain.  Want to insert a citation?  Just hit <strong>Insert –&gt; Citation</strong>.  There’s no fussing with markup tags or macro commands.  The same goes for inserting figure legends, tags, labels, footnotes or any other relatively complex formatting.  LyX takes care of all the minutiae for you.</p>
<p>When you want to customize LyX, however, all of the ugliness and complexity gets shoved right back into your face.  Instead of just writing and letting the program sort out the details, all of a sudden you are transformed from a user into a collaborating developer.  You need to know how the underlying technologies work.  What’s the difference between a LaTeX class and a style sheet?  What does a LyX layout document do?  How does that differ from a LyX template document?  How do you install them and get the system to recognize that they’re present?</p>
<p>To get a handle on these questions, you need to understand that LyX and LaTeX accomplish two different (though complementary) goals.  LaTeX is largely in the job of creating printed documents (typesetting), whereas LyX is about helping you to write and organize the document (on-screen display).</p>
<p>I like to think of LyX as an editorial assistant while LaTeX is the production staff.  The editorial assistant organizes the various elements into a more logical layout, puts references and other material at your fingertips, and finally helps collate everything into a package that the production people can make sense of.  Once the package has been assembled, the production staff then goes about laying it all out on paper, making sure that references are all numbered and formatted correctly, and otherwise handling the business of making the document beautiful.</p>
<h3>LaTeX Classes and Styles</h3>
<p>To go about its work, LaTeX uses a couple of important files: document classes (.cls) and styles (.sty).  As mentioned, the entire purpose behind LaTeX is that you should be able to focus on the content of your writing without being distracted by its visual presentation.  Classes and styles are what make this possible.  As you are writing, you tell LyX (and by extension LaTeX) whether a block of text is a chapter, figure legend, table, or footnote.  When ready, you can then transform the markup (which makes sense to a computer) into something that makes sense to a human being.</p>
<p><strong>LaTeX classes</strong> are the first step in the transformation.  They contain important information about what the structure of the document should be and where things should go.  You might even say that a class file tells a document “what” it is.  Subsequently, the most common types of document classes are articles, reports, and books.</p>
<p>A <strong>LaTeX style</strong>, in contrast, tells the file “how” it should look.  If a class says, “You’re a book,” then a style will say, “you should have one inch margins” and “the chapter heading should be in Arial 16 point font with 0.2 inches of space above and below them”.  Any given document will only have a single document class, but may use many different styles.</p>
<h3>LyX Layout and Template Files</h3>
<p>In contrast, a LyX layout file corresponds to a LaTeX class and tells LyX how to draw things on screen; and this is where things can get a little confusing.  Even though a LyX layout is supposed to look like the printed page, this isn’t always true.  For example, the final document may have two or three columns; but on-screen the LyX document will only have one.  What is true, however, is that a LyX layout file will contain information about what document elements are available.  If you’re writing a book, for example, the LyX layout will have an option called “Chapter”; even though the fonts and spacing used won’t always be exactly the same.</p>
<p>The final fie type that you need to know about is called a template.  Whereas a layout file largely contains information about the on-screen display, the template file has information about typesetting and presentation.  In many ways it inherits both the properties of the LaTeX .cls and .sty files and the LyX layout properties.  This means  that you can add both LaTeX and LyX information to it.</p>
<p>The figure below shows these relationships graphically.</p>
<p><!--adsensestop--></p>
<p><img style="margin: 20px 0px; display: inline; border-width: 0px;" title="How LyX Works" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/HowLyXWorks.png" border="0" alt="How LyX Works" width="434" height="374" /></p>
<h2>Creating a Custom LyX Template – NIH Grant Proposal</h2>
<p>With the definitions out of the way, here is the procedure for creating a custom document template.  There are four basic steps:</p>
<ol>
<li>Download the necessary document classes and styles</li>
<li>Install the files into the proper folder of your LaTeX distribution</li>
<li>Create an appropriate layout file corresponding to the document class or style</li>
<li>Create a template file with additional details and information</li>
</ol>
<h3>Step 1: Download the necessary styles and templates</h3>
<p>The very first step is to locate the document class that you need to use.  There are many good resources to do this.  The first is <a href="http://www.ctan.org/">CTAN</a>, which is probably the most comprehensive resource available.  (You can also find very good package lists on <a href="http://en.wikibooks.org/wiki/LaTeX/Packages">Wikipedia</a> and through Google.)  Since I already know the name of the document class I need (<a href="http://www.ctan.org/tex-archive/macros/latex/contrib/nih/">NIH</a>), I will download it from the associated CTAN page.</p>
<h3>Step 2: Install the files into the proper folder for your  LaTeX distribution</h3>
<p>Once you have saved the files onto your computer, you need to place them in one of several locations.  If all users of the computer need it, install it to the system wide LaTeX tree.  If, however, you are the only person who will be using the package, you can place it in your own “user” folder.</p>
<p>The location of the system tree varies depending on which version of LaTeX you happen to be running.  It is typically defined by the “TEXMFLOCAL” variable.  For individuals using Ubuntu Linux, you will find it at “/var/lib/texmf/tex/latex”.  For users of other LaTeX distributions or operating systems, you will need to consult the documentation files.  The “user” tree is located in your own user folder.  For users of Linux, this will be “/home/<em>username</em>/texmf/tex/latex”.  <em>Note: Be sure to replace “username” with your appropriate login information.</em></p>
<p>To install the package, unpack the archive and copy all of the contents to the appropriate location.  After, you will need to update the LaTeX database by running texhash.</p>
<blockquote><p>sudo texhash</p></blockquote>
<h3>Step 3: Create an appropriate style layout for LyX</h3>
<p>Now that the package has been installed, we need to create a layout file so that LyX can make use of it.  This is a two step process:</p>
<ol>
<li>Edit the document class and style so that it only contains general elements</li>
<li>Generate a new LyX layout file</li>
</ol>
<h4>Step 3.1: Edit the document class and style to only contain general elements</h4>
<p>Working with LaTeX classes in LyX is slightly different than how you would work with them in a tool like <a href="http://kile.sourceforge.net/">Kile</a> or <a href="http://www.xm1math.net/texmaker/">TeXMaker</a>.  As already mentioned, LyX abstracts a lot of the technical detail of LaTeX away.  However, when using a tool like Kile, you directly interact with the LaTeX code.  When working this way, it can be convenient to place commonly used elements into the document class or style.  The NIH files that we downloaded and installed in the steps above do this.  (The page headers and footers contain the name of the primary investigator and the reference number for the grant.)</p>
<p>As you might guess, however, this isn’t a good thing if you are trying to create a general template.  The document class and style files should only contain the elements that are going to applied to <em>all</em> of the documents.  This shouldn’t include dates specific to a given revision, the name of a principal investigator, or the title of the grant.  We want to install the LaTeX files and then forget about them, which is simply impossible if they contain such specific information.</p>
<p>As a result, before we go further, we need to redact this information from the nih.cls file.  But even though we are removing it, <strong>don’t throw it away! </strong>Stick it in a spare text file for the time being.  It is still needed so that the final document will match NIH style conventions.  We will add it back to the template created in Step 4.</p>
<p>In the original files from CTAN, open up nih.layout in your favorite text editor and cut out the following text:</p>
<blockquote><p>% preamble stuff<br />
\newcommand{\nih@PIname}{Oakes, Robert Stilman}<br />
\newcommand{\piname}[1]{\renewcommand{\nih@PIname}{#1}}<br />
\makeatletter</p>
<p>% constants<br />
\newcommand{\nih@sillysize}{\scriptsize}</p>
<p>…</p>
<p>\newtheorem{proposition}{Proposition}<br />
\newtheorem{lemma}{Lemma}</p></blockquote>
<p>In addition to redacting the information above, you will also want to add the following line close to the end of nih.cls.  It will ensures that alphabetic section labels will be used instead of numeric labels:</p>
<blockquote><p>\def\thesection{\Alph{section}}</p></blockquote>
<p><em>Note: In the files for this tutorial, I have already redacted the unnecessary text from the nih.cls file and added it to the NIH Grant Proposal template.  I have also added the section label code.</em></p>
<h4>Step 3.2: Generate a new LyX layout file</h4>
<p>The easiest way to create a new layout file is to modify one of the existing examples.  If you look closely at the NIH document class (nih.cls), you will notice that it is based on the LaTeX “article” class.  As we try and create an appropriate nih.layout, let’s start by modifying <a href="http://www.oak-tree.us/stuff/LyX/article.layout">article.layout</a>.</p>
<p>When you first open the file, you will see the following:</p>
<blockquote><p># Do not delete the line below; configure depends on this<br />
# \Declare LaTeXClass{article}<br />
…<br />
Format 11<br />
Input stdclass.inc</p>
<p>SecNumDepth             3<br />
TocDepth                3</p>
<p>NoStyle Chapter<br />
NoStyle Chapter*</p>
<p>Style Part<br />
    Align                 Left<br />
    AlignPossible         Left<br />
    TopSep                2<br />
    BottomSep             1.5<br />
    Font<br />
      Size                Larger<br />
    EndFont<br />
End<br />
…</p></blockquote>
<p>As you study the layout, you should start to see a few general sections.  For example, the second line tells LyX that it is using the LaTeX class “article”.  “Input stdclass.inc” tells LyX to import the standard list of document elements.  Whenever you see a line that begins “NoStyle”, that is telling LyX to remove those particular section types from the available list of options since they aren’t supported by the document class.</p>
<p>Pay close attention to the section block that begin with “Style”.  This tells LyX how to display that particular document element on screen.  It includes information about how the text should be aligned (“Align”, “AlignPossible”) and what font should be used (“Font”, “Size”, “EndFont”).</p>
<p>To make article.layout work with nih.cls, we need to make two modifications.  First, we need to change the \DeclareLaTeXClass and then we need to add a new “Style” block.</p>
<p>First, let’s change the \DeclareLaTeXClass.  Add the following:</p>
<blockquote><p>\DeclareLaTeXClass[nih]{proposal (NIH)}</p></blockquote>
<p>In this example, nih is the name of the LaTeX document class (nih.cls) and the information in curly brackets is a description which will make it easier to find in the LyX document settings pane.</p>
<p>Next, we need to add a “Style” block that describes the “Section” element of the nih document class.  By default NIH sections are labeled alphabetically: “A Specific Aims”, “B Background”, “C Methods”, etc.  In contrast, the article labels its sections numerically: “1 Specific Aims”, “2 Background”, “3 Methods”, etc.  If we don’t modify the standard labeling, it will be displayed incorrectly on screen</p>
<p>Luckily, it’s an easy fix.  Add the following to article.layout:</p>
<blockquote><p>Style Section<br />
    LabelType             Counter<br />
    LabelCounter          section<br />
    LabelString           &#8220;\Alph{section}&#8221;<br />
End</p></blockquote>
<p><img style="margin: 0px 0px 20px 20px; display: inline; border-width: 0px;" title="Before using your new document class, you will need to reconfigure LyX so that it can see them." src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/CustomizeLyXReconfigure.png" border="0" alt="Before using your new document class, you will need to reconfigure LyX so that it can see them." width="312" height="189" align="right" /> After you’ve made these changes, resave the file as “nih.layout”.  Then copy the file to either the main LyX directory layouts folder (typically LyXDir/layouts) or to your LyX user directory (typically found at .lyx/layouts/).  For LyX to see and use the new files, you will need to run <strong>Tools –&gt; Reconfigure</strong>.</p>
<p><em>Note: A full version of the nih.layout file is available as part of the <a href="http://www.oak-tree.us/stuff/LyX/nih.zip">archive package</a> for this tutorial.</em></p>
<h3>Step 4: Create a LyX template file</h3>
<p>With a fully functioning LyX layout (nih.layout), you can now create a template file that has all of the needed elements.  As mentioned above, a LyX template file is nothing more than a regular LyX file.  So, start by creating a new LyX document (<strong>File –&gt; New</strong>).</p>
<p>After the new document is open, the very first thing that you should do is change the document class.  Go to <strong>Document –&gt; Settings</strong> –&gt; <strong>Document Class</strong>.  Then from the drop down menu, select “proposal (NIH)”.</p>
<p><img style="display: inline; border-width: 0px;" title="Customize LyX - Document Settings" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/CustomizeLyXDocumentSettings.png" border="0" alt="Customize LyX - Document Settings" width="620" height="443" /></p>
<p>Next, you need to add the information removed from nih.cls to the LaTeX Preamble.  Go to <strong>Document –&gt; Settings –&gt;</strong> <strong>LaTeX Preamble</strong>, and paste the text into the provided space.  While doing this, you may want to modify the name of the PI that will be shown in the document header.  You make this change by adding your name to the line that reads:</p>
<blockquote><p>\newcommand{\nih@PIname}{Last Name, First Name Middle}</p></blockquote>
<p>When done, press “Close”.  You now have a fully functional, NIH compliant grant proposal template.</p>
<p><img style="display: inline; border-width: 0px;" title="Customize LyX - Document Preamble" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/CustomizeLyXDocumentPreamble.png" border="0" alt="Customize LyX - Document Preamble" width="620" height="444" /></p>
<p>But while that’s the end of the essential boilerplate, you may want to include a few additional goodies.  Wouldn’t it be nice, for example, if you had access to clickable hyperlinks?  Or if you were be able to use the bookmarks sidebar to navigate the document?  For these and other desirables, add the following to the preamble:</p>
<blockquote><p>% Hyperlink Options<br />
\usepackage{ifpdf} % part of the hyperref bundle<br />
\ifpdf % if pdflatex is used</p>
<p>% Use True Type Fonts Instead of Older LaTeX Fonts<br />
\IfFileExists{lmodern.sty}{\usepackage{lmodern}}{}</p>
<p>\fi % end if pdflatex is used</p>
<p>% for correct jump positions when clicking on a link to a float<br />
\usepackage[figure]{hypcap}</p></blockquote>
<p>This code enables the hyperref package.  Then, go to <strong>Document –&gt; Settings –&gt; PDF Properties </strong>and enable hyperref support in the options.  While changing the PDF properties, I personally like to customize the colors of the links.  I think that document links and cited references should be black; while urls and files should be blue.  To make this change, add the following to the “additional options” line:</p>
<blockquote><p>linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue</p></blockquote>
<p><img style="display: inline; border-width: 0px;" title="Customize LyX - PDF Properties" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/11/CustomizeLyXPDFProperties.png" border="0" alt="Customize LyX - PDF Properties" width="620" height="443" /></p>
<h2>Using the Template</h2>
<p>If you’ve followed all of the steps in this tutorial, you will now have a fully functioning NIH grant template.  Now might be a good time to save it in the same location where you keep other templates.  (If you don’t have a templates folder, you might want to create one.)  I’ve saved mine as “NIH Grant Proposal.lyx”.  From here on out, whenever I want to create a new NIH document, I simply choose <strong>New from template</strong> from the <strong>File</strong> menu and load the appropriate version.</p>
<p>Now that my template is set up, I’m back to an automated wonderland.  LyX and LaTeX keep track of the references, labels, footnotes, formatting and the other minutiae that make complicated documents so painful.  I’m free to focus on the ideas,  voice, and message; which is exactly how it should be.<br />
<h3>Similar Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.oak-tree.us/blog/index.php/2009/11/30/latex-cv-part2" rel="bookmark" title="November 30, 2009">Typeset Your Curriculum Vitae &ndash; Part 2: Extending and Customizing an Existing Document Class</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/11/14/customize-lyx-character-styles" rel="bookmark" title="November 14, 2009">Customizing LyX: Character Styles and the LyX Local Layout</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/11/25/latex-cv-part1" rel="bookmark" title="November 25, 2009">Typeset Your Curriculum Vitae &ndash; Part 1: The xetexCV Document Class</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool" rel="bookmark" title="March 4, 2009">Creating the Perfect Writing Tool: A Proposal</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/05/13/lyx-outline" rel="bookmark" title="May 13, 2009">Introducing LyX-Outline 0.1</a></li>
</ul>
<p><!-- Similar Posts took 15.108 ms --></p>
<p>Copywrite 2009: Rob Oakes.  <a href="http://www.oak-tree.us/blog">Apolitically Incorrect</a><br/><br/><a href="http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih">Customizing LyX: Create an NIH Grant Proposal Template</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating the Perfect Writing Tool: A Proposal</title>
		<link>http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool</link>
		<comments>http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool#comments</comments>
		<pubDate>Thu, 05 Mar 2009 02:32:33 +0000</pubDate>
		<dc:creator>Rob Oakes</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Writing and Literature]]></category>
		<category><![CDATA[LyX]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.oak-tree.us/blog/?p=760</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Creating+the+Perfect+Writing+Tool%3A+A+Proposal&amp;rft.aulast=Oakes&amp;rft.aufirst=Rob&amp;rft.subject=Computer&amp;rft.subject=Programming&amp;rft.subject=Writing+and+Literature&amp;rft.source=Apolitically+Incorrect&amp;rft.date=2009-03-04&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool&amp;rft.language=English"></span>
In addition to nouns, verbs, and adjectives; there are other tools which supplement the writer&#8217;s arsenal. some writers, this is a moleskin notebook and ballpoint pen. For others, writing is synonymous with the usage of computer word processors, such as Microsoft Word.&#160; What is a given, however, is that the choice is intensely personal. If [...]<p>Copywrite 2009: Rob Oakes.  <a href="http://www.oak-tree.us/blog">Apolitically Incorrect</a><br/><br/><a href="http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool">Creating the Perfect Writing Tool: A Proposal</a></p>
]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Creating+the+Perfect+Writing+Tool%3A+A+Proposal&amp;rft.aulast=Oakes&amp;rft.aufirst=Rob&amp;rft.subject=Computer&amp;rft.subject=Programming&amp;rft.subject=Writing+and+Literature&amp;rft.source=Apolitically+Incorrect&amp;rft.date=2009-03-04&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool&amp;rft.language=English"></span>
<p><img alt="" align="left" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe1.jpg" />In addition to nouns, verbs, and adjectives; there are other tools which supplement the writer&#8217;s arsenal. some writers, this is a moleskin notebook and ballpoint pen. For others, writing is synonymous with the usage of computer word processors, such as Microsoft Word.&#160; What is a given, however, is that the choice is intensely personal. If you ask ten different writers, &quot;What is the perfect tool?&quot; Expect ten different answers.</p>
<p>For those who create software, however, this is big problem. Programs can&#8217;t be customized to the individual whims of every writer. (A more diverse or idiosyncratic group does not exist.)&#160; It is necessary to select a cross section of features that meet the needs of most people.&#160; Unfortunately, however, this has resulted in some serious compromises and an emphasis on the technical process of writing, often to the exclusion of the creative process.</p>
<p> <span id="more-760"></span>
</p>
<h2>The Problem</h2>
<p>Like most writers, I have some strong feelings about the tools I use; and like most writers, I have never found one that fits my needs.&#160; But this is not for a lack of trying.&#160; In fact, I’ve been searching “perfect tool” for a very long time, at least since I was a senior in high school.</p>
<p>At that time, I enjoyed writing things out in longhand, with separate drafts copied over from the first iteration. I fancied myself a budding novelist and fervently believed that such an exercise would stimulate my creativity.</p>
<p>A decade later, however, I have become impatient. Now, I prefer to peck out my thoughts at the keyboard.&#160; Sometime in college, I realized that writing by hand is slow and while it can focus the mind on word choice, it&#8217;s a plodding and frustrating exercise. In contrast, typing at the computer is quick; and since I can type nearly as fast as I can think, it allows the text to keep pace with my thoughts.</p>
<p>Moreover, working on the computer is organic. There isn&#8217;t a discrete first, second, and final draft; instead, I can add, modify or change my writing as I form the ideas. If I want to jump back and change a word or sentence, I do so. Pen and paper isn&#8217;t nearly so adaptable and many ideas are lost before they can be captured and expanded. </p>
<h3>The Limitations of Existing Tools</h3>
<p>But even though I prefer to write at the computer, I haven’t been able to find a writing program that lets me creatively adapt the structure and flow of my document.&#160; I have tried nearly everything available, but nothing fully meets my needs.</p>
<p>Consider <a href="http://office.microsoft.com/en-us/word/default.aspx">Microsoft Word</a>, for example.&#160; Even with all of its power, there are a number of things that it doesn&#8217;t handle very well. Ever tried to work with a complex Word document, numbering into the hundreds or thousands of pages? If not, I don&#8217;t recommend that you do.&#160; Large Word documents cause the program to slow down or crash and they have a tendency to become corrupted.&#160; There is nothing more disconcerting than finding out one of your book chapters is no longer usable due to bit rot.</p>
<h3>Introducing LyX: The Document Processor</h3>
<p>Luckily, there may a potential solution.&#160; The open source document processor, LyX, meets many of Word’s shortcomings.&#160; LyX encourages people to approach writing based on the structure and content of the document, rather than the appearance. Thus, it isn&#8217;t a &quot;<strong>W</strong>hat <strong>Y</strong>ou <strong>S</strong>ee <strong>I</strong>s <strong>W</strong>hat <strong>Y</strong>ou <strong>G</strong>et&quot; so much as a &quot;<strong>W</strong>hat <strong>Y</strong>ou <strong>S</strong>ee <strong>I</strong>s <strong>W</strong>hat <strong>Y</strong>ou <strong>M</strong>ean&quot; (WYSIWYM).</p>
<p>When used right, LyX focuses the user on writing the content. The program handles the mechanics of layout and output. To do so, LyX leverages the LaTeX typesetting system, which is used heavily in the engineering and science disciplines to publish dissertations, grant proposals, journal articles, and books.</p>
<p>When I first found LyX three or four years ago, it fundamentally changed the way that I worked. Before, I manually formatted everything in a given document. While this approach is okay for simple letters or lists, it quickly breaks down in anything longer than a few pages.</p>
<p>In contrast, LyX makes extensive use of tags that tell the program what a given piece of text is. The title is enclosed by a &quot;title&quot; tag, book sections by the &quot;section&quot; tag, chapter headings by the &quot;chapter&quot; tag, block quotes by the &quot;quote&quot; tag, and paragraph text by the &quot;body&quot; tag. The program then applies formatting rules globally and in a consistent manner. Text within LyX has a meaning and will be processed in a specific way.</p>
<p>And thus we have the first important component of a perfect writing environment: the program is aware of what content is. Such awareness allows for extremely complicated written pieces to be assembled in a relatively easy fashion.</p>
<h3>A Sloppy Process</h3>
<p>Despite its strengths, though, LyX is an incomplete solution. It focuses on the mechanical aspects of writing and ignores what is arguably the more important component: the creative process. Using LyX, I can assemble a true monstrosity of a manuscript replete with footnotes, endnotes, references, tables, lists of figures, indices, appendices, and all of the other components of something unreadable. Yet such elements are mere after-thoughts rather than the heart and soul of the work. The center is all about ideas.</p>
<p>Which brings me to the serious limitations inherent in most word processing programs: joining ideas together is a <img alt="" align="right" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe2.png" />sloppy process and they simply don’t facilitate the sloppiness.</p>
<p>Every writer is creative in a different way. I personally start by making a miscellaneous brain dump. Everything relevant to the topic is listed out and then I start to type additional thoughts which seem relevant. After a while, I run out of steam which prompts research, reference collection, reference reading and chicken scratch notes.&#160; Then I groan, swear a little, go for a walk, and kick ideas around in my head.</p>
<p>When I come back to the computer, I move things around even further and excise any bits that now seem irrelevant (carefully saving them for later). Usually by this point, I have probably started over a few times and hopefully clarified my goals.&#160; If the process works, I get a slightly better fix on direction I intend to take and, eventually, a first draft magically seems to appear.&#160; That is when the real fun starts.</p>
<p>Unfortunately, LyX was designed to work linearly. You start at the beginning and continue to the end. All of the words and ideas are supposed to come marching out like perfect little soldiers on parade day. Using such a tool can be extremely frustrating to someone who doesn&#8217;t think in a linear fashion: I want the freedom to be intuitive! </p>
<p>And in the name of freedom, I will probably use of four or five programs spanning two operating systems: OneNote for data collection, KDissert or FreeMind for MindMapping, and Word or LyX for the actual writing. Then I go back and update my files in the other programs.</p>
<p>There should be a better way! I want to use the same tool from beginning to end, not continually move between the word processor, the outliner, the mind mapper, and the note taker.</p>
<h2>A Potential Solution: Scrivener</h2>
<p>There just happens to be a program on Mac OS X that was apparently made for scattered people: <a href="http://www.literatureandlatte.com/">Scrivener</a>. Scrivener employs a number of simple (yet profoundly powerful) metaphors that let you manage the anarchy of creativity. These include:</p>
<ol>
<li>An intuitive and simple map of the project (similar to Word&#8217;s Outline View). </li>
<li>A corkboard that lets you create any number of &quot;index cards&quot; with a title and short summary of the card&#8217;s contents. </li>
<li>An outline view where the entire structure of your document can be seen and manipulated through drag and drop. </li>
</ol>
<p>Scrivener leverages its corkboard metaphor and outliner by linking the &quot;index card&quot; to a real piece of text. Thus, the index card actually represents the physical chunk of text in the underlying draft. The index cards can be moved, nested and set into folders and any changes made to the index cards are then instantly applied to the overall structure of the document. Pretty cool, huh? A given index card can represent a section, paragraph, chapter, or sentence. Even better is that cards can be split or joined together easily.</p>
<p>The practical result is that the entire draft is instantly fluid. You can experiment with new ideas, split away sections of text for later use, and re-arrange things as inspiration strikes you. It substantially enhances the organic process already provided by the computer. I know a surprising number of people who have moved to the Mac platform just so that they can use Scrivener.</p>
<p>While other programs (like Semantik, formally known as KDissert) use similar metaphors, the use of a &quot;summary&quot; field is what makes Scrivener stand apart. The summary begins life as an outline point and later becomes the synopsis of the section. It can keep notes, goals, or thoughts in addition to a regurgitation of what is in the text.&#160; And no other program uses anything like it. Therefore, while you can replicate many of Scrivener&#8217;s best features through Word or LyX&#8217;s outline view, you are stuck manipulating the entire text (which becomes impractical and unwieldy very quickly).</p>
<p style="text-align: center"><img alt="" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe3.png" /></p>
<p style="text-align: justify; margin-left: 18pt"><strong>The Outliner. </strong>Scrivener includes a high quality outliner that allows individual elements to be repositioned via drag and drop. Each outline item is connected to the text in the actual draft; therefore, changes in the outline view are immediately reflected in the structure of the document. Scrivener&#8217;s outliner is particularly effective via the inclusion of a &quot;synopsis&quot; field that contains a summary of the text. This summary field isn&#8217;t part of the full draft, and as a result, can begin life as an outline point that reflects the goal of the section. In contrast, the outline view in Microsoft Word uses the text of the actual document. In long or complicated documents, it is a slightly less than effective way to add new ideas.</p>
<p style="text-align: center"><img alt="" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe4.png" /></p>
<p style="margin-left: 18pt"><strong>The Corkboard. </strong>As an alternative to the outliner, Scrivener also provides a &quot;corkboard&quot; where parts of the document can be moved around on index cards. Each card has a title and summary that is is linked to a block of text in the document. Unlike the outliner, however, the corkboard only deals with one navigational element of the document. When at the top level, the cards might represent the parts or chapters of a book. When working on the corkboard of a book chapter, they might represent sections or individual scenes. There is no limit to the number of cards or nesting that can be done.</p>
<h3>Scrivener&#8217;s Singular Strength</h3>
<p>Though Scrivener handles the creative process beautifully, it isn&#8217;t a serious word or document processor. On the program&#8217;s <a href="http://www.literatureandlatte.com/scrivener.html">website</a>, the primary developer states that Scrivener is a &quot;personal writing tool.&quot; As a result, it seems uniquely geared to creative writing; that is to say, novels and screenplays. Not many novels or screenplays have a need for a bibliography, index, appendix, footnotes, or endnotes. As a result, Scrivener cannot handle the minutiae of complicated documents.</p>
<p>Just forget support for hyperlinks, cross-links, cross-references, figures, legends or graphics. They&#8217;re outside the developer&#8217;s stated need and are unlikely to appear. That&#8217;s too bad, because it makes Scrivener worthless to those who need support for these features. Microsoft Word has them and LyX has them, OpenOffice pretends that it has them. However, Word, LyX, OpenOffice and other word processors completely lack the creative tools that make Scrivener a joy to use.</p>
<p style="text-align: center"><img alt="" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe5.png" /></p>
<p style="margin-left: 18pt"><strong>A Glorified Text Editor. </strong>The weakest component of Scrivener is the actual word processor. Advanced (and even not so advanced) features like footnotes, endnotes, cross references of links are completely unsupported. It is simply unsuited to writing a complicated document like an article or cross-referenced book.</p>
<h2>A Combined Approach</h2>
<p>The simplicity of Scrivener&#8217;s word processor causes a semi-crisis. If given my choice, I would compose nearly everything in it for the convenience of its outliner and index cards. However, it isn&#8217;t up to supporting the type of heavy lifting I am often asked to do. While I could use it as my creative crutch, that worsens the overall problem. Instead of four programs across two platforms (Window/Linux), I would be using five programs across three platforms; not what I&#8217;m aiming for. I want to simplify my work process, not make it more complicated.</p>
<p>I&#8217;ve tried to find what I want in the software of others and determined that it doesn&#8217;t exist. The fallback is to develop it myself by turning to opensource solutions. Since LyX already meets my needs as a document processor, it is a great place to start. As a front-end to LaTeX, it automatically supports the advanced features I need. It is cross-platform, which means that the writing environment would be the same regardless of whether I am working on Windows, Mac OS X, or Linux. Additionally, it has deep integration with <a href="http://www.oak-tree.us/blog/index.php/science-and-technology/svn">revision control systems</a>, which greatly simplify collaboration. Last, it is available under the GNU public license, which means that I can access the source code. LyX combined with the same creative tools found in Scrivener would be nearly perfect.</p>
<p><img alt="" align="left" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe6.png" /></p>
<h3>Almost There: LyX&#8217;s Existing Features</h3>
<p>After a careful review of LyX, it becomes obvious that much of the functionality required for a robust outliner and corkboard is already present. At left is the outline panel in LyX. The outline is automatically generated from the heading information in a given document and any child documents. The particular example shown here is series of three essays kept in four different files: a master document and three child documents.</p>
<p>LyX already recognizes blocks of text and understands their contextual meaning. In fact, you can already specify the order of any element and what position it holds. Further, individual text elements can be moved from one child document to another. In other words, nearly all of the background elements for a Scrivener-like outliner or corkboard are already present.</p>
<h3>Form and Function</h3>
<p>What is missing is the ability to assign a summary or &quot;synopsis&quot; to a given chunk of text. This would ideally exist as associated meta-data and affiliated with a particular tag. Additionally, it might prove convenient to associate other meta-data in addition to the summary.</p>
<p>To add the &quot;creative elements,&quot;&#160; most development could focus on creating a user interface that&#160; blends the existing outline view with the functional equivalents of the corkboard and outliner from Scrivener. Convenient drag and drop of document sections from within the document map, outliner, or corkboard would allow text to be moved and positioned. The outliner would show the complete document with the option to expand or collapse a given section. The corkboard, in contrast, would show only the elements contained in one particular outline node.</p>
<p>The figures below show an example of what such a user-interfaces might look like. The first figure shows the outliner and the second shows the corkboard. (Though the index cards and outline points of the example correspond to the chapters and sections of the document map, this should not necessarily be required in an ideal implementation. Instead, the user would be able to determine which index cards correspond to sections and which correspond to a specific piece of evidence, argument, or narrative. That is to say, the user should be allowed the freedom to create the outline structure, rather than have it imposed.)</p>
<h2>Proposal</h2>
<p>I propose to create an add-on for LyX which would combine the best features of Scrivener with the already powerful capabilities of LyX. As described above, this would consist of two inter-related tools:</p>
<p>1) The Outliner. The outliner would be an expandable panel where the structure and rough content of a document could be laid out prior to beginning the first draft. Specific features of the Outliner would include:</p>
<p>a. Each outline point would have room for a title, synopsis and type of content (drawn from the list provided by the LaTeX class).</p>
<p>b. Individual nests in the outline can be expanded or collapsed.</p>
<p>c. Elements can be dragged and dropped from one point to another. The underlying document will be updated to reflect any changes.</p>
<p>d. Though most points in the outline might correspond to headings (e.g. book parts, chapters, sections, or subsections), this would not be required. Instead, any block of text could be assigned to a point in the outline. It would behave in precisely the same manner as other outline elements.</p>
<p style="text-align: center"><img alt="" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe7.png" /></p>
<p>2) The Corkboard. Housed in the same panel as the Outliner would also be a digital Corkboard which would display a small &quot;Index card&quot; with the title of an outline element in addition to the synopsis. However, in contrast to the outline, only the individual elements for a selected point in the document map would be shown. In the example below, the sections of a specific chapter, &quot;Eragon Shadeslayer: Sociopath&quot; are shown with their corresponding summaries. Changes in the order of the cards would be reflected in the underlying draft.</p>
<p style="text-align: center"><img alt="" src="http://www.oak-tree.us/blog/wp-content/uploads/2009/03/030509-0231-creatingthe8.png" /></p>
<h2>Conclusion</h2>
<p>The proposed additions to LyX would further expand its other excellent features, making it the only document/word processor with a powerful set of creative tools. By associating blocks of text with additional meta-data (like a synopsis), working with the document structure would become a visual and interactive process, thereby allowing for much greater flexibility. Indeed, such changes would bring LyX one step closer to writing perfection.</p>
<p><em>Note: A PDF copy of this article can be found <a href="http://www.oak-tree.us/stuff/LyX-Proposal.pdf">here</a>.</em></p>
<h3>Similar Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.oak-tree.us/blog/index.php/2009/05/13/lyx-outline" rel="bookmark" title="May 13, 2009">Introducing LyX-Outline 0.1</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/11/30/latex-cv-part2" rel="bookmark" title="November 30, 2009">Typeset Your Curriculum Vitae &ndash; Part 2: Extending and Customizing an Existing Document Class</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2008/11/20/software-cuttingoutclutter" rel="bookmark" title="November 20, 2008">On Writing &ndash; Software that cuts out distraction and clutter</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2008/12/14/wpf-svg-xaml-part2" rel="bookmark" title="December 14, 2008">WPF – SVG Graphics and XAML – Part 2</a></li>
<li><a href="http://www.oak-tree.us/blog/index.php/2009/11/02/custom-lyx-nih" rel="bookmark" title="November 2, 2009">Customizing LyX: Create an NIH Grant Proposal Template</a></li>
</ul>
<p><!-- Similar Posts took 17.480 ms --></p>
<p>Copywrite 2009: Rob Oakes.  <a href="http://www.oak-tree.us/blog">Apolitically Incorrect</a><br/><br/><a href="http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool">Creating the Perfect Writing Tool: A Proposal</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oak-tree.us/blog/index.php/2009/03/04/perfect-tool/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
