diff --git a/lib/layouts/IEEEtran.layout b/lib/layouts/IEEEtran.layout index 0ce9fc6f0e..74ef6f0bd4 100644 --- a/lib/layouts/IEEEtran.layout +++ b/lib/layouts/IEEEtran.layout @@ -162,6 +162,11 @@ Style Page_headings Category FrontMatter InTitle 1 Align Center + Argument 1 + Mandatory 1 + LabelString "Left Side" + Tooltip "Left side of the header line" + EndArgument Font Size Small EndFont @@ -278,6 +283,11 @@ Style Biography LabelString "Photo" Tooltip "Optional photo for biography" EndArgument + Argument 2 + Mandatory 1 + LabelString "Name" + Tooltip "Name of the author" + EndArgument Align Block TextFont Size Small @@ -289,6 +299,11 @@ Style Biography_without_photo CopyStyle Biography LaTeXName IEEEbiographynophoto ResetArgs 1 + Argument 1 + Mandatory 1 + LabelString "Name" + Tooltip "Name of the author" + EndArgument End Style BiographyNoPhoto diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index f9b0266a6e..3fd1a84c32 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -1166,6 +1166,145 @@ def revert_latexargs(document): i = i + 1 +def revert_Argument_to_TeX_brace(document, line, n, nmax, environment): + ''' + Reverts an InsetArgument to TeX-code + usage: + revert_Argument_to_TeX_brace(document, LineOfBeginLayout, StartArgument, EndArgument, isEnvironment) + LineOfBeginLayout is the line of the \begin_layout statement + StartArgument is the number of the first argument that needs to be converted + EndArgument is the number of the last argument that needs to be converted or the last defined one + isEnvironment must be true, if the layout id for a LaTeX environment + ''' + lineArg = 0 + while lineArg != -1 and n < nmax + 1: + lineArg = find_token(document.body, "\\begin_inset Argument " + str(n), line) + if lineArg != -1: + beginPlain = find_token(document.body, "\\begin_layout Plain Layout", lineArg) + endLayout = find_token(document.body, "\\end_layout", beginPlain) + endInset = find_token(document.body, "\\end_inset", endLayout) + if environment == False: + document.body[endLayout : endInset + 1] = put_cmd_in_ert("}{") + del(document.body[lineArg : beginPlain + 1]) + else: + document.body[endLayout : endInset + 1] = put_cmd_in_ert("}") + document.body[lineArg : beginPlain + 1] = put_cmd_in_ert("{") + n = n + 1 + + +def revert_IEEEtran(document): + " Reverts InsetArgument to old syntax " + i = 0 + j = 0 + k = 0 + while True: + if i != -1: + i = find_token(document.body, "\\begin_layout Page headings", i) + if i != -1: + revert_Argument_to_TeX_brace(document, i, 1, 1, False) + i = i + 1 + if j != -1: + j = find_token(document.body, "\\begin_layout Biography without photo", j) + if j != -1: + revert_Argument_to_TeX_brace(document, j, 1, 1, True) + j = j + 1 + if k != -1: + k = find_token(document.body, "\\begin_layout Biography", k) + kA = find_token(document.body, "\\begin_layout Biography without photo", k) + if k == kA and k != -1: + k = k + 1 + continue + if k != -1: + # start with the second argument, therefore 2 + revert_Argument_to_TeX_brace(document, k, 2, 2, True) + k = k + 1 + if i == -1 and j == -1 and k == -1: + return + + +def convert_Argument_to_TeX_brace(document, line, n, nmax, environment): + ''' + Converts TeX code to an InsetArgument + !!! Be careful if the braces are different in your case as exppected here: + - }{ separates mandatory arguments of commands + - { and } surround a mandatory argument of an environment + usage: + convert_Argument_to_TeX_brace(document, LineOfBeginLayout, StartArgument, EndArgument, isEnvironment) + LineOfBeginLayout is the line of the \begin_layout statement + StartArgument is the number of the first ERT that needs to be converted + EndArgument is the number of the last ERT that needs to be converted + isEnvironment must be true, if the layout id for a LaTeX environment + + Notes: + - this routine will fail if the user has additional TeX-braces (there is nothing we can do) + - this routine can currently handle only one mandatory argument of environments + Todo: + - support the case that }{ is in the file in 2 separate ERTs + ''' + lineArg = line + while lineArg != -1 and n < nmax + 1: + 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 + 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"] + n = n + 1 + else: + 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 + 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 + end2 = find_token(document.body, "\\end_inset", closing) + document.body[lineArg2 : end2 + 1] = ["\\end_layout", "", "\\end_inset"] + else: + lineArg = lineArg + 1 + + +def convert_IEEEtran(document): + ''' + Converts ERT of + Page headings + Biography + Biography without photo + to InsetArgument + ''' + i = 0 + j = 0 + k = 0 + while True: + if i != -1: + i = find_token(document.body, "\\begin_layout Page headings", i) + if i != -1: + convert_Argument_to_TeX_brace(document, i, 1, 1, False) + i = i + 1 + if j != -1: + j = find_token(document.body, "\\begin_layout Biography without photo", j) + if j != -1: + convert_Argument_to_TeX_brace(document, j, 1, 1, True) + j = j + 1 + if k != -1: + # assure that we don't handle Biography Biography without photo + k = find_token(document.body, "\\begin_layout Biography", k) + kA = find_token(document.body, "\\begin_layout Biography without photo", k - 1) + if k == kA and k != -1: + k = k + 1 + continue + if k != -1: + # the argument we want to convert is the second one + convert_Argument_to_TeX_brace(document, k, 2, 2, True) + k = k + 1 + if i == -1 and j == -1 and k == -1: + return + + ## # Conversion hub # @@ -1204,10 +1343,12 @@ convert = [ [443, []], [444, []], [445, []], - [446, [convert_latexargs]] + [446, [convert_latexargs]], + [447, [convert_IEEEtran]] ] revert = [ + [446, [revert_IEEEtran]], [445, [revert_latexargs]], [444, [revert_uop]], [443, [revert_biolinum]], diff --git a/lib/templates/IEEEtran.lyx b/lib/templates/IEEEtran.lyx index 5040be9abe..c3948c1e6f 100644 --- a/lib/templates/IEEEtran.lyx +++ b/lib/templates/IEEEtran.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 IEEEtran @@ -20,13 +20,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 @@ -50,15 +50,21 @@ \pdf_quoted_options "pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false" \papersize default \use_geometry false -\use_amsmath 1 -\use_esint 0 -\use_mhchem 1 -\use_mathdots 1 +\use_package amsmath 1 +\use_package amssymb 1 +\use_package esint 0 +\use_package mathdots 1 +\use_package mathtools 0 +\use_package mhchem 1 +\use_package undertilde 0 \cite_engine basic +\cite_engine_type numerical +\biblio_style plain \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false +\justification true \use_refstyle 0 \index Index \shortcut idx @@ -304,13 +310,11 @@ optional \end_layout \begin_layout Page headings -Journal of XXX -\begin_inset ERT -status collapsed +\begin_inset Argument 1 +status open \begin_layout Plain Layout - -}{ +Journal of XXX \end_layout \end_inset @@ -467,7 +471,7 @@ Methodology \end_layout \begin_layout Theorem -\begin_inset Argument +\begin_inset Argument 1 status collapsed \begin_layout Plain Layout @@ -556,7 +560,7 @@ above \align center \begin_inset Tabular - + @@ -684,43 +688,10 @@ options "IEEEtran" \end_layout \begin_layout Biography -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -{ -\end_layout - -\end_inset - -Your Name -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -} -\end_layout - -\end_inset - - All about you and the what your interests are. -\begin_inset Argument +\begin_inset Argument 1 status open \begin_layout Plain Layout -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -{ -\end_layout - -\end_inset - - \begin_inset Graphics filename ../examples/CV-image.png width 1in @@ -731,22 +702,21 @@ status collapsed \end_inset -\begin_inset ERT -status collapsed +\end_layout + +\end_inset + + +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -} +Your Name \end_layout \end_inset - -\end_layout - -\end_inset - - + All about you and the what your interests are. \end_layout \begin_layout --Separator-- @@ -754,23 +724,11 @@ status collapsed \end_layout \begin_layout Biography without photo -\begin_inset ERT -status collapsed +\begin_inset Argument 1 +status open \begin_layout Plain Layout - -{ -\end_layout - -\end_inset - Coauthor -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -} \end_layout \end_inset diff --git a/src/version.h b/src/version.h index a305e9ce11..3febd57b16 100644 --- a/src/version.h +++ b/src/version.h @@ -30,8 +30,8 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 446 // spitz: InsetArgument revision -#define LYX_FORMAT_TEX2LYX 446 // landroni: InsetArgument revision +#define LYX_FORMAT_LYX 447 // uwestoehr: IEEEtran layout revision +#define LYX_FORMAT_TEX2LYX 447 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER