Layout file format change proposal

Lorenzo Bertini lorenzobertini97 at gmail.com
Wed Mar 20 08:59:04 UTC 2024


Dear devs,
I don't know if this has been discussed before. Lyx uses it's own
format .layout (or .module), with it's own parser. However, the same
information can be easily saved stored in another format. I asked a
chatbot to convert "amsbook.layout" to an hypothetical "amsbook.yaml"
file:

format: 104
columns: 1
sides: 2
page_style: Headers
docbook_root: book
provides:
  - amsmath: 1
  - makeidx: 1
class_options:
  font_size: [8, 9, 10, 11, 12]
default_modules:
  - theorems-ams
  - eqs-within-sections
  - figs-within-sections
styles:
  Standard:
    category: MainText
    margin: Static
    latex_type: Paragraph
    latex_name: dummy
    par_indent: MM
    par_skip: 0.4
    align: Block
    align_possible: [Block, Left, Right, Center]
    label_type: No_Label
    docbook_tag: para
preamble: "\numberwithin{section}{chapter}"
inputs:
  - stdsections.inc
  - stdinsets.inc
  - numreport.inc
  - lyxmacros.inc
  - stdlayouts.inc
  - stdlists.inc
  - stdfloats.inc
  - stdcounters.inc
  - amsdefs.inc
unwanted_styles:
  - Verse
  - Bibliography:
      toc_level: 0
styles_append:
  Section:
    align: Center
    font:
      series: Bold
      size: Large
    toc_level: 1
  Subsection:
    font:
      series: Bold
      size: Normal
    toc_level: 2
  Subsubsection:
    font:
      shape: Italic
      size: Normal
    toc_level: 3
  Section*:
    align: Center
    font:
      series: Bold
      size: Large
  Subsection*:
    font:
      series: Bold
      size: Normal
  Subsubsection*:
    font:
      shape: Italic
      size: Normal
  Paragraph:
    font:
      series: Medium
    toc_level: 4
  Chapter_Exercises:
    margin: First_Dynamic
    latex_type: Item_Environment
    latex_name: lyxxcb
    next_no_indent: 1
    left_margin: MMN
    label_sep: xx
    par_skip: 0.0
    item_sep: 0.2
    top_sep: 0.7
    bottom_sep: 0.7
    par_sep: 0.3
    align: Block
    align_possible: [Block, Left]
    label_type: Itemize
    label_font:
      shape: Up
      series: Bold
    preamble: "\newenvironment{lyxxcb}..."
    argument_listpreamble:
      - label_string: "List preamble"
        menu_string: "List Preamble"
        tooltip: "LaTeX code to be inserted before the first item"
        pass_thru: 1
        font:
          family: typewriter
          color: latex
    docbook_tag: para
    docbook_attr: role='chapter-exercises'

I think it looks pretty good. The advantages of using an industry standard are:
1. People already know the format. This could encourage publishers to
provide layouts.
2. Existing and solid tools for parsing can be used. Even if not
directly by LyX, someone manipulating layouts externally doesn't need
to reinvent the wheel.

Let me know what you think.

Lorenzo


More information about the lyx-devel mailing list