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
#
[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]],
-#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
\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
\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
\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
\end_layout
\begin_layout Theorem
-\begin_inset Argument
+\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
-<features tabularvalignment="middle">
+<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<row>
\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
\end_inset
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-}
\end_layout
\end_inset
+\begin_inset Argument 2
+status open
+
+\begin_layout Plain Layout
+Your Name
\end_layout
\end_inset
-
+ All about you and the what your interests are.
\end_layout
\begin_layout --Separator--
\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