Other posts related to customization

 | July 13, 2010 6:38 pm

In the past few months, I’ve written several articles about the ways LyX can be customized.  These included a brief introduction to layout files and how they relate to document classes in addition to a tour of character styles and how you can add them to the LyX local layout.  What I have not written about, though, is one of the most important ways of extending LyX, the module.

Ever since version 1.6 of LyX, the core LyX developers have worked very hard to make LyX a modular system.  Instead of hard coding values and options – as they had done previously – they’ve instead placed all of the needed information in configuration files that can be edited and modified by users.  This is a Very Good Thng.  It means that (given enough motivation), you can customize LyX to behave exactly was you wish.  You can change the default document classes, styles, fonts and anything else that your little heart desires.  It also means that any extensions you create will exist as first-class citizens.  They have access to all of the internal wizardry as the default document classes and features.

In order to make this transition work, it was necessary to have certain chunks of code that could be switched on when needed and switched off when not required, and that’s how “modules” were born.  In a lot of ways, you might think of modules as document plugins.  They let you do stuff that, while not required, can greatly improve your editing experience.  (Modules are switched on and off from the “Document Settings” pane.)

They let you do things like run Sweave code, add additional theorem environments, or apply a different style to your text.  But unlike a layout file, they are not tied to any particular document class or type; which makes them very powerful.  In fact, nearly all of them they can be used with any document type that LyX supports.

There are two main types of modules:

  1. Modules that contain all of the code needed to implement a particular feature (or modify an existing one) and do not reference external packages.
  2. Modules that load existing LaTeX styles/packages and translate their features into insets, commands and headings.

In both cases, modules serve as a container for the code.  You can use a module to package code that would normally live in a document layout file, or you can use code that might have been placed in the local layout.  The code may be a document header, a new LaTeX command, a character style, a custom inset, or any other type of user customization that LyX supports.

The biggest difference between using a module instead of a layout, of course, is that when the code is placed in a module, you can then add it to any document on your system.  This makes modules a tremendously flexible way to reuse customizations that you’ve created.  In fact, in nearly all cases, they are the best way to package your customizations for use on your own system or for sharing with others.

In this article, I’d like to introduce the module.  I will explain its position in the larger LyX/LaTeX “big picture”, its internal anatomy and provide a few examples of how it can be used to add new features.

Show me more… »

 | November 14, 2009 5:00 pm

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.

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?

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!

Thankfully, there is.  It’s through the consistent use of styles.

Show me more… »