<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns:Table="http://iso.org/pdf/ssn/Table" xmlns:pdf2="http://iso.org/pdf2/ssn" xmlns:Layout="http://iso.org/pdf/ssn/Layout" xmlns:pdf1="http://iso.org/pdf/ssn" xmlns:latexSE="https://www.latex-project.org/ns/dflt" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns="http://relaxng.org/ns/structure/1.0">
  <include href="document-pdf-ua2.rng">
    <define name="Document">
      <element name="pdf2:Document">
        <ref name="pdf2-attributes"/>
        <ref name="latex.document.content"/>
      </element>
    </define>
    <define name="Sect.content">
      <choice>
        <ref name="semantic-para"/>
        <ref name="theorem-like"/>
        <ref name="itemize"/>
        <ref name="enumerate"/>
        <ref name="description"/>
        <ref name="list"/>
        <ref name="footnote"/>
        <ref name="ltxtoc"/>
        <ref name="ltxtable"/>
        <ref name="ltxfigure"/>
      </choice>
    </define>
    <define name="sechead.content">
      <zeroOrMore>
        <choice>
          <ref name="heading-fragment"/>
          <ref name="heading-parbox"/>
          <ref name="latex.inline.content"/>
          <ref name="text-block"/>
        </choice>
      </zeroOrMore>
    </define>
  </include>
  <define name="pdf2rolemap-Title">
    <a:documentation>end of over-ride of ua2 schema</a:documentation>
    <attribute name="rolemaps-to">
      <value>Title</value>
    </attribute>
  </define>
  <define name="latex.document.content">
    <a:documentation>share UA-2 and UA-1 from here</a:documentation>
    <interleave>
      <zeroOrMore>
        <ref name="ltxartifact"/>
      </zeroOrMore>
      <choice>
        <interleave>
          <optional>
            <ref name="title-block"/>
          </optional>
          <group>
            <zeroOrMore>
              <choice>
                <ref name="section1"/>
                <ref name="Sect.content"/>
                <ref name="ltxsect"/>
                <ref name="footnote"/>
                <ref name="ltxlink"/>
                <ref name="float"/>
                <ref name="ltxaside"/>
                <ref name="ltxdiv"/>
                <ref name="ltxp"/>
              </choice>
            </zeroOrMore>
            <zeroOrMore>
              <ref name="chapter1"/>
            </zeroOrMore>
            <zeroOrMore>
              <ref name="part"/>
            </zeroOrMore>
            <interleave>
              <optional>
                <ref name="figures"/>
              </optional>
              <optional>
                <ref name="tables"/>
              </optional>
            </interleave>
          </group>
        </interleave>
        <interleave>
          <optional>
            <ref name="title1-block"/>
          </optional>
          <group>
            <zeroOrMore>
              <choice>
                <ref name="section2"/>
                <ref name="Sect.content"/>
                <ref name="ltxsect"/>
                <ref name="footnote"/>
                <ref name="ltxlink"/>
                <ref name="float"/>
                <ref name="ltxaside"/>
                <ref name="ltxdiv"/>
                <ref name="ltxp"/>
              </choice>
            </zeroOrMore>
            <zeroOrMore>
              <ref name="chapter2"/>
            </zeroOrMore>
            <zeroOrMore>
              <ref name="part"/>
            </zeroOrMore>
            <interleave>
              <optional>
                <ref name="figures"/>
              </optional>
              <optional>
                <ref name="tables"/>
              </optional>
            </interleave>
          </group>
        </interleave>
      </choice>
    </interleave>
  </define>
  <define name="title-block">
    <a:documentation>section heirarchy</a:documentation>
    <element name="latexSE:title-block">
      <attribute name="rolemaps-to">
        <value>Div</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <oneOrMore>
          <ref name="title-text"/>
        </oneOrMore>
        <zeroOrMore>
          <ref name="text-block"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="semantic-para"/>
        </zeroOrMore>
        <zeroOrMore>
          <choice>
            <ref name="title-author"/>
            <ref name="title-date"/>
          </choice>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="title1-block">
    <element name="latexSE:title-block">
      <attribute name="rolemaps-to">
        <value>Div</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <oneOrMore>
          <ref name="title1-text"/>
        </oneOrMore>
        <zeroOrMore>
          <ref name="text-block"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="semantic-para"/>
        </zeroOrMore>
        <zeroOrMore>
          <choice>
            <ref name="title-author"/>
            <ref name="title-date"/>
          </choice>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="title-text">
    <element name="latexSE:title-text">
      <ref name="pdf2rolemap-Title"/>
      <ref name="pdf2-attributes"/>
      <ref name="sechead.content"/>
    </element>
  </define>
  <define name="title1-text">
    <element name="latexSE:title-text">
      <attribute name="rolemaps-to">
        <value>H1</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="sechead.content"/>
    </element>
  </define>
  <define name="title-author">
    <element name="latexSE:title-author">
      <attribute name="rolemaps-to">
        <value>P</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
          <ref name="ltxlink"/>
          <ref name="footnotemark"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="title-date">
    <element name="latexSE:title-date">
      <attribute name="rolemaps-to">
        <value>P</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <choice>
        <text/>
        <ref name="text-fragment"/>
        <ref name="footnotemark"/>
      </choice>
    </element>
  </define>
  <define name="part">
    <element name="latexSE:part">
      <attribute name="rolemaps-to">
        <value>Part</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="part-heading"/>
      <zeroOrMore>
        <choice>
          <ref name="chapter1"/>
          <ref name="chapter2"/>
          <ref name="section"/>
          <ref name="Sect.content"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="part-heading">
    <element name="latexSE:part-heading">
      <ref name="pdf2rolemap-Title"/>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="chapter1">
    <element name="latexSE:chapter">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="chapter-heading1"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="section"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="chapter-heading1">
    <element name="latexSE:chapter-heading">
      <attribute name="rolemaps-to">
        <value>H1</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="chapter2">
    <element name="latexSE:chapter">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="chapter-heading2"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="section"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="chapter-heading2">
    <element name="latexSE:chapter-heading">
      <attribute name="rolemaps-to">
        <value>H2</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="section1">
    <element name="latexSE:section">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="section-heading1"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subsection"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="section-heading1">
    <element name="latexSE:section-heading">
      <ref name="pdf2-attributes"/>
      <attribute name="rolemaps-to">
        <value>H1</value>
      </attribute>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="section2">
    <element name="latexSE:section">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="section-heading2"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subsection"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="section-heading2">
    <element name="latexSE:section-heading">
      <attribute name="rolemaps-to">
        <value>H2</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="section">
    <element name="latexSE:section">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="section-heading"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subsection"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="section-heading">
    <element name="latexSE:section-heading">
      <attribute name="rolemaps-to">
        <choice>
          <value>H1</value>
          <value>H2</value>
          <value>H3</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="subsection">
    <element name="latexSE:subsection">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="subsection-heading"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subsubsection"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="subsection-heading">
    <element name="latexSE:subsection-heading">
      <attribute name="rolemaps-to">
        <choice>
          <value>H2</value>
          <value>H3</value>
          <value>H4</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="subsubsection">
    <element name="latexSE:subsubsection">
      <ref name="pdf2-attributes"/>
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="subsubsection-heading"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="paragraph"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="subsubsection-heading">
    <element name="latexSE:subsubsection-heading">
      <attribute name="rolemaps-to">
        <choice>
          <value>H3</value>
          <value>H4</value>
          <value>H5</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="paragraph">
    <element name="latexSE:paragraph">
      <ref name="pdf2-attributes"/>
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="paragraph-heading"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="subparagraph"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="paragraph-heading">
    <element name="latexSE:paragraph-heading">
      <attribute name="rolemaps-to">
        <choice>
          <value>H4</value>
          <value>H5</value>
          <value>H6</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="subparagraph">
    <element name="latexSE:subparagraph">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="subparagraph-heading"/>
      <zeroOrMore>
        <ref name="Sect.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="subparagraph-heading">
    <element name="latexSE:subparagraph-heading">
      <attribute name="rolemaps-to">
        <choice>
          <value>H5</value>
          <value>H6</value>
          <value>H7</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <ref name="sechead.content"/>
      </interleave>
    </element>
  </define>
  <define name="heading-number">
    <element name="latexSE:heading-number">
      <attribute name="rolemaps-to">
        <choice>
          <value>Lbl</value>
          <value>Span</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="mathse"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="heading-fragment">
    <element name="latexSE:heading-fragment">
      <attribute name="rolemaps-to">
        <value>Span</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="heading-number"/>
        </optional>
        <zeroOrMore>
          <choice>
            <text/>
            <ref name="text-fragment"/>
          </choice>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="heading-parbox">
    <element>
      <choice>
        <name>latexSE:heading-parbox</name>
        <name>latexSE:heading-minipage</name>
      </choice>
      <attribute name="rolemaps-to">
        <value>Span</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
          <ref name="heading-fragment"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="latex.inline.content">
    <a:documentation>end of headings</a:documentation>
    <a:documentation>paragraphs</a:documentation>
    <choice>
      <text/>
      <ref name="text-fragment"/>
      <ref name="footnotemark"/>
      <ref name="footnote"/>
      <ref name="ltxcode"/>
      <ref name="ltxsub"/>
      <ref name="ltxlbl"/>
      <ref name="ltxem"/>
      <ref name="ltxstrong"/>
      <ref name="ltxspan"/>
      <ref name="ltxlink"/>
      <ref name="ltxreference"/>
      <ref name="ltxannot"/>
      <ref name="ltxform"/>
      <ref name="ltxruby"/>
      <ref name="ltxwarichu"/>
      <ref name="ltxfenote"/>
      <ref name="ltxbibentry"/>
      <ref name="ltxfigure"/>
      <ref name="ltxformula"/>
      <ref name="ltxform"/>
      <ref name="ltxannot"/>
      <ref name="ltxartifact"/>
    </choice>
  </define>
  <define name="semantic-para">
    <element name="latexSE:semantic-para">
      <attribute name="rolemaps-to">
        <value>Part</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <optional>
        <choice>
          <ref name="ltxtitle"/>
          <ref name="title-text"/>
        </choice>
      </optional>
      <optional>
        <ref name="ltxcaption"/>
      </optional>
      <zeroOrMore>
        <choice>
          <ref name="text-block"/>
          <ref name="text-minipage"/>
          <ref name="quotation"/>
          <ref name="enumerate"/>
          <ref name="itemize"/>
          <ref name="description"/>
          <ref name="list"/>
          <ref name="verbatim"/>
          <ref name="quote"/>
          <ref name="ltxformula"/>
          <ref name="ltxtable"/>
          <ref name="ltxaside"/>
          <ref name="ltxdiv"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="text-block">
    <element name="latexSE:text-block">
      <attribute name="rolemaps-to">
        <value>P</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <zeroOrMore>
          <ref name="ltxlbl"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="latex.inline.content"/>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="text-fragment">
    <element name="latexSE:text-fragment">
      <attribute name="rolemaps-to">
        <value>Span</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="figures">
    <a:documentation>Floats</a:documentation>
    <element name="latexSE:figures">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <optional>
        <attribute name="id"/>
      </optional>
      <ref name="showtags-attributes"/>
      <zeroOrMore>
        <ref name="float"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="tables">
    <element name="latexSE:tables">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <optional>
        <attribute name="id"/>
      </optional>
      <ref name="showtags-attributes"/>
      <zeroOrMore>
        <ref name="float"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="float">
    <element name="latexSE:float">
      <attribute name="rolemaps-to">
        <choice>
          <value>Aside</value>
          <value>Note</value>
        </choice>
      </attribute>
      <optional>
        <attribute name="id"/>
      </optional>
      <ref name="showtags-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="ltxcaption"/>
          <ref name="semantic-para"/>
          <ref name="ltxfigure"/>
          <ref name="text-fragment"/>
          <ref name="text-block"/>
          <ref name="ltxformula"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="verbatim">
    <a:documentation>blocks</a:documentation>
    <element name="latexSE:verbatim">
      <attribute name="rolemaps-to">
        <choice>
          <value>P</value>
          <value>Code</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="ltxcaption"/>
        </optional>
        <zeroOrMore>
          <ref name="codeline"/>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="codeline">
    <element name="latexSE:codeline">
      <attribute name="rolemaps-to">
        <choice>
          <value>Sub</value>
          <value>Span</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="ltxem"/>
          <ref name="ltxstrong"/>
          <ref name="ltxspan"/>
          <ref name="ltxformula"/>
          <ref name="ltxlbl"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="list">
    <element name="latexSE:list">
      <attribute name="rolemaps-to">
        <value>L</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="list-attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="item"/>
          <ref name="ltxli"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="itemize">
    <element name="latexSE:itemize">
      <attribute name="rolemaps-to">
        <value>L</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="list-attributes"/>
      <zeroOrMore>
        <ref name="item"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="enumerate">
    <element name="latexSE:enumerate">
      <attribute name="rolemaps-to">
        <value>L</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="list-attributes"/>
      <zeroOrMore>
        <ref name="item"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="quote">
    <element name="latexSE:quote">
      <attribute name="rolemaps-to">
        <value>BlockQuote</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="semantic-para"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="quotation">
    <element name="latexSE:quotation">
      <attribute name="rolemaps-to">
        <value>BlockQuote</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="semantic-para"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="description">
    <element name="latexSE:description">
      <attribute name="rolemaps-to">
        <value>L</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="list-attributes"/>
      <zeroOrMore>
        <ref name="item"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="item">
    <element name="latexSE:item">
      <ref name="pdf2-attributes"/>
      <attribute name="rolemaps-to">
        <value>LI</value>
      </attribute>
      <group>
        <optional>
          <ref name="itemlabel"/>
        </optional>
        <optional>
          <ref name="itembody"/>
        </optional>
      </group>
    </element>
  </define>
  <define name="ltxli">
    <element name="pdf2:LI">
      <ref name="pdf2-attributes"/>
      <group>
        <optional>
          <ref name="ltxlbl"/>
        </optional>
        <optional>
          <ref name="ltxlbody"/>
        </optional>
      </group>
    </element>
  </define>
  <define name="itemlabel">
    <element name="latexSE:itemlabel">
      <ref name="pdf2-attributes"/>
      <attribute name="rolemaps-to">
        <value>Lbl</value>
      </attribute>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="itembody">
    <element name="latexSE:itembody">
      <ref name="pdf2-attributes"/>
      <attribute name="rolemaps-to">
        <value>LBody</value>
      </attribute>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-block"/>
          <ref name="semantic-para"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxlbody">
    <element name="pdf2:LBody">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-block"/>
          <ref name="semantic-para"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="theorem-like">
    <element name="latexSE:theorem-like">
      <attribute name="rolemaps-to">
        <value>Sect</value>
      </attribute>
      <optional>
        <attribute name="id"/>
      </optional>
      <ref name="showtags-attributes"/>
      <optional>
        <ref name="ltxcaption"/>
      </optional>
      <optional>
        <ref name="ltxlbl"/>
      </optional>
      <zeroOrMore>
        <ref name="semantic-para"/>
      </zeroOrMore>
    </element>
  </define>
  <!-- allow float for H (and ltx-talk) -->
  <define name="text-minipage">
    <element>
      <choice>
        <name>latexSE:text-minipage</name>
        <name>latexSE:text-parbox</name>
      </choice>
      <attribute name="rolemaps-to">
        <value>Div</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="semantic-para"/>
          <ref name="ltxformula"/>
          <ref name="float"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="footnotemark">
    <element name="latexSE:footnotemark">
      <attribute name="rolemaps-to">
        <value>Lbl</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="footnote">
    <element name="latexSE:footnote">
      <attribute name="rolemaps-to">
        <choice>
          <value>FENote</value>
          <value>Note</value>
        </choice>
      </attribute>
      <ref name="pdf2-attributes"/>
      <ref name="footnotelabel"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
          <ref name="semantic-para"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="footnotelabel">
    <element name="latexSE:footnotelabel">
      <attribute name="rolemaps-to">
        <value>Lbl</value>
      </attribute>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxlink">
    <a:documentation>still using pdf elements, redeclared here to constrain children back to latex-namespace</a:documentation>
    <element name="pdf2:Link">
      <ref name="pdf2-attributes"/>
      <choice>
        <zeroOrMore>
          <ref name="latex.inline.content"/>
        </zeroOrMore>
        <zeroOrMore>
          <choice>
            <ref name="ltxlbl"/>
            <ref name="text-fragment"/>
            <ref name="semantic-para"/>
            <ref name="ltxformula"/>
          </choice>
        </zeroOrMore>
      </choice>
    </element>
  </define>
  <define name="ltxreference">
    <element name="pdf1:Reference">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="ltxlbl"/>
          <ref name="text-fragment"/>
          <ref name="ltxlink"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxtoc">
    <element name="pdf1:TOC">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="ltxtoc"/>
          <ref name="ltxtoci"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxtoci">
    <element name="pdf1:TOCI">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="ltxlbl"/>
          <ref name="ltxreference"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxdiv">
    <element name="pdf2:Div">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="text-block"/>
          <ref name="semantic-para"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <!-- should be text-fragment? -->
  <define name="ltxspan">
    <element name="pdf2:Span">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxem">
    <element name="pdf2:Em">
      <ref name="pdf1rolemap-Span"/>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxstrong">
    <element name="pdf2:Strong">
      <ref name="pdf1rolemap-Span"/>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxlbl">
    <element name="pdf2:Lbl">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxsub">
    <element name="pdf2:Sub">
      <ref name="pdf1rolemap-Any"/>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxcode">
    <element name="pdf1:Code">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <text/>
      </zeroOrMore>
    </element>
  </define>
  <!-- expanded pdf2-attributes to avoid so much backtracking -->
  <define name="ltxformula">
    <a:documentation>formula</a:documentation>
    <element name="pdf2:Formula">
      <zeroOrMore>
        <ref name="AssociatedFiletext"/>
      </zeroOrMore>
      <ref name="formula-requirements"/>
      <zeroOrMore>
        <ref name="AssociatedFiletext"/>
      </zeroOrMore>
      <group>
        <optional>
          <attribute name="lang"/>
        </optional>
        <optional>
          <!-- Lang -->
          <attribute name="expansion"/>
        </optional>
        <optional>
          <!-- E -->
          <attribute name="title"/>
        </optional>
        <optional>
          <!-- T -->
          <attribute name="id"/>
        </optional>
        <optional>
          <!-- ID -->
          <attribute name="phoneme"/>
        </optional>
        <optional>
          <!-- Phoneme -->
          <attribute name="phonetic-alphabet"/>
        </optional>
        <optional>
          <!-- PhoneticAlphabet -->
          <attribute name="revision"/>
        </optional>
        <!-- R -->
        <ref name="layout-attributes"/>
        <ref name="otherns-attributes"/>
        <optional>
          <attribute name="af"/>
        </optional>
        <optional>
          <attribute name="rolemapped-from"/>
        </optional>
        <optional>
          <attribute name="referenced-as"/>
        </optional>
        <optional>
          <attribute name="Layout:Width"/>
        </optional>
        <optional>
          <attribute name="Layout:Height"/>
        </optional>
        <zeroOrMore>
          <choice>
            <ref name="ltxlbl"/>
            <ref name="semantic-para"/>
            <ref name="ltxlink"/>
            <ref name="mathse"/>
            <text/>
            <ref name="ltxfigure"/>
          </choice>
        </zeroOrMore>
      </group>
    </element>
  </define>
  <define name="ltxtable">
    <element name="pdf2:Table">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:Width"/>
      </optional>
      <optional>
        <attribute name="Layout:Height"/>
      </optional>
      <ref name="table-attributes"/>
      <interleave>
        <zeroOrMore>
          <ref name="ltxtr"/>
        </zeroOrMore>
        <group>
          <optional>
            <ref name="THead"/>
          </optional>
          <zeroOrMore>
            <ref name="TBody"/>
          </zeroOrMore>
          <optional>
            <ref name="TFoot"/>
          </optional>
        </group>
        <optional>
          <ref name="ltxcaption"/>
        </optional>
        <zeroOrMore>
          <ref name="ltxartifact"/>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="ltxtr">
    <element name="pdf2:TR">
      <ref name="pdf2-attributes"/>
      <ref name="table-attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="ltxth"/>
          <ref name="ltxdt"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxth">
    <element name="pdf2:TH">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:Width"/>
      </optional>
      <optional>
        <attribute name="Layout:Height"/>
      </optional>
      <optional>
        <attribute name="Layout:BlockAlign">
          <choice>
            <value>Before</value>
            <value>Middle</value>
            <value>After</value>
            <value>Justify</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Layout:InlineAlign">
          <choice>
            <value>Start</value>
            <value>Center</value>
            <value>End</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Layout:TBorderStyle"/>
      </optional>
      <optional>
        <attribute name="Layout:TPadding"/>
      </optional>
      <!---->
      <ref name="table-attributes"/>
      <optional>
        <attribute name="Table:Scope">
          <choice>
            <value>Column</value>
            <value>Row</value>
            <value>Both</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Table:Short"/>
      </optional>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <choice>
          <ref name="semantic-para"/>
          <ref name="ltxdiv"/>
          <ref name="verbatim"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxdt">
    <element name="pdf2:TD">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:Width"/>
      </optional>
      <optional>
        <attribute name="Layout:Height"/>
      </optional>
      <optional>
        <attribute name="Layout:BlockAlign">
          <choice>
            <value>Before</value>
            <value>Middle</value>
            <value>After</value>
            <value>Justify</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Layout:InlineAlign">
          <choice>
            <value>Start</value>
            <value>Center</value>
            <value>End</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Layout:TBorderStyle"/>
      </optional>
      <optional>
        <attribute name="Layout:TPadding"/>
      </optional>
      <!---->
      <ref name="table-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <choice>
          <ref name="semantic-para"/>
          <ref name="ltxdiv"/>
          <ref name="verbatim"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxaside">
    <element name="pdf2:Aside">
      <ref name="pdf1rolemap-Any"/>
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="semantic-para"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxruby">
    <element name="pdf2:Ruby">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:RubyAlign">
          <choice>
            <value>Start</value>
            <value>Center</value>
            <value>End</value>
            <value>Justify</value>
            <value>Distribute</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Layout:RubyPosition">
          <choice>
            <value>Before</value>
            <value>After</value>
            <value>Warichu</value>
            <value>Inline</value>
          </choice>
        </attribute>
      </optional>
      <interleave>
        <zeroOrMore>
          <text/>
        </zeroOrMore>
        <group>
          <ref name="ltxrb"/>
          <choice>
            <ref name="ltxrt"/>
            <group>
              <ref name="ltxrb"/>
              <ref name="ltxrt"/>
              <ref name="ltxrp"/>
            </group>
          </choice>
        </group>
      </interleave>
    </element>
  </define>
  <define name="ltxrb">
    <element name="pdf2:RB">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:RubyAlign">
          <choice>
            <value>Start</value>
            <value>Center</value>
            <value>End</value>
            <value>Justify</value>
            <value>Distribute</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Layout:RubyPosition">
          <choice>
            <value>Before</value>
            <value>After</value>
            <value>Warichu</value>
            <value>Inline</value>
          </choice>
        </attribute>
      </optional>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxrt">
    <element name="pdf2:RT">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:RubyAlign">
          <choice>
            <value>Start</value>
            <value>Center</value>
            <value>End</value>
            <value>Justify</value>
            <value>Distribute</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="Layout:RubyPosition"/>
      </optional>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxrp">
    <element name="pdf2:RP">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:RubyAlign"/>
      </optional>
      <optional>
        <attribute name="Layout:RubyPosition"/>
      </optional>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxwarichu">
    <element name="pdf2:Warichu">
      <ref name="pdf2-attributes"/>
      <interleave>
        <zeroOrMore>
          <text/>
        </zeroOrMore>
        <group>
          <ref name="ltxwp"/>
          <ref name="ltxwt"/>
          <ref name="ltxwp"/>
        </group>
      </interleave>
    </element>
  </define>
  <define name="ltxwt">
    <element name="pdf2:WT">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxwp">
    <element name="pdf2:WP">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxsect">
    <element name="pdf2:Sect">
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="ltxcaption"/>
        </optional>
        <zeroOrMore>
          <choice>
            <text/>
            <ref name="text-fragment"/>
            <ref name="text-block"/>
            <ref name="semantic-para"/>
          </choice>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="ltxartifact">
    <element name="pdf2:Artifact">
      <ref name="pdf1rolemap-Any"/>
      <ref name="pdf2-attributes"/>
      <ref name="artifact-attributes"/>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="text-fragment"/>
          <ref name="semantic-para"/>
          <ref name="ltxdiv"/>
          <ref name="ltxlink"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxcaption">
    <element name="pdf2:Caption">
      <ref name="pdf2-attributes"/>
      <interleave>
        <optional>
          <ref name="ltxlbl"/>
        </optional>
        <choice>
          <zeroOrMore>
            <choice>
              <ref name="semantic-para"/>
              <ref name="text-block"/>
            </choice>
          </zeroOrMore>
          <zeroOrMore>
            <ref name="latex.inline.content"/>
          </zeroOrMore>
        </choice>
      </interleave>
    </element>
  </define>
  <define name="ltxfigure">
    <element name="pdf2:Figure">
      <optional>
        <attribute name="lang"/>
      </optional>
      <optional>
        <!-- Lang -->
        <attribute name="expansion"/>
      </optional>
      <optional>
        <!-- E -->
        <attribute name="title"/>
      </optional>
      <optional>
        <!-- T -->
        <attribute name="id"/>
      </optional>
      <!-- ID -->
      <ref name="layout-attributes"/>
      <ref name="otherns-attributes"/>
      <ref name="showtags-attributes"/>
      <optional>
        <attribute name="Layout:Width"/>
      </optional>
      <optional>
        <attribute name="Layout:Height"/>
      </optional>
      <ref name="figure-attributes"/>
      <text/>
    </element>
  </define>
  <define name="ltxannot">
    <element name="pdf2:Annot">
      <ref name="pdf2-attributes"/>
      <choice>
        <zeroOrMore>
          <choice>
            <ref name="semantic-para"/>
            <ref name="ltxtable"/>
            <ref name="ltxfigure"/>
          </choice>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="latex.inline.content"/>
        </zeroOrMore>
      </choice>
    </element>
  </define>
  <define name="ltxform">
    <element name="pdf2:Form">
      <ref name="pdf2-attributes"/>
      <optional>
        <attribute name="Layout:Width"/>
      </optional>
      <optional>
        <attribute name="Layout:Height"/>
      </optional>
      <ref name="printfield-attributes"/>
      <interleave>
        <optional>
          <ref name="ltxcaption"/>
        </optional>
        <choice>
          <zeroOrMore>
            <choice>
              <ref name="semantic-para"/>
              <ref name="ltxtable"/>
              <ref name="ltxfigure"/>
            </choice>
          </zeroOrMore>
          <zeroOrMore>
            <ref name="latex.inline.content"/>
          </zeroOrMore>
        </choice>
      </interleave>
    </element>
  </define>
  <define name="ltxfenote">
    <element name="pdf2:FENote">
      <ref name="pdf1rolemap-Note"/>
      <ref name="pdf2-attributes"/>
      <ref name="fenote-attributes"/>
      <choice>
        <zeroOrMore>
          <choice>
            <ref name="semantic-para"/>
            <ref name="ltxtable"/>
            <ref name="ltxfigure"/>
          </choice>
        </zeroOrMore>
        <zeroOrMore>
          <choice>
            <text/>
            <ref name="text-fragment"/>
            <ref name="ltxlink"/>
            <ref name="ltxformula"/>
          </choice>
        </zeroOrMore>
      </choice>
    </element>
  </define>
  <define name="ltxbibentry">
    <element name="pdf2:BibEntry">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxtitle">
    <element name="pdf2:Title">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <choice>
          <ref name="latex.inline.content"/>
          <ref name="text-block"/>
          <ref name="semantic-para"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="ltxp">
    <element name="pdf2:P">
      <ref name="pdf2-attributes"/>
      <zeroOrMore>
        <ref name="latex.inline.content"/>
      </zeroOrMore>
    </element>
  </define>
</grammar>
