Add in text cross references to figures, sections, and tables using the Report Genorator toolbox.

2 ビュー (過去 30 日間)
Alec Bowman
Alec Bowman 2022 年 6 月 2 日
編集済み: Joris 2023 年 9 月 3 日
I am using Report Generator to translate a spreadsheet into a complete word document with sections, text, tables, figures, etc. I want cross reference figures, tables, and section numbers in the body of the text. Something like "see Figure 1.1 for more detail". I want to reference the figure (or table or section) number as it falls in the report.
  1 件のコメント
Joris
Joris 2023 年 9 月 3 日
I figured something out, though I would have liked the normal Xref documentation as Rahul Singhal pointed out to have covered this.
So to be clear, the normal Xref documentation works to get a cross reference, but with the title instead of the (in my experience common) type and number reference, e.g. Figure 5.6 / Table 4.
The solution I found still uses Xref, but the inspiration came from 'Number Section Headings, Table Titles, and Figure Captions Programmatically' documentation. Number Section Headings, Table Titles, and Figure Captions.
I modified the getFigureCaption and getTableTitle functions shown in the above documentation. So instead of using the Dom functions to caption figures (linkTarget on fig.Snapshot.Caption) and tables (linkTarget on BaseTable('Title', ...) I build my own paragraph with my own counters and set linkTarget to the Figure M.N portion / Table M.N of my captions. A bit of work but it does work out.

サインインしてコメントする。

回答 (1 件)

Rahul Singhal
Rahul Singhal 2022 年 6 月 3 日
Hi Alec,
Please see mlreportgen.dom.XRef for creating such cross-references in DOCX reports.
Thanks,
Rahul
  2 件のコメント
Alec Bowman
Alec Bowman 2022 年 6 月 6 日
I had tried this, but I don't know of a way to access the figure number through this. Unless I manually enter the number (or any text) it won't populate. What I'm looking for is something along the lines of mlreportgen.dom.PageNumber where the page number is populated based on the linked item's page. Using XRef, the only way I've found to include the figure number is if I'm manually creating the figure numbers.
Joris
Joris 2023 年 9 月 1 日
編集済み: Joris 2023 年 9 月 3 日
Same question here as Alec, the XRef documentation does not show if or how it is possible to reference the number of the figure (or table).
edit: I found a solution, posted as reply to original post

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by