Skip to content

Field-based cross-references instead of hyperlinks in LaTeX2docx conversion #10663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jgm opened this issue Mar 4, 2025 · 0 comments
Open

Comments

@jgm
Copy link
Owner

jgm commented Mar 4, 2025

Discussed in #10660

Originally posted by JPZ4-5 March 4, 2025
When using LaTeX2docx conversion, how can we achieve field-based cross-references (for captions and text references) rather than hyperlinks? This is crucial for automatic numbering updates when merging DOCX documents.

Current Behavior:

  1. pandoc -o output.docx main.tex can convert \caption{XX} in the table and figure environments in LaTeX to captions in plain text, above tables or below figures. The \ref{} in the text can be converted to hyperlinks.
  2. pandoc -F pandoc-crossref -o output.docx main.tex can convert \caption{XX} in the table and figure environments in LaTeX to captions with numbering in plain text, above tables or below figures. The \ref{} in the text can be converted to hyperlinks.
  3. pandoc -F pandoc-tex-numbering -o output.docx main.tex can customize captions well, where Figure X-XX: XXXXX has Figure X-XX as a hyperlink and : XXXXX as plain text. The \ref in the text can be converted to hyperlinks. This is also the recommended latex2docx filter in the pandoc-crossref documentation.

Problem:
Haven't found any existing method produces Word field codes (like SEQ fields) for captions/references. Manual conversion (inserting caption fields + replacing hyperlinks with cross-reference fields) is prohibitively tedious.

Questions:

  1. Are there mature solutions for automatic field-based conversion?
  2. If not, is it better to:
    • Develop a custom Pandoc filter (preferred), or
    • Create VBA macros (undesirable due to lack of VBA expertise)?
    • record a macro in Word and execute it in a loop?

Recommendation

jgm: What we could perhaps do is add a specially marked Span around the generated numbers; this would be enough of a hook for the docx reader to substitute a field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant