Thanks, Jean-Marc.
Please forgive me for being verbose in what follows. I want to be sure I
correctly understand what's going on.
If I understand you correctly, LyX determines the correspondence between
the layout and cls files by their common base names: for example,
x.layout will always associate with x.cls. Furthermore, LaTeX takes care
of any \RequirePackage, \LoadClass, or similar commands in x.cls, so LyX
does not need to know about these. This implies that LyX's
\DeclareLaTeXClass statement simply ties the current LyX layout file to
a LaTeX cls file with the same name, and the contents of the statement
play no role in making the association. In particular, the information
in curly brackets is used ONLY to specify a character string displayed
in the Document Settings drop-down.
You say that "adding the optional "letter" argument tells (LyX) that
your document actually starts with \documentclass{letter}." Does this
imply that when the argument is omitted for a layout file named
x.layout, LyX will start the document with "\documentclass{x}"?
What if, for some reason the layout designer wants two different layouts
to use a common LaTeX class? (E.g., using letterhead for both memos and
letters) Wouldn't this imply two layout files and one class file? How
would one make the association?
Finally, I have two questions about the argument(s) in square brackets
on the \DeclareLaTeXClass statement:
1. I'm assuming that it's just a list of comma-separated class and
style names. An alternative syntax might be a mandatory first
argument separated by a comma from an optional second argument,
but the second argument would be a list of names separated only by
spaces. (The documentation is not clear on this.) Is my assumption
that everything is comma-separated correct?
2. More importantly, the optional square brackets and arguments
within it are only used to mandate that LyX check that certain
packages and classes are installed before even allowing the user
to use the layout to select a document class. Since some LaTeX
implementations (e.g., MiKTeX) can load packages on the fly, this
might disallow some document classes that would otherwise run
perfectly. Also, LaTeX itself should tell the user if a package or
class is unavailable when the user tries to compile the output
(dvi, pdf, etc.) file. So the use of the square bracketed
argument(s) is a rather stringent standard. I can see its utility
for document classes typically used for large documents: so the
user does not waste time with something that in the end will not
work. Are there other uses?
Besides being more clear in the documentation (a draft of which I'd be
glad to offer once I'm sure I understand the command), one change that
LyX developers might consider is to issue a warning message and make the
document class available to the user even if the classes in square
brackets are not installed. This would allow the LaTeX implementation to
load missing packages dynamically and make less serious the layout
designer's decision to check for packages or not.
Thanks again for your help.
Marsh
On 7/12/2010 6:48 AM, Jean-Marc LASGOUTTES wrote:
Marshall Feldman<ma...@uri.edu> writes:
I'm writing my first LyX layout and running into trouble. When I use
the following command in the layout file, the document class appears
in the Document Settings drop-down list:
# \DeclareLaTeXClass[letter,graphix]{letter (mine)}
Assuming that the layout is named myletter.layout and you have a class
myletter.cls, the following should be enough:
# \DeclareLaTeXClass{letter (mine)}
Adding the optional "letter" argument tells that your document actually
starts with \documentclass{letter}. Adding "graphix" means that you want
"graphix.cls" to be available, which seems very strange to me. Assuming
you want to specify that graphicx.sty (the graphicx package) to be
available, the right command would be
# \DeclareLaTeXClass[letter,graphicx.sty]{letter (mine)}
Actually, the extra checks are not needed at all if the class is for
your own use. They have been proposed for the classes that we ship with
LyX and that may rely on `weird' packages.
In general one never tests for graphicx.sty or clac.sty, since they are
part of the `required' packages of LaTeX, i.e. supposed to be always
available.
Hope this helps.
JMarc