The attached patch adds support for the elsart.cls latex class. It is based on Herbert's class (with a couple fixes of my own) and the patch to support it has a similar effect to Herbert's.
This will get included in 1.3.1 if 1/ it gets a good testing. I do not have an elsart.cls here to try to typeset files. Also, what floats should be defined in elsart? 2/ I get some minimal doc to include in LaTeXConfig:lyx:in (at least) and Extended.lyx (optional). JMarc
Index: lib/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.363.2.5 diff -u -r1.363.2.5 ChangeLog --- lib/ChangeLog 11 Feb 2003 14:31:21 -0000 1.363.2.5 +++ lib/ChangeLog 11 Feb 2003 23:04:27 -0000 @@ -1,3 +1,9 @@ +2003-02-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * templates/elsart.lyx: + * layouts/elsart.layout: new class, adapted from work of Herbert + Voss and Rod Pinna + 2003-02-11 Angus Leeming <[EMAIL PROTECTED]> * BasicLyX.pm: enable reLyX to recognise natbib citations. Index: lib/layouts/elsart.layout =================================================================== RCS file: lib/layouts/elsart.layout diff -N lib/layouts/elsart.layout --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/layouts/elsart.layout 11 Feb 2003 23:04:30 -0000 @@ -0,0 +1,474 @@ +#% Do not delete the line below; configure depends on this +# \DeclareLaTeXClass[elsart,amssymb.sty]{article (elsevier)} +# Author: Rod Pinna <[EMAIL PROTECTED]> +# The Elsevier doc style also duplicates the theorem +# environments used by the AMS. The definitions here have been +# mainly taken from the amsmath.inc file, from lyx-1.0.2, by +# David L. Johnson and Jean-Marc Lasgouttes. Some modifications +# have been made. +# +# The Elsevier style *does not* implement the starred versions +# of these environments, so they are not supported by this layout. +# There are also a few AMS environments not impletemented by Elsevier, +# so they are not included either. +# +# Version 1.0 19990506 R. Pinna Inital version +# modified 2002-04-02 Herbert Voss <[EMAIL PROTECTED]> +# for use of BeginTitle/EndTitle +# modified 2003-03-11 JMarc for use of TitleLatexType/TitleLatexName + +# General textclass parameters +Columns 1 +Sides 2 +PageStyle headings +MaxCounter Counter_Subsection + + +ClassOptions +# FontSize "default" # controlled by class +End + +# elsart does not use the plain old \maketitle +TitleLatexType Environment +TitleLatexName frontmatter + +DefaultFont + Family Roman + Series Medium + Shape Up + Size Normal + Color None +EndFont + + +Style Standard + LatexName dummy + LatexType Paragraph + Margin Static + ParIndent MM + ParSkip 0.4 + ParSep 0.4 + TopSep 1.0 + BottomSep 1.0 + Align Block + AlignPossible Block, Left, Right, Center + LabelType No_Label +End + + +Style Keywords + LatexName keyword + LatexType Environment + Margin Static + ParIndent MM + InTitle 1 + ParSkip 0.4 + ParSep 0.4 + TopSep 1.0 + BottomSep 1.0 + Align Block + AlignPossible Block, Left, Right, Center + LabelType No_Label +Font + Color blue +EndFont +End + + +# Load standard defs, as most of the +# Elsevier stuff seems the same. +Input stdsections.inc +Input stdstarsections.inc +Input stdlists.inc +Input stdstruct.inc +Input stdlayouts.inc +Input stdfloats.inc +Input stdcounters.inc + + +# Title style definition +Style Title + Margin Static + LatexType Command + InTitle 1 + LatexName title + NextNoIndent 1 + ParSkip 0.4 + TopSep 1.3 + BottomSep 0.7 + ParSep 0.7 + Align Center + LabelType No_Label +# standard font definition + Font + Family Sans + Series Bold + Size Largest + EndFont +End + +# Author style definition +Style Author + Margin Static + LatexType Command + InTitle 1 + LatexName author + NextNoIndent 1 + ParSkip 0.4 + TopSep 0.7 + BottomSep 0.7 + ItemSep 0 + ParSep 0 + Align Center + AlignPossible Center + # standard font definition + Font + Series Bold + EndFont +End + +# Author Adress +Style Author_Address + Margin Static + LatexType Command + InTitle 1 + LatexName address + Align Center + AlignPossible Center + Labeltype Static + LabelString "Address: " + LabelFont + Shape Italic + EndFont +End + +Style Author_Email + Margin Static + LatexType Command + InTitle 1 + PassThru 1 + LatexName ead + Align Center + AlignPossible Center + Labeltype Static + LabelString "Email: " + TextFont + Family Typewriter + EndFont + LabelFont + Shape Italic + Family Roman + EndFont +End + +Style Author_URL + Margin Static + LatexType Command + InTitle 1 + PassThru 1 + LatexName ead{url} + Align Center + AlignPossible Center + Labeltype Static + LabelString "URL: " + TextFont + Family Typewriter + EndFont + LabelFont + Shape Italic + Family Roman + EndFont +End + +# thanks is like a footnote +Style Thanks + Margin Static + LatexType Command + LatexName thanks + InTitle 1 + Font + Size Small + Family Typewriter + Shape Italic + EndFont +End + +# new Abstract style definition +Style Abstract + Margin Static + LatexType Environment + LatexName abstract + NextNoIndent 1 + InTitle 1 + LeftMargin MMM + RightMargin MMM + ParIndent MM + ItemSep 0 + TopSep 0.7 + BottomSep 0.7 + ParSep 0 + Align Block + AlignPossible Block + LabelType Centered_Top_Environment + LabelString Abstract + LabelBottomSep 0.5 + + # standard font definition + Font + Size Small + EndFont + + # label font definition + LabelFont + Series Bold + Size Large + EndFont +End + + +# Theorm environments have been copied over from +# the amsmaths.inc file. It could not be inputfiled +# as it does some stuff which is incompatible with +# the Elsevier stlye, that is it redefines +# the theorem* environments in the preamble. + + + +# The environments defined are : +# - Theorem +# - Corollary +# - Lemma +# - Proposition +# - Conjecture +# - Criterion +# - Algorithm +# - Definition +# - Example +# - Problem +# - Remark +# - Note +# - Claim +# - Summary +# - Acknowledgement +# - Case + +# Theorem-numbered style declaration +Style Theorem + Margin First_Dynamic + LatexType Environment + LatexName thm + NextNoIndent 1 + LabelSep xx + ParIndent MMM + ParSkip 0.4 + ItemSep 0.2 + TopSep 0.7 + BottomSep 0.7 + ParSep 0.3 + Align Block + AlignPossible Block, Left + LabelType Static + LabelString "Theorem #." + + + # standard font definition + Font + Shape Italic + Size Normal + EndFont + + # label font definition + LabelFont + Shape Up + Series Bold + EndFont + +End + +# Lemma-numbered style declaration +Style Lemma + CopyStyle Theorem + LatexName lem + LabelString "Lemma #." + +# Preamble +# \theoremstyle{plain} +# \newtheorem{lem}[thm]{Lemma} %%Delete [thm] to re-start numbering +# EndPreamble +End + +# Corollary-numbered style declaration +Style Corollary + CopyStyle Theorem + LatexName cor + LabelString "Corollary #." + +# Preamble +# \theoremstyle{plain} +# \newtheorem{cor}[thm]{Corollary} %%Delete [thm] to re-start numbering +# EndPreamble +End + +# Proposition-numbered style declaration +Style Proposition + CopyStyle Theorem + LatexName prop + LabelString "Proposition #." + +# Preamble +# \theoremstyle{plain} +# \newtheorem{prop}[thm]{Proposition} %%Delete [thm] to re-start numbering +# EndPreamble +End + +# Criterion-numbered style declaration +Style Criterion + CopyStyle Theorem + LatexName crit + LabelString "Criterion #." + +# Preamble +# \theoremstyle{plain} +# \newtheorem{crit}[thm]{Criterion} %%Delete [thm] to re-start numbering +# EndPreamble +End + +# Algorithm-numbered style declaration +Style Algorithm + CopyStyle Theorem + LatexName alg + LabelString "Algorithm #." + +# Preamble +# \theoremstyle{plain} +# \newtheorem{alg}[thm]{Algorithm} %%Delete [thm] to re-start numbering +# EndPreamble +End + +# Definition-numbered style declaration +Style Definition + CopyStyle Theorem + LatexName defn + LabelString "Definition #." + + # standard font definition + Font + Shape Up + EndFont + + # label font definition + LabelFont + Shape Up + Series Bold + EndFont + +# Preamble +# \theoremstyle{definition} +# \newtheorem{defn}[thm]{Definition} +# EndPreamble +End + +# Conjecture-numbered style declaration +Style Conjecture + CopyStyle Theorem + LatexName conj + LabelString "Conjecture #." + +# Preamble +# \theoremstyle{plain} +# \newtheorem{conj}[thm]{Conjecture} %%Delete [thm] to re-start numbering +# EndPreamble +End + +# Example-numbered style declaration +Style Example + CopyStyle Theorem + LatexName exmp + LabelString "Example #." + +# Preamble +# \theoremstyle{definition} +# \newtheorem{exmp}[thm]{Example} +# EndPreamble +End + +# Problem-numbered style declaration +Style Problem + CopyStyle Theorem + LatexName prob + LabelString "Problem #." + +# Preamble +# \theoremstyle{definition} +# \newtheorem{prob}[thm]{Problem} +# EndPreamble +End + +# Remark-numbered style declaration +Style Remark + CopyStyle Theorem + LatexName rem + LabelString "Remark #." + +End + +# Note-numbered style declaration +Style Note + CopyStyle Theorem + LatexName note + LabelString "Note #." + +End + +# Claim-numbered style declaration +Style Claim + CopyStyle Theorem + LatexName claim + LabelString "Claim #." + +End + +# Summary-numbered style declaration +Style Summary + CopyStyle Theorem + LatexName summ + LabelString "Summary #." + +End + +# Case-numbered style declaration +Style Case + CopyStyle Theorem + LatexName case + LabelString "Case #." + +End + +# Acknowledgement-numbered style declaration +#Style Acknowledgement +# CopyStyle Theorem +# LatexName ack +# LabelString "Acknowledgement #." +# +#End + +# Acknowledgement style definition +# This is not taken from the AMS defs, +# so as to match the output of the +# style file. + +Style Acknowledgement + Margin Static + LatexType environment + LatexName ack + Labeltype Top_Environment + LabelBottomsep 1 + LabelString "Acknowledgement #." + parsep 0.3 + +LabelFont + Size large + Series Bold +EndFont + +End Index: lib/templates/elsart.lyx =================================================================== RCS file: lib/templates/elsart.lyx diff -N lib/templates/elsart.lyx --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/templates/elsart.lyx 11 Feb 2003 23:04:31 -0000 @@ -0,0 +1,142 @@ +#LyX 1.3 created this file. For more info see http://www.lyx.org/ +\lyxformat 221 +\textclass elsart +\begin_preamble +\usepackage{natbib} +\usepackage{amssymb} +\end_preamble +\language english +\inputencoding auto +\fontscheme default +\graphics default +\paperfontsize default +\spacing single +\papersize Default +\paperpackage a4 +\use_geometry 0 +\use_amsmath 0 +\use_natbib 0 +\use_numerical_citations 0 +\paperorientation portrait +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\defskip medskip +\quotes_language english +\quotes_times 2 +\papercolumns 1 +\papersides 1 +\paperpagestyle default + +\layout Title + +Insert your Title Here +\layout Author + +Author's name +\layout Author Address + +Author's address +\layout Author Email + +email@address +\layout Author URL + +http://www.home.page +\layout Abstract + +Text of abstract. +\layout Keywords + +keyword1 +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +sep +\end_inset + + keyword2 +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +sep +\end_inset + + keyword3 +\layout Keywords + + +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +PACS +\end_inset + + code1 +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +sep +\end_inset + + code2 +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +sep +\end_inset + + code3 +\layout Section + +First section +\layout Standard + +See style options in the +\family sans +Document\SpecialChar ~ +Layout +\family default + popup (accessed from the +\family sans +Layout +\family default + menu). + See the elsart manual for style options, special macros, and the like +\begin_inset LatexCommand \cite{mycitation} + +\end_inset + +. +\layout Bibliography +\bibitem {mycitation} + +Author, +\begin_inset Quotes eld +\end_inset + +Title +\begin_inset Quotes erd +\end_inset + +, Journal +\series bold +Volume +\series default +, page--numbers (year). +\the_end Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.1021.2.1 diff -u -r1.1021.2.1 ChangeLog --- src/ChangeLog 7 Feb 2003 15:11:00 -0000 1.1021.2.1 +++ src/ChangeLog 11 Feb 2003 23:04:58 -0000 @@ -1,3 +1,13 @@ +2003-02-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * paragraph.C (asString): remove two unused variables + + * lyxtextclass.C (readTitleType): + (Read): + (LyXTextClass): handle new members titletype_ and titlename_ + + * buffer.C (latexParagraphs): honor LyXTextClass::titletype + 2003-02-07 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * text.C (getLengthMarkerHeight): Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.399 diff -u -r1.399 buffer.C --- src/buffer.C 23 Jan 2003 16:23:36 -0000 1.399 +++ src/buffer.C 11 Feb 2003 23:05:06 -0000 @@ -2158,6 +2158,7 @@ { bool was_title = false; bool already_title = false; + LyXTextClass const & tclass = params.getLyXTextClass(); // if only_body while (par != endpar) { @@ -2174,10 +2175,24 @@ lyxerr <<"Error in latexParagraphs: You" " should not mix title layouts" " with normal ones." << endl; - } else + } else if (!was_title) { was_title = true; + if (tclass.titletype() == TITLE_ENVIRONMENT) { + ofs << "\\begin{" + << tclass.titlename() + << "}\n"; + texrow.newline(); + } + } } else if (was_title && !already_title) { - ofs << "\\maketitle\n"; + if (tclass.titletype() == TITLE_ENVIRONMENT) { + ofs << "\\end{" << tclass.titlename() + << "}\n"; + } + else { + ofs << "\\" << tclass.titlename() + << "\n"; + } texrow.newline(); already_title = true; was_title = false; @@ -2196,7 +2211,14 @@ } // It might be that we only have a title in this document if (was_title && !already_title) { - ofs << "\\maketitle\n"; + if (tclass.titletype() == TITLE_ENVIRONMENT) { + ofs << "\begin{" << tclass.titlename() + << "}\n"; + } + else { + ofs << "\\" << tclass.titlename() + << "\n"; + } texrow.newline(); } } Index: src/layout.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/layout.h,v retrieving revision 1.40 diff -u -r1.40 layout.h --- src/layout.h 6 Aug 2002 22:38:38 -0000 1.40 +++ src/layout.h 11 Feb 2003 23:05:08 -0000 @@ -80,6 +80,15 @@ }; +/// The different title types +enum LYX_TITLE_LATEX_TYPES { + /// + TITLE_COMMAND_AFTER = 1, + /// + TITLE_ENVIRONMENT +}; + + /// The different label types enum LYX_LABEL_TYPES { /// Index: src/lyxtextclass.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclass.C,v retrieving revision 1.22 diff -u -r1.22 lyxtextclass.C --- src/lyxtextclass.C 27 Nov 2002 10:30:13 -0000 1.22 +++ src/lyxtextclass.C 11 Feb 2003 23:05:10 -0000 @@ -64,6 +64,8 @@ opt_fontsize_ = "10|11|12"; opt_pagestyle_ = "empty|plain|headings|fancy"; provides_ = nothing; + titletype_ = TITLE_COMMAND_AFTER; + titlename_ = "maketitle"; loaded = false; } @@ -107,10 +109,11 @@ TC_RIGHTMARGIN, TC_FLOAT, TC_COUNTER, - TC_NOFLOAT + TC_NOFLOAT, + TC_TITLELATEXNAME, + TC_TITLELATEXTYPE }; - // Reads a textclass structure from file. bool LyXTextClass::Read(string const & filename, bool merge) { @@ -137,6 +140,8 @@ { "secnumdepth", TC_SECNUMDEPTH }, { "sides", TC_SIDES }, { "style", TC_STYLE }, + { "titlelatexname", TC_TITLELATEXNAME }, + { "titlelatextype", TC_TITLELATEXTYPE }, { "tocdepth", TC_TOCDEPTH } }; @@ -149,7 +154,7 @@ << MakeDisplayPath(filename) << endl; - LyXLex lexrc(textClassTags, TC_NOFLOAT); + LyXLex lexrc(textClassTags, TC_TITLELATEXTYPE); bool error = false; lexrc.setFile(filename); @@ -327,13 +332,19 @@ case TC_COUNTER: readCounter(lexrc); break; + case TC_TITLELATEXTYPE: + readTitleType(lexrc); + break; + case TC_TITLELATEXNAME: + if (lexrc.next()) + titlename_ = lexrc.getString(); + break; case TC_NOFLOAT: if (lexrc.next()) { string const nofloat = lexrc.getString(); floatlist_->erase(nofloat); } break; - } } @@ -355,6 +366,33 @@ } +void LyXTextClass::readTitleType(LyXLex & lexrc) +{ + keyword_item titleTypeTags[] = { + { "commandafter", TITLE_COMMAND_AFTER }, + { "environment", TITLE_ENVIRONMENT } + }; + + pushpophelper pph(lexrc, titleTypeTags, TITLE_ENVIRONMENT); + + int le = lexrc.lex(); + switch (le) { + case LyXLex::LEX_UNDEF: + lexrc.printError("Unknown output type `$$Token'"); + return; + case TITLE_COMMAND_AFTER: + case TITLE_ENVIRONMENT: + titletype_ = static_cast<LYX_TITLE_LATEX_TYPES>(le); + break; + default: + lyxerr << "Unhandled value " << le + << " in LyXTextClass::readTitleType." << endl; + + break; + } +} + + void LyXTextClass::readOutputType(LyXLex & lexrc) { keyword_item outputTypeTags[] = { @@ -887,6 +925,21 @@ { return maxcounter_; } + + +LYX_TITLE_LATEX_TYPES LyXTextClass::titletype() const +{ + return titletype_; +} + + +string const & LyXTextClass::titlename() const +{ + return titlename_; +} + + + int LyXTextClass::size() const Index: src/lyxtextclass.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclass.h,v retrieving revision 1.11 diff -u -r1.11 lyxtextclass.h --- src/lyxtextclass.h 7 Nov 2002 19:51:22 -0000 1.11 +++ src/lyxtextclass.h 11 Feb 2003 23:05:10 -0000 @@ -51,6 +51,8 @@ /// void readOutputType(LyXLex &); /// + void readTitleType(LyXLex &); + /// void readMaxCounter(LyXLex &); /// void readClassOptions(LyXLex &); @@ -139,6 +141,12 @@ string const & rightmargin() const; /// int maxcounter() const; + + /// The type of command used to produce a title + LYX_TITLE_LATEX_TYPES titletype() const; + /// The name of the title command + string const & titlename() const; + /// int size() const; private: @@ -189,6 +197,11 @@ string rightmargin_; /// highest header level used in this layout. int maxcounter_; // add approp. signedness + + /// The type of command used to produce a title + LYX_TITLE_LATEX_TYPES titletype_; + /// The name of the title command + string titlename_; /// Paragraph styles used in this layout LayoutList layoutlist_; Index: src/paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.235 diff -u -r1.235 paragraph.C --- src/paragraph.C 15 Jan 2003 14:23:20 -0000 1.235 +++ src/paragraph.C 11 Feb 2003 23:05:16 -0000 @@ -1729,11 +1729,9 @@ // Used for building the table of contents string const Paragraph::asString(Buffer const * buffer, bool label) const { - BufferParams const & bparams = buffer->params; string s; if (label && !params().labelString().empty()) s += params().labelString() + ' '; - string::size_type const len = s.size(); for (pos_type i = 0; i < size(); ++i) { value_type c = getChar(i);