Hello,
It's not possible to accomplish that task using the current version of addCrossReference. We move the request to the dev team to add support.
As the dev team sent to your email the latest version of addCrossReference that supports REF and ABOVE_BELOW, maybe you could add the following change to be able to set custom modifiers:
/**
* Adds a cross reference
*
* @access public
* @param string $text Text of the reference
* @param array $options
* Values:
* 'type' (bookmark, heading)
* 'modifiers' (string) custom modifiers: \r \h, \n \h...
* 'referenceName' (string) the name of the element to be referred
* 'referenceTo' (string) content to display when the field is updated PAGEREF (default), REF, ABOVE_BELOW
* For other options @see addText
*/
public function addCrossReference($text, $options = array())
{
if (!isset($options['type'])) {
$options['type'] = 'bookmark';
}
if (!isset($options['referenceTo'])) {
$options['referenceTo'] = 'PAGEREF';
}
$modifiers = ' \h';
if ($options['referenceTo'] == 'ABOVE_BELOW') {
$options['referenceTo'] = 'REF';
$modifiers = ' \p \h';
}
if (isset($options['modifiers'])) {
$modifiers = $options['modifiers'];
}
So you could set a custom modifier when adding a cross-reference:
$docx->addCrossReference('Custom text cross-reference', array('type' => 'bookmark', 'referenceName'=> 'bookmark_name', 'referenceTo' => 'REF', 'modifiers' => '\r \h'));
Maybe this small change is enough for your needs?
Regards.