On 2011-12-14, Eric Weir wrote:

> I've been reading the documentation and stuff that I've found on the
> web related to developing customized formats, but am still unclear
> about many things. I'd like to follow up on this post as a way to get
> some help on the things that are of highest priority at the moment. 

> Again, I compose in Scrivener, export to LaTeX, and import into LyX.
> I'd like to be able to apply my customizations to multiple documents.
> I'll be using an article class. And again, what I want is simple: Title
> bold in a font only a little large than text, sometimes centered,
> sometimes at the left margin; headings bold at the left margin in a
> font the same size as text; ability to switch between footnotes and
> endnotes.

> On Dec 7, 2011, at 2:43 PM, Guenter Milde wrote:

>> * Maybe a LaTeX document class works with some minor configuration that can
>>  be done in the document preamble.

>>  You need to find it and read the documentation
>>  start the LaTeX document with
>>  \documentclass{<the-nice-class-i-found> and now there is 
>>  a choice:

>>  a) import and do the configuration to each
>>     imported document under Document>Settings.

> Nope. Don't wanna do that. I'd want to be able to use my customizations
> across multiple documents. 

I see. Still, for some of this tweaks you could consider a script-based
approach (after the basic import works, see below): 

* Import a sample document (a.tex -> a.lyx)
* "hand configure" the Document->Settings 
* save to a different file (b.lyx)

* Make a diff of the two *.lyx files: diff -u a.lyx b.lyx
* Using your favourite script language or text editor macros,
  write a script that can convert a.lyx to b.lyx 
  in a way that works for other imported documents.

  BTW: The script may also include the tex-lyx conversion: 
   lyx -i tex a.tex 
  or directly call `tex2lyx` where you can also specify command
  line options (you might need to specify the exact location if it is not
  on the binary path)

This works nicely together with b) - the script would then only need to
insert some module imports at the right place.

>>  b) write a LyX module (document class extension) with your
>>     configuration and load it under Document settings (again for each
>>     imported document)

> I think this is what I want to do, butI'am not sure, in spite of my
> reading, how to start. My understanding is that modules are similar to
> layouts except that they have a different extension and can be used
> across documents.

Almost: Modules can be used in combination with document classes and with
other modules. For a physicist: they are orthogonal.

Layouts define the "type" of the document, Modules add "features".

If you have some LaTeX knowledge, it may helpt to think of "layouts"
as analogon to a LaTeX document class (*.cls) and "modules" as analogon
to a LaTeX package/style (*.sty)

> I've pretty much settled on the KOMA-script classes, specifically for
> now the article class. I've copied the layout for it to the layouts
> folder in my user directory. I'm assuming I can use it as a base for
> creating the modules I'd like to have. 

You are better of using an existing module as base for a module. Try to
find one that does something similar to what you want to achieve. (If you
go for the module approach, you don't need to copy the KOMA article
layout to your folder, however it might be good to have it as reference
(together with the included files).

> I've looked at the code in several layouts. I find it more difficult to
> understand than LaTeX code; I can see that something is a command, but
> I have no idea what the command does. 

Maybe starting with one of the simpler modules (side-by-side with the
Customization Guide) will be the easier approach.

> I'm guessing that the commands listed and defined in section 5.3 of the
> Customizing LyX guide are the ones that I would use. But it's not
> obvious to me which ones I would use for modifying KOMA-script titling
> and section heading.

Do you have the KOMA guide (scrguien.pdf) ready? Find out and try (on a
test.tex document) the preamble commands required for the desired
configuration.

Now, in your module, insert these commands as 

AddToPreamble
        % KOMA script preamble customization commands 
        <LaTeX code>
EndPreamble


> I'm taking it that creating a LyX module or layout does not involve any
> use of LATeX commands

No. The layout or module files are the "glue" between LyX and LaTeX.
Hence they contain both, definitions for the appearance in the GUI and
the commands or environments to use for the LaTeX export 
(the LaTeXName entry in Style/Inset definitions and the Preamble code).

Günter

Reply via email to