Skip to content

Missing autoref labels #822

Description

@teepeemm

Hyperref has the convenient \autoref command, so that instead of Section \ref{mylabel}, I can type \autoref{mylabel}, and the entire text becomes a link, instead of the individual number. Using the attached tex file, it seems that:

  • LaTeXML autorefs correctly for chapters, figures, tables, and theorems
  • LaTeXML doesn't autoref for sections, subsections, equations, items, and footnotes
  • LaTeXML doesn't autoref for anything produced by \captionof (although the Info suggests that we shouldn't expect it to work)
  • LaTeXML and LaTeX don't autoref for subsubsections (we've passed secnumdepth?)
  • LaTeXML would autoref correctly for parts, but when I include parts, my xml has \xA0 characters sprinkled throughout the names, and latexmlpost refuses to run

For section and subsection (which I'm most interested in at the moment), having autoref work correctly appears to require an adjustment to \@startsection in LaTeX.pool.ltxml to include the correct frefnum (which would also make index entries display correctly). Failing that, a hack on the postprocessing end could be something like

  <xsl:template match="ltx:section[@refnum][not(@frefnum)]">
    <xsl:attribute name="frefnum">
      <xsl:text>Section </xsl:text>
      <xsl:value-of select="@refnum" />
    </xsl:attribute>
    <xsl:apply-templates/>
  </xsl:template>

but this crashes with the fatal error Cannot add attributes to an element if children have been already added to the element. (I also don't know xslt well enough to know if that's remotely correct.)

Would we be able to make autoref work for more of these options?
autoref.tex.zip

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions