Forum


Replies: 4   Views: 47
Formula inside table

Posted by admin  · 20-02-2025 - 07:03

Hello,

Please note that the trial package doesn't include technical support. Please purchase a license to get technical support, remove trial watermarks, use phpdocx on a production server, and get all available features (https://www.phpdocx.com/features).

Using the current stable version of phpdocx, to add math equations as block WordFragments, you need to add them in a paragraph. For example:

$docx = new CreateDocx();

$math = new WordFragment($docx);
$math->addMathEquation(
    '<m:oMathPara>
        <m:oMath><m:r><m:t>∪±∞=~×</m:t></m:r></m:oMath>
    </m:oMathPara>', 'omml'
);
$textMath = new WordFragment($docx);
$textMath->addText([$math]);

$valuesTable = array(
    array(
        $textMath,
    )
);
$docx->addTable($valuesTable);

$docx->createDocx('output');

The next stable release of phpdocx won't have this requirement and adding math equations as block WordFragments will be possible without using an extra paragraph WordFragment.

Regards.