From 102266cf922b4a62c9ce33635b67e98a8872c004 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 13 Feb 2003 17:49:09 +0000 Subject: [PATCH] elsart support git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6140 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 6 + lib/doc/LaTeXConfig.lyx.in | 23 +- lib/layouts/elsart.layout | 475 +++++++++++++++++++++++++++++++++++++ lib/templates/elsart.lyx | 142 +++++++++++ src/ChangeLog | 10 + src/buffer.C | 28 ++- src/layout.h | 9 + src/lyxtextclass.C | 61 ++++- src/lyxtextclass.h | 13 + src/paragraph.C | 2 - 10 files changed, 759 insertions(+), 10 deletions(-) create mode 100644 lib/layouts/elsart.layout create mode 100755 lib/templates/elsart.lyx diff --git a/lib/ChangeLog b/lib/ChangeLog index b8f2bc8991..b9cbc0ae20 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2003-02-11 Jean-Marc Lasgouttes + + * templates/elsart.lyx: + * layouts/elsart.layout: new class, adapted from work of Herbert + Voss and Rod Pinna + 2003-02-12 Tomasz Luczak * layouts/mwart.cls: diff --git a/lib/doc/LaTeXConfig.lyx.in b/lib/doc/LaTeXConfig.lyx.in index 99e023a463..82eccc1409 100644 --- a/lib/doc/LaTeXConfig.lyx.in +++ b/lib/doc/LaTeXConfig.lyx.in @@ -693,6 +693,27 @@ egs can be used to write articles for the European Geophysical Society. \layout Subsection +elsart +\layout Description + +Found: @chk_elsart@ +\layout Description + +CTAN: +\family typewriter +macros/latex/contrib/supported/elsevier/ +\layout Description + +WWW: +\family typewriter +http://authors.elsevier.com/ +\layout Description + +Notes: This package is intended for producing journal articles for publication + by Elsevier Science. + +\layout Subsection + entcs \layout Description @@ -743,7 +764,7 @@ extletter CTAN: \family typewriter -tex-archive/macros/latex/contrib/other/extsizes/ +macros/latex/contrib/other/extsizes/ \layout Description Notes: These document classes are equivalent to the corresponding standard diff --git a/lib/layouts/elsart.layout b/lib/layouts/elsart.layout new file mode 100644 index 0000000000..143cbcbcd8 --- /dev/null +++ b/lib/layouts/elsart.layout @@ -0,0 +1,475 @@ +#% Do not delete the line below; configure depends on this +# \DeclareLaTeXClass[elsart,amssymb.sty]{article (elsevier)} +# Author: Rod Pinna +# 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 +# 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 + LatexParam "[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 diff --git a/lib/templates/elsart.lyx b/lib/templates/elsart.lyx new file mode 100755 index 0000000000..47ca0395db --- /dev/null +++ b/lib/templates/elsart.lyx @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog index c156b070a4..5aac0c6fc9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2003-02-11 Jean-Marc Lasgouttes + + * 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-13 John Levon * CutAndPaste.C: remove debug diff --git a/src/buffer.C b/src/buffer.C index 77916fbac5..370ebdce27 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2230,6 +2230,7 @@ void Buffer::latexParagraphs(ostream & ofs, Paragraph * par, { bool was_title = false; bool already_title = false; + LyXTextClass const & tclass = params.getLyXTextClass(); // if only_body while (par != endpar) { @@ -2246,10 +2247,24 @@ void Buffer::latexParagraphs(ostream & ofs, Paragraph * par, 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; @@ -2268,7 +2283,14 @@ void Buffer::latexParagraphs(ostream & ofs, Paragraph * par, } // 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 << "\\end{" << tclass.titlename() + << "}\n"; + } + else { + ofs << "\\" << tclass.titlename() + << "\n"; + } texrow.newline(); } } diff --git a/src/layout.h b/src/layout.h index fd86e9910f..637a059a61 100644 --- a/src/layout.h +++ b/src/layout.h @@ -80,6 +80,15 @@ enum LYX_LATEX_TYPES { }; +/// The different title types +enum LYX_TITLE_LATEX_TYPES { + /// + TITLE_COMMAND_AFTER = 1, + /// + TITLE_ENVIRONMENT +}; + + /// The different label types enum LYX_LABEL_TYPES { /// diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 88644cd84d..d44748b0e5 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -60,6 +60,8 @@ LyXTextClass::LyXTextClass(string const & fn, string const & cln, opt_fontsize_ = "10|11|12"; opt_pagestyle_ = "empty|plain|headings|fancy"; provides_ = nothing; + titletype_ = TITLE_COMMAND_AFTER; + titlename_ = "maketitle"; loaded = false; } @@ -103,10 +105,11 @@ enum TextClassTags { 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) { @@ -133,6 +136,8 @@ bool LyXTextClass::Read(string const & filename, bool merge) { "secnumdepth", TC_SECNUMDEPTH }, { "sides", TC_SIDES }, { "style", TC_STYLE }, + { "titlelatexname", TC_TITLELATEXNAME }, + { "titlelatextype", TC_TITLELATEXTYPE }, { "tocdepth", TC_TOCDEPTH } }; @@ -145,7 +150,7 @@ bool LyXTextClass::Read(string const & filename, bool merge) << MakeDisplayPath(filename) << endl; - LyXLex lexrc(textClassTags, TC_NOFLOAT); + LyXLex lexrc(textClassTags, TC_TITLELATEXTYPE); bool error = false; lexrc.setFile(filename); @@ -323,13 +328,19 @@ bool LyXTextClass::Read(string const & filename, bool merge) 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; - } } @@ -351,6 +362,33 @@ bool LyXTextClass::Read(string const & filename, bool merge) } +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(le); + break; + default: + lyxerr << "Unhandled value " << le + << " in LyXTextClass::readTitleType." << endl; + + break; + } +} + + void LyXTextClass::readOutputType(LyXLex & lexrc) { keyword_item outputTypeTags[] = { @@ -885,6 +923,21 @@ int LyXTextClass::maxcounter() const } +LYX_TITLE_LATEX_TYPES LyXTextClass::titletype() const +{ + return titletype_; +} + + +string const & LyXTextClass::titlename() const +{ + return titlename_; +} + + + + + int LyXTextClass::size() const { return layoutlist_.size(); diff --git a/src/lyxtextclass.h b/src/lyxtextclass.h index 20f19476cf..2b0a3a538a 100644 --- a/src/lyxtextclass.h +++ b/src/lyxtextclass.h @@ -47,6 +47,8 @@ public: /// void readOutputType(LyXLex &); /// + void readTitleType(LyXLex &); + /// void readMaxCounter(LyXLex &); /// void readClassOptions(LyXLex &); @@ -135,6 +137,12 @@ public: 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: @@ -186,6 +194,11 @@ private: /// 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_; diff --git a/src/paragraph.C b/src/paragraph.C index b3883753fa..a37ee9b3a0 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1760,11 +1760,9 @@ bool Paragraph::isMultiLingual(BufferParams const & bparams) // 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);