On Friday 04 June 2010 23:32:40 Richard Heck wrote:
> Thoughts?
> 
> Richard

I agree with your analysis.

It would possible for us to have the user configuring from its personal .lyx 
directory lyx2lyx to bypass some conversion filters. It is not difficult and I 
am not suggesting it for this case I am just saying that it could be done 
easily.

On the same vein as your work and since I dislike the latex output of lyx-
beamer I have a workaround in the form of a python script and another layout.

This work is incomplete in the sense that only supports normal frames (no 
plain or otherwise) but it allows me to share the latex output with my 
colleagues that only use plain latex. (for any definition of plain that I will 
ignore due to the respect to the readers :-) )

-- 
José Abílio
import sys

end_frame="""\\end_deeper

\\begin_layout Separator

\\end_layout
"""

begin_frame="""\\begin_layout BeginFrame

\\end_layout
\\begin_deeper

"""

titlepage=r"""\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
titlepage
\end_layout

\end_inset


\end_layout
"""

def clean(lyx_file):
    # find textclass
    for line in lyx_file:
        # strip endline char
        line = line[:-1]

        if line.startswith("\\textclass"):
            print("\\textclass beamer-clean")
            break
        else:
            print line

    # goto the document body
    for line in lyx_file:
        # strip endline char
        line = line[:-1]

        print line
        if line.startswith("\\begin_body"):
            break

    # scan document body
    print (begin_frame)
    frame_closed = False
    first_frame = True

    for line in lyx_file:
        # strip endline char
        line = line[:-1]

        if line.startswith("\\begin_layout"):
            layout = line[len("\\begin_layout "):]
            if layout in ("BeginFrame", "Section", "SubSection", "Section*", "Subsection*"):
                if first_frame:
                    print (titlepage)
                    first_frame = False

                if not frame_closed:
                    print(end_frame)
                    frame_closed = True

            if layout == "BeginFrame":
                frame_closed = False
                print (begin_frame)
                line = "\\begin_layout FrameTitle"

            if layout == "EndFrame":
                if first_frame:
                    print (titlepage)
                    first_frame = False
                frame_closed = True
                print ("\\end_deeper")
                print ("")
                line = "\\begin_layout Separator"

#            if layout == "Title":
#                line = "\\begin_layout FrameTitle"

        if line.startswith("\\end_body"):
            if not frame_closed:
                print(end_frame)

        print(line)


def main():
    if len(sys.argv) < 2:
        lyx_file = sys.stdin
    else:
        lyx_file = open(sys.argv[1])

    clean(lyx_file)


if __name__ == "__main__":
    main()
#% Do not delete the line below; configure depends on this
#  \DeclareLaTeXClass[beamer,pgf.sty,xcolor.sty]{presentation (beamer, clean 
lattex code)}

Format 11
Input beamer

# Section style _re_definition
Style Section
  LatexName        section
End

# Section* style _re_definition
Style Section*
  LatexName        section*
End

# Subsection style _re_definition
Style Subsection
  LatexName        subsection
End

# Subsection* style _re_definition
Style Subsection*
  LatexName        subsection*
End

Style FrameTitle
  CopyStyle BeginFrame
  LatexName        frametitle
  LabelString      ""
  Preamble
  EndPreamble
End

Style BeginFrame
  LatexName        frame
  LatexType        Environment
  Margin           Static
  Align            Center
  AlignPossible    Center
  LabelString      "______________________ Frame ______________________"
  Preamble
  EndPreamble
  Font
    Series         Medium
    Size           Normal
    Color          None
  EndFont

End

TitleLaTeXName titlepage

Preamble
EndPreamble

Reply via email to