Hi Manoj,

In LyX, most of the specialized commands are housed inside of "insets".  All
of the floats and many of the commands in LyX make use of them.  The
provide, in essence, a convenient container for LaTeX commands.

A custom inset is just an inset that you have defined yourself.  As an
example, about a month ago this list was talking about ways to create a
float environment for longtables.  Someone suggested that using the
following command might work: 

\afterpage{\clearpage tablecontent}

So, I spent a while testing this out, and it works great.  However, I
greatly dislike the use of evil red text (ERT) in LyX.  The entire reason
that I use LaTeX (and by extension LyX) is to get away from "finger painting
my documents", and providing pages and pages of personal macro definitions I
the *epitome* of finger painting.  Thus, I greatly prefer to define personal
macros (either in module files or in layouts) and make use of those,
instead.  For this reason, I transformed \afterpage{clearpage tablecontent}
into a new macro:

\usepackage{afterpage}
\newcommand{\longtablepage}[1]{%
        \afterpage{\clearpage #1}}

And then I placed that macro in its own module.  Finally, I created a custom
inset that would act as a float for longtables.  Here is the float
definition:

InsetLayout Custom:Longtable
        LyXType                                 custom
        Labelstring                             longtable
        Decoration                              classic
        LabelFont
                Color                           collapsable
                Size                            Small
        EndFont
        MultiPar                                true
        LatexName                               longtablepage
        LatexType                               command
        Requires                                afterpage
        Preamble
                \usepackage{afterpage}
                \newcommand{\longtablepage}[1]{%
                        \afterpage{\clearpage #1}}
        EndPreamble
End

Here is a brief description of the parameters.  The LyXType defines it as a
custom float with a lable of "longtable".  It uses the "classic" decoration
(which happens to be a little red box, similar to the label for "figure" or
table").  The float is collapsible and the font-size is small.  MultiPar =
true allows me to enter multiple paragraphs into the environment. 

The next few commands define the LaTeX options.  LatexName is the name of
the command, "longtable" (see the definition above).  LatexType tells LyX
that this inset is a command (for other types, see the Advanced User
Manual).  It requires the "afterpage" package.  Finally, the preamble
command defines what should be placed in the document's preamble for the
command to work.

Like I said above, this information can be placed in a module, which makes
it conveniently available in any document.  It also returns LyX to a "What
You See is What You Mean" writing environment.

Hope that helps.

Cheers,

Rob Oakes

PS, the module for this particular command is attached in case it is of
interest to anyone.  To use it, just place it in the "layouts" folder of
your user directory.

Attachment: longtablepage.module
Description: Binary data

Reply via email to