Forum


Replies: 1   Views: 148
Cross reference tables, images, heading and appendices
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by pwctechnicalsecurity  · 02-08-2019 - 07:15

I am looking for an example to cross reference tables, images, heading and appendices (and potentially Captions with a new label), but at first glance there does not seem to be a suitable example in the forum or the document. - Could be overlooking it though.

More specifically on what we are trying to achieve:

  • Cross reference a H1, H2, H3 (or appendices for that matter) so that you have a field that automatically adjusts
  • Create a Caption for (for instance) a table is, to my understanding, basically a combination of setting the right caption style and defining a field that sequentially adds +1 throughout the document. How do I achieve the latter?
  • How do I cross reference that particular field?
  • Is there a way to create such a thing for a new label, e.g. "Queries"
  • Is there a way to create an overview basically outlining on which page those queries, tables or figures can be found? Similar to the Insert Table of Figures functionality in Word (Reference -> Insert Table of Figures).

Thanks for your support, we just obtained the premium license and the library seems to work well :-)

 

Posted by admin  · 02-08-2019 - 10:31

Hello,

phpdocx allows using cross-references with bookmarks and headings; headings are used creating a bookmark, so we recommend using bookmarks directly.

As bookmarks and cross-refences can be used as WordFragments you can apply them almost anywhere using the WordFragment methods: creating contents, replacing placeholders (https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml) and DOCXPath (https://www.phpdocx.com/documentation/introduction/docxpath).

phpdocx supports adding a caption to images, not to tables or other contents. We move the request to the dev team. If you want to generate them using raw WordML (addWordML), this kind of content is created using a w:fldSimple tag and a text string, in the CreateImageCaption.php file you can see how it's being generated for images.

About getting page numbers you can generate fields but they aren't automatically updated unless they are in headers and footers. This kind of fields may require being updated manually (for example pressing F9) or using a macro.

Adding a content such as a Table of figures is not supported yet, only TOC are supported. Using getDocxPathQueryInfo available in DOCXPath and custom XPath queries you could generate a list contents with links using the bookmark names (addLink), but it's not an easy task.

Regards.