Dear all, I now finally get a chance to go back to this auto-cls-layout patch. Please allow me to reiterate the goal of it (r13611).
1. When a layout file is stored with the .lyx document, the layout file can be automatically recognized and used. This allows me to open and edit a lyx document (most likely sent by others) without having to put the .layout file to $HOME/.lyx/layouts, .cls to localtexmf, texhash and re-configure. 2. The .cls file can also be stored with the document, and will be used. It can also be in any place that latex knows through $TEXINPUTS. A slave document may not be compiled directly if it can not access this .cls file (e.g. when it resides in a directory different from its master). Known issues:
> > Not all concerns have been fixed. You still use the current directory > > as search path. This should be only the document directory.
This is addressed in the attached patch. OK to apply?
The next thing to check would be child documents that live in different paths than their parent. They should find the layout file in the parent path, too. This is impossible to do when they are opened without the master document, but possible if they are opened from the master document (have a look at Buffer::getMasterBuffer())
This is a non-issue. When the master document is loaded, the layout is loaded and is available to the slave documents that will be loaded later. As you have mentioned, there is no fix to the situation when the slave document is loaded without its master. Attached please find some test documents: cv-class.cls cvtry.layout local-layout.lyx slave/slave.lyx Currently: $ lyx local-layout.lyx will load both master and slave documents. Both files can be edited. Only the master document can be compiled since there is no cv-class.cls in the slave directory. Putting cv-class.cls in the slave directory, or somewhere under $TEXINPUTS can solve this problem. JMarc > Before we put in the core a big machinery to handle all the JMarc > things that can go wrong with this approach, I have been careful not to touch 'the big machinery'. For example, automatic re-configuration can be a bad thing since the internal oder of the layouts is significant... JMarc > I think we should stop and think. Any idea now? JMarc > I am sorry, but as it stands, I am not sure that this patch solves JMarc > more problems than it creates. I do not think I want it in 1.4. JMarc > So it might be better to skip this and go directly to a more JMarc > ambitious plan. Please be more specific about the 'more problems', as I have not found any. Instead, this has been a clear improvement to me, and to some others. Cheers, Bo
Index: src/lyxtextclass.C =================================================================== --- src/lyxtextclass.C (revision 13787) +++ src/lyxtextclass.C (working copy) @@ -917,15 +917,17 @@ if (loaded_) return true; - // Read style-file, current directory is searched before system ones - string real_file = path + "/" + name_ + ".layout"; - if (!fs::exists(real_file)) - real_file = libFileSearch("layouts", name_, "layout"); - loaded_ = const_cast<LyXTextClass*>(this)->read(real_file) == 0; + // Read style-file, provided path is searched before the system ones + string layout_file = ""; + if (path != "") + layout_file = path + "/" + name_ + ".layout"; + if (layout_file == "" || !fs::exists(layout_file)) + layout_file = libFileSearch("layouts", name_, "layout"); + loaded_ = const_cast<LyXTextClass*>(this)->read(layout_file) == 0; if (!loaded_) { lyxerr << "Error reading `" - << makeDisplayPath(real_file) + << makeDisplayPath(layout_file) << "'\n(Check `" << name_ << "')\nCheck your installation and " "try Options/Reconfigure..." << endl; Index: src/lyxtextclass.h =================================================================== --- src/lyxtextclass.h (revision 13787) +++ src/lyxtextclass.h (working copy) @@ -84,7 +84,7 @@ LyXLayout_ptr const & operator[](std::string const & vname) const; /// Sees to that the textclass structure has been loaded - bool load(std::string const & path=".") const; + bool load(std::string const & path="") const; /// Has this layout file been loaded yet? bool loaded() const { return loaded_; }
%%%% This is the cv document class, intended to provide a simple way %%%% to write your curriculum vitaes (resume) %%%% Author: Jean-Marc Lasgouttes ([EMAIL PROTECTED]) %%%% (with lot of help from Amir Karger <[EMAIL PROTECTED]>, %%%% Reuben Thomas <[EMAIL PROTECTED]> %%%% and Dekel Tsur <[EMAIL PROTECTED]>) %%%% WARNING: this document class is really simple. Don't expect too much. %%%% You can do what you want with this code. %% %%% Basic usage: %% \leftheader{text} : defines what should appear in the upper %% left of the first page. `Text' may contain \\ to break lines. %% \rightheader{text} : like \leftheader, but for the upper right of %% the first page %% \title{text} : defines a title, will will appear centered below the %% headers (or above, if the `titleabove' option is used) %% \maketitle: actually typesets the header. %% %% \section{text} : gives a title for a new topic of the CV. %% %% `topic' environment: begins an itemize-like environment where the %% argument of \item[] is typeset in font \itemfont. A line break is %% automatically inserted if the label is too long to fit in the %% margin (this can be controlled by option `notopicbreak'). %% %% The cv document class also has some support for bibliography. %% You can use the `thebibliography' environment as usual, in %% particular wih BibTeX . The output is similar to the `topic' %% environment. If you separate your bibliography into several %% sections, you may want to use the `contbibnum' document class %% option. %% %% Note that this class also has support for right-to-left languages, %% such as hebrew (courtesy Dekel Tsur). %% %% The document class accepts some options (along with the usual %% article.cls options): %% sf (default) produce title and headers in sans serif fonts %% plain produce all output in roman fonts. %% notopicbreak do not add a line break after longtopic labels. %% contbibnum let the numbering of bibliography items be %% continuous when there are several thebibliography %% environments %% titleabove output the title above the left and right headers, %% not below %% %% You can also modify directly the fonts used in the document be %% using the following macros. They take one parameter which is the font %% changing command. %% \headerfont: the font used in both headers. %% Defaults to sans serif. %% \titlefont: the font used for the title. %% Defaults to \LARGE sans-serif semi bold condensed. %% \sectionfont: the font used by \section when beginning a new topic. %% Defaults to sans-serif semi bold condensed. %% \subsectionfont: the font used by \subsection when beginning a new %% topic. %% Defaults to sans-serif semi bold condensed. %% \itemfont: the font used in descriptions of items. %% Defaults to sans-serif slanted. %% %% You can modify the following parameters using \renewcommand: %% \topicmargin: the left margin inside topics. %% Defaults to 20% of the text width (0.20\textwidth). %%% CHANGES: %% - 1.0 1998/03/23: First public release. %% - 1.1 1998/11/06: Better documentation, in order to release it for %% LyX ,added \refname, disabled all sectionning commands other that %% \section, disabled numbering of sections. %% - 1.2 1998/12/01: %% * Refined the algorithm to display the headers. In %% particular, \leftheader and \rightheader do not exist %% anymore. %% * Changed the justification of items labels %% [Thanks to Amir Karger <[EMAIL PROTECTED]> for the two %% changes above] %% * Added command \title %% * Changed the semantics of \topicfont and \itemfont, and added %% \titlefont and \headerfont %% %% - 1.3 1999/02/09: %% * The thebibliography environment does not add a section by %% itself anymore. This means that you can/should add your own %% and that \refname does not exist anymore. %% [Thanks to Reuben Thomas for the idea] %% * Added support for subsections (with associated font command %% \subsectionfont). %% * Added class options `sf' and `plain'. %% - 1.4 2001/05/04 %% * Added `notopicbreak' class option. %% - 1.5 2001/06/18 %% * Added hebrew support (from Dekel Tsur). %% * \topicmargin is now a macro and defaults to 20% of text width. %% * Added `contbibnum' class option. %% * Added `titleabove' class option. %% * some variables renaming and cleanups. %% Basic definition to have a real LaTeX document class \NeedsTeXFormat{LaTeX2e} \ProvidesClass{cvtry1}[2001/06/18 Curriculum vitae version 1.5] %% The fonts used in the layout [EMAIL PROTECTED]@fnt{#1}} [EMAIL PROTECTED]@fnt{#1}} [EMAIL PROTECTED]@fnt{#1}} [EMAIL PROTECTED]@fnt{#1}} [EMAIL PROTECTED]@fnt{#1}} % Some document class options. \DeclareOption{sf}{ \sectionfont{\sffamily\fontseries{sbc}\selectfont} \subsectionfont{\sffamily\fontseries{sbc}\selectfont} \itemfont{\sffamily\slshape} \headerfont{\sffamily} \titlefont{\sffamily\fontseries{sbc}\selectfont\LARGE} } \DeclareOption{plain}{ \sectionfont{\bfseries} \subsectionfont{\bfseries} \itemfont{\itshape} \headerfont{} \titlefont{\bfseries\LARGE} } [EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@[EMAIL PROTECTED] \DeclareOption{notopicbreak}{ [EMAIL PROTECTED]@[EMAIL PROTECTED] } [EMAIL PROTECTED]@[EMAIL PROTECTED]@num [EMAIL PROTECTED]@[EMAIL PROTECTED]@numfalse \DeclareOption{contbibnum}{ [EMAIL PROTECTED]@[EMAIL PROTECTED]@numtrue [EMAIL PROTECTED]@[EMAIL PROTECTED] } [EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@[EMAIL PROTECTED] \DeclareOption{titleabove}{ [EMAIL PROTECTED]@[EMAIL PROTECTED] } \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} \ExecuteOptions{sf,letterpaper,10pt,oneside,onecolumn,final} \ProcessOptions \LoadClass{article} % Support for RTL (Hebrew). This will be defined and set by babel for % RtL languages, but we define it here for the benefit of others. [EMAIL PROTECTED] %% stuff needed for the header [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] % Default to empty. \leftheader{}\rightheader{}\title{} % And now a command to actually show the headers [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]@[EMAIL PROTECTED]@{\endR}}% \else% [EMAIL PROTECTED]@[EMAIL PROTECTED]@{}}% \fi% #1% \end{tabular}} [EMAIL PROTECTED]@title}{\par\bigskip \begin{center} [EMAIL PROTECTED]@[EMAIL PROTECTED] \renewcommand{\maketitle}{% [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED] \par\noindent% [EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@lh}&[EMAIL PROTECTED]@rh} \end{tabular*} \par [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED] \bigskip\par} %% Redefine \section to use [EMAIL PROTECTED]@fnt \renewcommand{\section}{ [EMAIL PROTECTED]@} {-3.5ex [EMAIL PROTECTED] -1ex [EMAIL PROTECTED] -.2ex} {2.3ex [EMAIL PROTECTED] [EMAIL PROTECTED]@fnt}} \renewcommand{\subsection}{ [EMAIL PROTECTED] {-3.5ex [EMAIL PROTECTED] -1ex [EMAIL PROTECTED] -.2ex} {2.3ex [EMAIL PROTECTED] [EMAIL PROTECTED]@fnt}} % the other ones do not exist. \let\subsubsection=\relax \let\paragraph=\relax \let\subparagraph=\relax % we do not want any numbering \setcounter{secnumdepth}{0} %% Define the topic environment % The left margin for topics \newcommand{\topicmargin}{0.20\textwidth} [EMAIL PROTECTED] % The label stuff [EMAIL PROTECTED]@[EMAIL PROTECTED]@fnt #1\hfill} [EMAIL PROTECTED]@[EMAIL PROTECTED]@item [EMAIL PROTECTED]@length} [EMAIL PROTECTED]@item[#1]{% [EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@length}{#1}% [EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@length>\labelwidth\mbox{}\\*\fi% \else% [EMAIL PROTECTED]@[EMAIL PROTECTED] \fi} [EMAIL PROTECTED]@setup}{% [EMAIL PROTECTED] [EMAIL PROTECTED] \setlength{\leftmargin}{0cm}% [EMAIL PROTECTED] \else% [EMAIL PROTECTED] \setlength{\rightmargin}{0cm}% \fi% [EMAIL PROTECTED] [EMAIL PROTECTED]@makelabel} \newenvironment{topic} {\list{} { [EMAIL PROTECTED]@setup% [EMAIL PROTECTED]@[EMAIL PROTECTED] {\endlist} %% Redefine the thebibliography environment to look like the topic %% environment. The argument of thebibliography is ignored \renewenvironment{thebibliography}[1] [EMAIL PROTECTED] [EMAIL PROTECTED]@setup% [EMAIL PROTECTED]@code% \usecounter{enumiv}% [EMAIL PROTECTED]@empty% [EMAIL PROTECTED]@enumiv}}% [EMAIL PROTECTED]@[EMAIL PROTECTED]@num% [EMAIL PROTECTED]@[EMAIL PROTECTED] \fi% \sloppy \clubpenalty 4000 \widowpenalty 4000 [EMAIL PROTECTED] {\endlist% [EMAIL PROTECTED]@[EMAIL PROTECTED]@num% [EMAIL PROTECTED]@[EMAIL PROTECTED] \fi}
cvtry.layout
Description: Binary data
local-layout.lyx
Description: Binary data
slave.lyx
Description: Binary data