From 0c622a5c580b215c7e75a68098ac6d1959146dae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Mon, 26 Nov 2012 03:39:40 +0100 Subject: [PATCH] aastex: update layout and example file - also fix an issue in the generic lyx2lyx InsetArgument routines --- lib/layouts/aastex.layout | 746 +++++++++++++++++++------------------- lib/lyx2lyx/lyx_2_1.py | 45 ++- lib/templates/aastex.lyx | 46 +-- 3 files changed, 438 insertions(+), 399 deletions(-) diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index fd8c9c9d30..01f443b82e 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -32,33 +32,34 @@ # Version 1.3 5/7/04 - Updated for AASTeX 5.2 # Version 1.4 26/10/08 - new custom insets for \altaffilmark, \tablenotemark # - new environments for \altaffiltext and \tablenotetext +# Version 1.5 26/11/12 - added mandatory argument for \altaffiltext Format 41 -Columns 1 -Sides 1 -#SecNumDepth 3 -TocDepth 0 -PageStyle Plain -Provides amsmath 1 -Provides natbib 1 -Provides url 1 +Columns 1 +Sides 1 +#SecNumDepth 3 +TocDepth 0 +PageStyle Plain +Provides amsmath 1 +Provides natbib 1 +Provides url 1 ClassOptions - PageStyle "" + PageStyle "" End Style Standard - Margin Static - LatexType Paragraph - LatexName dummy - ParIndent MM - ParSkip 0.4 - Align Block - AlignPossible Block, Left, Right, Center - LabelType No_Label + Margin Static + LatexType Paragraph + LatexName dummy + ParIndent MM + ParSkip 0.4 + Align Block + AlignPossible Block, Left, Right, Center + LabelType No_Label End @@ -66,19 +67,19 @@ End # Therefore I'll define the entries first, then fill them in Style Section - TocLevel 1 + TocLevel 1 End Style Subsection - TocLevel 2 + TocLevel 2 End Style Subsubsection - TocLevel 3 + TocLevel 3 End Style Paragraph - TocLevel 4 + TocLevel 4 End Style Itemize @@ -176,334 +177,339 @@ NoStyle Bibliography Style Section - Align Center - NextNoIndent 0 - TopSep 2.0 - BottomSep 1.3 + Align Center + NextNoIndent 0 + TopSep 2.0 + BottomSep 1.3 Font - Series Bold - Size Normal + Series Bold + Size Normal EndFont - TocLevel 1 + TocLevel 1 End Style Subsection - Align Center - NextNoIndent 0 - TopSep 1.7 - BottomSep 1.1 + Align Center + NextNoIndent 0 + TopSep 1.7 + BottomSep 1.1 Font - Series Bold - Size Normal + Series Bold + Size Normal EndFont - TocLevel 2 + TocLevel 2 End Style Subsubsection - Align Center - NextNoIndent 0 - TopSep 1.7 - BottomSep 1.1 + Align Center + NextNoIndent 0 + TopSep 1.7 + BottomSep 1.1 Font - Series Medium - Shape Italic - Size Normal + Series Medium + Shape Italic + Size Normal EndFont - TocLevel 3 + TocLevel 3 End Style Title - TopSep 2 - BottomSep 1.3 - Align Center - InTitle 0 + TopSep 2 + BottomSep 1.3 + Align Center + InTitle 0 Font - Series Bold - Size Large + Series Bold + Size Large EndFont End Style Author - Align Center - LabelType No_Label - InTitle 0 + Align Center + LabelType No_Label + InTitle 0 Font - Size Normal - Series Medium - Shape SmallCaps + Size Normal + Series Medium + Shape SmallCaps EndFont End Style Date - InTitle 0 - LabelSep "" - TopSep 1.2 - Align Center + InTitle 0 + LabelSep "" + TopSep 1.2 + Align Center Font - Size Small + Size Small EndFont End Style Abstract - LeftMargin "MMM" - RightMargin "MMM" - ParIndent "MM" - InTitle 0 - TopSep 1.4 - BottomSep 0.7 - LabelType Centered_Top_Environment - Align Block - AlignPossible Block, Left, Right, Center + LeftMargin "MMM" + RightMargin "MMM" + ParIndent "MM" + InTitle 0 + TopSep 1.4 + BottomSep 0.7 + LabelType Centered_Top_Environment + Align Block + AlignPossible Block, Left, Right, Center Font - Size Normal + Size Normal EndFont LabelFont - Series Bold - Size Normal + Series Bold + Size Normal EndFont End Style Affiliation - Margin Static - LatexType Command - LatexName affil - Category FrontMatter - ParSkip 0.4 - BottomSep 0.4 - Align Center - AlignPossible Block, Left, Right, Center - LabelType No_Label + Margin Static + LatexType Command + LatexName affil + Category FrontMatter + ParSkip 0.4 + BottomSep 0.4 + Align Center + AlignPossible Block, Left, Right, Center + LabelType No_Label Font - Family Roman - Size Normal + Family Roman + Size Normal EndFont End Style Altaffilation - Margin Dynamic - LatexType Command - LatexName altaffiltext - Category FrontMatter - ParSkip 0.4 - Align Block - LabelSep xx - LabelType Static - LabelString "Alternative affiliation:" + Margin Dynamic + LatexType Command + LatexName altaffiltext + Category FrontMatter + ParSkip 0.4 + Align Block + Argument 1 + Mandatory 1 + LabelString "Number" + Tooltip "Consecutive number for the alternative affiliations" + EndArgument + LabelSep xx + LabelType Static + LabelString "Alternative affiliation:" LabelFont - Color green + Color green EndFont End InsetLayout "Flex:altaffilmark" - LyxType custom - LatexType command - LatexName altaffilmark - LabelString "altaffiliation mark" + LyxType custom + LatexType command + LatexName altaffilmark + LabelString "altaffiliation mark" Font - Color foreground - Size Small - Family Roman - Shape Up - Series Medium - Misc No_Emph - Misc No_Noun - Misc No_Bar + Color foreground + Size Small + Family Roman + Shape Up + Series Medium + Misc No_Emph + Misc No_Noun + Misc No_Bar EndFont LabelFont - Color green - Size Small + Color green + Size Small EndFont End Style Keywords - LeftMargin MMM - Margin Dynamic - LatexType Command - InTitle 0 - LatexName keywords - Category FrontMatter - ParSkip 0.4 - BottomSep 0.4 - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep M - LabelString "Subject headings:" + LeftMargin MMM + Margin Dynamic + LatexType Command + InTitle 0 + LatexName keywords + Category FrontMatter + ParSkip 0.4 + BottomSep 0.4 + Align Block + AlignPossible Block, Left, Right, Center + LabelType Static + LabelSep M + LabelString "Subject headings:" Font - Family Roman - Shape Up - Size Normal + Family Roman + Shape Up + Size Normal EndFont LabelFont - Family Roman - Shape Italic - Size Normal + Family Roman + Shape Italic + Size Normal EndFont End Style Email - Margin Static - LatexType Command - InTitle 0 - LatexName email - Category FrontMatter - ParSkip 0.4 - BottomSep 0.4 - Align Center - AlignPossible Block, Left, Right, Center - LabelType No_Label + Margin Static + LatexType Command + InTitle 0 + LatexName email + Category FrontMatter + ParSkip 0.4 + BottomSep 0.4 + Align Center + AlignPossible Block, Left, Right, Center + LabelType No_Label Font - Family Roman - Size Normal - Shape Italic + Family Roman + Size Normal + Shape Italic EndFont End Style Acknowledgements - Margin Dynamic - LatexType Command - InTitle 0 - LatexName acknowledgements - TopSep 1.2 - ParSkip 0.4 - BottomSep 0.8 - Align Left - LabelType Static - LabelString "[Acknowledgements]" - KeepEmpty 1 + Margin Dynamic + LatexType Command + InTitle 0 + LatexName acknowledgements + TopSep 1.2 + ParSkip 0.4 + BottomSep 0.8 + Align Left + LabelType Static + LabelString "[Acknowledgements]" + KeepEmpty 1 Font - Family Roman - Size Normal - Shape Italic + Family Roman + Size Normal + Shape Italic EndFont End Style And - Margin Dynamic - LatexType Command - InTitle 0 - LatexName and - Category FrontMatter - TopSep 1.2 - ParSkip 0.4 - BottomSep 1.2 - Align Center - LabelType Static - LabelString "and" - KeepEmpty 1 + Margin Dynamic + LatexType Command + InTitle 0 + LatexName and + Category FrontMatter + TopSep 1.2 + ParSkip 0.4 + BottomSep 1.2 + Align Center + LabelType Static + LabelString "and" + KeepEmpty 1 Font - Family Roman - Size Normal + Family Roman + Size Normal EndFont End Style PlaceFigure - Margin Dynamic - LatexType Command - InTitle 0 - LatexName placefigure - TopSep 1.2 - ParSkip 0.4 - BottomSep 0.8 - Align Left - LabelType Static - LabelSep M - LabelString "Place Figure here:" + Margin Dynamic + LatexType Command + InTitle 0 + LatexName placefigure + TopSep 1.2 + ParSkip 0.4 + BottomSep 0.8 + Align Left + LabelType Static + LabelSep M + LabelString "Place Figure here:" Font - Family Roman - Size Normal - Shape Italic + Family Roman + Size Normal + Shape Italic EndFont End Style PlaceTable - Margin Dynamic - LatexType Command - InTitle 0 - LatexName placetable - TopSep 1.2 - ParSkip 0.4 - BottomSep 0.8 - Align Left - LabelType Static - LabelSep M - LabelString "Place Table here:" + Margin Dynamic + LatexType Command + InTitle 0 + LatexName placetable + TopSep 1.2 + ParSkip 0.4 + BottomSep 0.8 + Align Left + LabelType Static + LabelSep M + LabelString "Place Table here:" Font - Family Roman - Size Normal - Shape Italic + Family Roman + Size Normal + Shape Italic EndFont End Style Appendix - Margin Dynamic - LatexType Command - LatexName appendix - Category BackMatter - TopSep 1.2 - ParSkip 0.4 - BottomSep 0.8 - Align Left - LabelType Static - LabelString "[Appendix]" - KeepEmpty 1 + Margin Dynamic + LatexType Command + LatexName appendix + Category BackMatter + TopSep 1.2 + ParSkip 0.4 + BottomSep 0.8 + Align Left + LabelType Static + LabelString "[Appendix]" + KeepEmpty 1 Font - Family Roman - Size Normal - Shape Italic + Family Roman + Size Normal + Shape Italic EndFont End Style MathLetters - LatexType Environment - LatexName mathletters - LabelType No_Label - Align Block - AlignPossible Block, Left, Right, Center + LatexType Environment + LatexName mathletters + LabelType No_Label + Align Block + AlignPossible Block, Left, Right, Center Font - Size Normal + Size Normal EndFont End Style References - Margin First_Dynamic - LatexType Bib_Environment - LatexName thebibliography - Category BackMatter - NextNoIndent 1 - LeftMargin MM - ParSkip 0.4 - ItemSep 0 - TopSep 0.7 - BottomSep 0.7 - ParSep 0.5 - LabelType Bibliography - LabelString "References" - LabelBottomSep 0.7 - Align Block - AlignPossible Block, Left, Right, Center + Margin First_Dynamic + LatexType Bib_Environment + LatexName thebibliography + Category BackMatter + NextNoIndent 1 + LeftMargin MM + ParSkip 0.4 + ItemSep 0 + TopSep 0.7 + BottomSep 0.7 + ParSep 0.5 + LabelType Bibliography + LabelString "References" + LabelBottomSep 0.7 + Align Block + AlignPossible Block, Left, Right, Center LabelFont - Family Roman - Size Normal - Series Bold + Family Roman + Size Normal + Series Bold EndFont End @@ -511,203 +517,203 @@ End # Need reordering below here Style NoteToEditor - Margin Dynamic - LatexType Command - InTitle 0 - LatexName notetoeditor - TopSep 1.2 - ParSkip 0.4 - BottomSep 0.8 - Align Left - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep M - LabelString "Note to Editor:" + Margin Dynamic + LatexType Command + InTitle 0 + LatexName notetoeditor + TopSep 1.2 + ParSkip 0.4 + BottomSep 0.8 + Align Left + AlignPossible Block, Left, Right, Center + LabelType Static + LabelSep M + LabelString "Note to Editor:" Font - Family Roman - Size Normal - Shape Italic + Family Roman + Size Normal + Shape Italic EndFont End Style TableRefs - Margin First_Dynamic - LatexType Command - InTitle 0 - LatexName tablerefs - TopSep 1.2 - ParSkip 0.4 - BottomSep 0.8 - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep M - LabelString "References. ---" + Margin First_Dynamic + LatexType Command + InTitle 0 + LatexName tablerefs + TopSep 1.2 + ParSkip 0.4 + BottomSep 0.8 + Align Block + AlignPossible Block, Left, Right, Center + LabelType Static + LabelSep M + LabelString "References. ---" Font - Family Roman - Size Normal + Family Roman + Size Normal EndFont End Style TableComments - Margin First_Dynamic - LatexType Command - InTitle 0 - LatexName tablecomments - TopSep 1.2 - ParSkip 0.4 - BottomSep 0.8 - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep M - LabelString "Note. ---" + Margin First_Dynamic + LatexType Command + InTitle 0 + LatexName tablecomments + TopSep 1.2 + ParSkip 0.4 + BottomSep 0.8 + Align Block + AlignPossible Block, Left, Right, Center + LabelType Static + LabelSep M + LabelString "Note. ---" Font - Family Roman - Size Normal + Family Roman + Size Normal EndFont End Style "Table note" - Margin Dynamic - LatexType Command - LatexName tablenotetext - ParSkip 0.4 - Align Block - LabelSep xx - LabelType Static - LabelString "Table note:" + Margin Dynamic + LatexType Command + LatexName tablenotetext + ParSkip 0.4 + Align Block + LabelSep xx + LabelType Static + LabelString "Table note:" LabelFont - Color magenta + Color magenta EndFont End InsetLayout "Flex:tablenotemark" - LyxType custom - LatexType command - LatexName tablenotemark - LabelString "tablenote mark" + LyxType custom + LatexType command + LatexName tablenotemark + LabelString "tablenote mark" Font - Color foreground - Size Small - Family Roman - Shape Up - Series Medium - Misc No_Emph - Misc No_Noun - Misc No_Bar + Color foreground + Size Small + Family Roman + Shape Up + Series Medium + Misc No_Emph + Misc No_Noun + Misc No_Bar EndFont LabelFont - Color magenta - Size Small + Color magenta + Size Small EndFont End Style FigCaption - Margin First_Dynamic - LatexType Command - LatexName figcaption - LabelSep xx - ParSkip 0.4 - TopSep 0.5 - Align Block - AlignPossible Block, Left - LabelType Static - LabelString "Fig. ---" + Margin First_Dynamic + LatexType Command + LatexName figcaption + LabelSep xx + ParSkip 0.4 + TopSep 0.5 + Align Block + AlignPossible Block, Left + LabelType Static + LabelString "Fig. ---" Argument 1 - LabelString "Short Title|S" - Tooltip "The caption as it appears in the list of figures" + LabelString "Short Title|S" + Tooltip "The caption as it appears in the list of figures" EndArgument End # Facility style definition Style Facility - LeftMargin MMM - Margin Dynamic - LatexType Command - InTitle 0 - LatexName facility - ParSkip 0.4 - BottomSep 0.4 - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep M - LabelString "Facility:" + LeftMargin MMM + Margin Dynamic + LatexType Command + InTitle 0 + LatexName facility + ParSkip 0.4 + BottomSep 0.4 + Align Block + AlignPossible Block, Left, Right, Center + LabelType Static + LabelSep M + LabelString "Facility:" Font - Family Roman - Shape Up - Size Normal + Family Roman + Shape Up + Size Normal EndFont LabelFont - Family Roman - Shape Italic - Size Normal + Family Roman + Shape Italic + Size Normal EndFont End # Objectname style definition Style Objectname - LeftMargin MMM - Margin Dynamic - LatexType Command - InTitle 0 - LatexName objectname - ParSkip 0.4 - BottomSep 0.4 - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep M - LabelString "Obj:" + LeftMargin MMM + Margin Dynamic + LatexType Command + InTitle 0 + LatexName objectname + ParSkip 0.4 + BottomSep 0.4 + Align Block + AlignPossible Block, Left, Right, Center + LabelType Static + LabelSep M + LabelString "Obj:" Argument 1 - LabelString "Recognized Name" - Tooltip "Separate the recognized name of an object from text" + LabelString "Recognized Name" + Tooltip "Separate the recognized name of an object from text" EndArgument Font - Family Roman - Shape Up - Size Normal + Family Roman + Shape Up + Size Normal EndFont LabelFont - Family Roman - Shape Italic - Size Normal + Family Roman + Shape Italic + Size Normal EndFont End # Dataset style definition Style Dataset - LeftMargin MMM - Margin Dynamic - LatexType Command - InTitle 0 - LatexName dataset - ParSkip 0.4 - BottomSep 0.4 - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep M - LabelString "Dataset:" + LeftMargin MMM + Margin Dynamic + LatexType Command + InTitle 0 + LatexName dataset + ParSkip 0.4 + BottomSep 0.4 + Align Block + AlignPossible Block, Left, Right, Center + LabelType Static + LabelSep M + LabelString "Dataset:" Argument 1 - LabelString "Recognized Name" - Tooltip "Separate the dataset ID from text" + LabelString "Recognized Name" + Tooltip "Separate the dataset ID from text" EndArgument Font - Family Roman - Shape Up - Size Normal + Family Roman + Shape Up + Size Normal EndFont LabelFont - Family Roman - Shape Italic - Size Normal + Family Roman + Shape Italic + Size Normal EndFont End diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index 3fd1a84c32..cab19d82dd 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -1193,7 +1193,13 @@ def revert_Argument_to_TeX_brace(document, line, n, nmax, environment): def revert_IEEEtran(document): - " Reverts InsetArgument to old syntax " + ''' + Reverts InsetArgument of + Page headings + Biography + Biography without photo + to TeX-code + ''' i = 0 j = 0 k = 0 @@ -1246,7 +1252,8 @@ def convert_Argument_to_TeX_brace(document, line, n, nmax, environment): lineArg = find_token(document.body, "\\begin_inset ERT", lineArg) if environment == False and lineArg != -1: bracePair = find_token(document.body, "}{", lineArg) - if bracePair == lineArg + 5: # assure that the "}{" is in this ERT + # assure that the "}{" is in this ERT (5 is or files saved with LyX 2.0, 4 for files exported by LyX 2.1) + if bracePair == lineArg + 5 or bracePair == lineArg + 4: end = find_token(document.body, "\\end_inset", bracePair) document.body[lineArg : end + 1] = ["\\end_layout", "", "\\end_inset"] document.body[line + 1 : line + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] @@ -1255,13 +1262,13 @@ def convert_Argument_to_TeX_brace(document, line, n, nmax, environment): lineArg = lineArg + 1 if environment == True and lineArg != -1: opening = find_token(document.body, "{", lineArg) - if opening == lineArg + 5: # assure that the "{" is in this ERT + if opening == lineArg + 5 or opening == lineArg + 4: # assure that the "{" is in this ERT end = find_token(document.body, "\\end_inset", opening) document.body[lineArg : end + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] n = n + 1 lineArg2 = find_token(document.body, "\\begin_inset ERT", lineArg) closing = find_token(document.body, "}", lineArg2) - if closing == lineArg2 + 5: # assure that the "}" is in this ERT + if closing == lineArg2 + 5 or closing == lineArg2 + 4: # assure that the "}" is in this ERT end2 = find_token(document.body, "\\end_inset", closing) document.body[lineArg2 : end2 + 1] = ["\\end_layout", "", "\\end_inset"] else: @@ -1305,6 +1312,32 @@ def convert_IEEEtran(document): return +def revert_AASTeX(document): + " Reverts InsetArgument of Altaffilation to TeX-code " + i = 0 + while True: + if i != -1: + i = find_token(document.body, "\\begin_layout Altaffilation", i) + if i != -1: + revert_Argument_to_TeX_brace(document, i, 1, 1, False) + i = i + 1 + if i == -1: + return + + +def convert_AASTeX(document): + " Converts ERT of Altaffilation to InsetArgument " + i = 0 + while True: + if i != -1: + i = find_token(document.body, "\\begin_layout Altaffilation", i) + if i != -1: + convert_Argument_to_TeX_brace(document, i, 1, 1, False) + i = i + 1 + if i == -1: + return + + ## # Conversion hub # @@ -1344,11 +1377,11 @@ convert = [ [444, []], [445, []], [446, [convert_latexargs]], - [447, [convert_IEEEtran]] + [447, [convert_IEEEtran, convert_AASTeX]] ] revert = [ - [446, [revert_IEEEtran]], + [446, [revert_IEEEtran, revert_AASTeX]], [445, [revert_latexargs]], [444, [revert_uop]], [443, [revert_biolinum]], diff --git a/lib/templates/aastex.lyx b/lib/templates/aastex.lyx index 0e578fc695..2324d44263 100644 --- a/lib/templates/aastex.lyx +++ b/lib/templates/aastex.lyx @@ -1,5 +1,5 @@ -#LyX 2.0 created this file. For more info see http://www.lyx.org/ -\lyxformat 413 +#LyX 2.1 created this file. For more info see http://www.lyx.org/ +\lyxformat 447 \begin_document \begin_header \textclass aastex @@ -17,13 +17,13 @@ \font_roman default \font_sans default \font_typewriter default +\font_math auto \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 - \graphics default \default_output_format default \output_sync 0 @@ -34,15 +34,21 @@ \use_hyperref false \papersize default \use_geometry false -\use_amsmath 0 -\use_esint 0 -\use_mhchem 1 -\use_mathdots 1 -\cite_engine natbib_authoryear +\use_package amsmath 0 +\use_package amssymb 0 +\use_package esint 0 +\use_package mathdots 1 +\use_package mathtools 0 +\use_package mhchem 1 +\use_package undertilde 0 +\cite_engine natbib +\cite_engine_type authoryear +\biblio_style plainnat \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false +\justification true \use_refstyle 0 \index Index \shortcut idx @@ -132,13 +138,11 @@ status collapsed \end_layout \begin_layout Altaffilation -1 -\begin_inset ERT -status collapsed +\begin_inset Argument 1 +status open \begin_layout Plain Layout - -}{ +1 \end_layout \end_inset @@ -147,13 +151,11 @@ Visiting Astronomer, etc. \end_layout \begin_layout Altaffilation -2 -\begin_inset ERT -status collapsed +\begin_inset Argument 1 +status open \begin_layout Plain Layout - -}{ +2 \end_layout \end_inset @@ -162,13 +164,11 @@ Current Address, etc. \end_layout \begin_layout Altaffilation -3 -\begin_inset ERT -status collapsed +\begin_inset Argument 1 +status open \begin_layout Plain Layout - -}{ +3 \end_layout \end_inset -- 2.39.2