Dodawanie równań matematycznych do prezentacji PowerPoint w C++
Przegląd
PowerPoint przechowuje równania jako Office Math Markup Language (OMML). Korzystając z Aspose.Slides dla C++, możesz programowo tworzyć tego samego rodzaju zawartość matematyczną: ułamki, pierwiastki, funkcje, granice, operatory N-arne, macierze, tablice i sformatowane bloki matematyczne.
W PowerPoint użytkownicy zazwyczaj dodają równania z Wstaw > Równanie:

Rezultatem jest edytowalny tekst matematyczny na slajdzie:

Aspose.Slides buduje ten tekst matematyczny za pomocą trzech głównych obiektów:
- Kształt matematyczny, utworzony przy pomocy AddMathShape, jest kształtem zawierającym równanie.
- MathPortion przechowuje treść matematyczną wewnątrz ramki tekstowej kształtu.
- MathParagraph zawiera jeden lub więcej obiektów MathBlock.
Większość przykładów poniżej używa MathematicalText oraz metod płynnych z IMathElement, aby kod był krótki i czytelny.
Scenariusze eksportu MathML znajdziesz w Export Math Equations from Presentations in C++.
Utwórz równanie
Ten przykład używa AddMathShape do utworzenia kształtu matematycznego i dodaje twierdzenie Pitagorasa:

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathBlock.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/IMathSuperscriptElement.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 120.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto equation = System::MakeObject<MathematicalText>(u"c")
- >SetSuperscript(u"2")
- >Join(u"=")
- >Join(System::MakeObject<MathematicalText>(u"a")->SetSuperscript(u"2"))
- >Join(u"+")
- >Join(System::MakeObject<MathematicalText>(u"b")->SetSuperscript(u"2"));
mathParagraph->Add(equation);
presentation->Save(u"pythagorean-theorem.pptx", SaveFormat::Pptx);
presentation->Dispose();
Note
AddMathShape tworzy kształt, który już zawiera akapit matematyczny. Uzyskaj dostęp do pierwszego MathPortion, wywołaj get_MathParagraph, i dodaj bloki lub elementy matematyczne.Dodaj ułamki
Użyj Divide do utworzenia ułamka. Możesz wybrać styl ułamka za pomocą MathFractionTypes.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathFractionTypes.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto fraction = System::MakeObject<MathematicalText>(u"1")
- >Divide(u"x", MathFractionTypes::Skewed);
mathParagraph->Add(System::MakeObject<MathBlock>(fraction));
presentation->Save(u"fraction.pptx", SaveFormat::Pptx);
presentation->Dispose();
Aby uzyskać ułamek ze stosunkiem pionowym, użyj MathFractionTypes::Bar:
#include <DOM/MathText/MathFractionTypes.h>
#include <DOM/MathText/MathematicalText.h>
using namespace Aspose::Slides::MathText;
auto stackedFraction = System::MakeObject<MathematicalText>(u"x + 1")->Divide(u"y - 1", MathFractionTypes::Bar);
Dodaj pierwiastki
Użyj Radical do utworzenia pierwiastka kwadratowego, sześciennego lub innego. Aktualny element staje się podstawą, a argument stopniem.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto radical = System::MakeObject<MathematicalText>(u"x")
- >Radical(u"n");
mathParagraph->Add(System::MakeObject<MathBlock>(radical));
presentation->Save(u"radical.pptx", SaveFormat::Pptx);
presentation->Dispose();
Pokaż lub ukryj stopień pierwiastka kwadratowego
Pierwiastek kwadratowy może wyświetlać wyraźne 2 lub używać konwencjonalnej notacji √x. Użyj IMathRadical::set_HideDegree aby przełączać między tymi formami. Obie zachowują stopień 2 i radicand x w edytowalnym równaniu.

Przykład zapisuje ten sam pierwiastek dwukrotnie. W visible-degree.pptx liczba 2 jest widoczna. W hidden-degree.pptx jest ukryta.
#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathRadical.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto radicand = System::MakeObject<MathematicalText>(u"x");
auto radical = radicand->Radical(u"2");
auto block = System::MakeObject<MathBlock>(radical);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 200.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
mathParagraph->Add(block);
radical->set_HideDegree(false);
presentation->Save(u"visible-degree.pptx", SaveFormat::Pptx);
radical->set_HideDegree(true);
presentation->Save(u"hidden-degree.pptx", SaveFormat::Pptx);
presentation->Dispose();
Dodaj funkcje i granice
Użyj AsArgumentOfFunction lub Function dla funkcji takich jak sin(x), log(x) lub własnych nazw funkcji. Dla granic umieść lim w MathLimit lub użyj SetLowerLimit.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathLimit.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto limit = System::MakeObject<MathematicalText>(u"lim")
- >SetLowerLimit(u"x→∞")
- >Function(u"x");
mathParagraph->Add(System::MakeObject<MathBlock>(limit));
presentation->Save(u"functions-and-limits.pptx", SaveFormat::Pptx);
presentation->Dispose();
Aby używać własnej nazwy funkcji, ustaw nazwę funkcji jako bieżący element i wywołaj Function z jej argumentem:
#include <DOM/MathText/MathematicalText.h>
using namespace Aspose::Slides::MathText;
auto customFunction = System::MakeObject<MathematicalText>(u"f")->Function(u"x + 1");
Dodaj operatory N-arne i całki
Użyj Nary dla sum, unii, przecięć i innych dużych operatorów. Użyj Integral dla całek. Obie metody pozwalają ustawić limity dolny i górny.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/IMathSuperscriptElement.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathNaryOperatorTypes.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 120.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto summationBase = System::MakeObject<MathematicalText>(u"x")
- >SetSuperscript(u"k")
- >Join(System::MakeObject<MathematicalText>(u"a")->SetSuperscript(u"n-k"));
auto summation = summationBase->Nary(MathNaryOperatorTypes::Summation, u"k=0", u"n");
mathParagraph->Add(System::MakeObject<MathBlock>(summation));
presentation->Save(u"nary-operators.pptx", SaveFormat::Pptx);
presentation->Dispose();
Operatory N-arne służą do dużych operatorów z opcjonalnymi limitami. Proste operatory takie jak +, - i = są zwykle dodawane jako MathematicalText i łączone w wyrażenie.
Dla całki użyj Integral:
#include <DOM/MathText/IMathBlock.h>
#include <DOM/MathText/IMathBox.h>
#include <DOM/MathText/IMathElement.h>
#include <DOM/MathText/MathIntegralTypes.h>
#include <DOM/MathText/MathematicalText.h>
using namespace Aspose::Slides::MathText;
auto integralBase = System::MakeObject<MathematicalText>(u"x")->Join(System::MakeObject<MathematicalText>(u"dx")->ToBox());
auto integral = integralBase->Integral(MathIntegralTypes::Simple, u"0", u"1");
Dodaj macierze
Użyj MathMatrix dla wierszy i kolumn. Macierze domyślnie nie zawierają nawiasów, więc otocz macierz, gdy potrzebujesz nawiasów okrągłych, kwadratowych lub klamrowych.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathBlock.h>
#include <DOM/MathText/IMathElement.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathMatrix.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 120.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto matrix = System::MakeObject<MathMatrix>(2, 3);
matrix->idx_set(0, 0, System::MakeObject<MathematicalText>(u"1"));
matrix->idx_set(0, 1, System::MakeObject<MathematicalText>(u"x"));
matrix->idx_set(1, 0, System::MakeObject<MathematicalText>(u"x"));
matrix->idx_set(1, 1, System::MakeObject<MathematicalText>(u"2"));
matrix->idx_set(1, 2, System::MakeObject<MathematicalText>(u"y"));
mathParagraph->Add(System::MakeObject<MathBlock>(matrix));
presentation->Save(u"matrix.pptx", SaveFormat::Pptx);
presentation->Dispose();
Dodaj tablice równań
Użyj ToMathArray kiedy potrzebujesz wyrównanych równań lub pionowego stosu wyrażeń.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 140.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto equationArray = System::MakeObject<MathematicalText>(u"x")
- >Join(u"y")
- >ToMathArray();
mathParagraph->Add(System::MakeObject<MathBlock>(equationArray));
presentation->Save(u"equation-array.pptx", SaveFormat::Pptx);
presentation->Dispose();
Wyrównaj tablicę z elementami otaczającymi
IMathArray::set_BaseJustification kontroluje pionowe wyrównanie tablicy względem elementów matematycznych obok niej. Poniższy przykład porównuje wyrównanie pierwszego wiersza, środka tablicy i ostatniego wiersza.
Poniższy przykład tworzy trzy identyczne tablice, każda z trzema wierszami i sąsiadującymi elementami A= oraz =B. Cały tekst matematyczny używa czcionki Cambria Math 24 pt. Zmienia się wyłącznie wyrównanie tablicy.
#include <system/array.h>
#include <system/console.h>
#include <drawing/color.h>
#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/IPortion.h>
#include <DOM/IPortionFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/Fonts/FontData.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathArray.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathJustification.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathVerticalAlignment.h>
#include <DOM/MathText/MathRowSpacingRule.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
#include <DOM/FillType.h>
#include <DOM/IColorFormat.h>
#include <DOM/IFillFormat.h>
#include <DOM/ILineFormat.h>
#include <DOM/ISlideSize.h>
#include <DOM/ITextFrameFormat.h>
#include <DOM/ShapeType.h>
#include <DOM/SlideSizeScaleType.h>
#include <DOM/TextAnchorType.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto createText = [](System::String value)
{
auto text = System::MakeObject<MathematicalText>(value);
text->get_Format()->set_FontHeight(24);
auto font = System::MakeObject<FontData>(u"Cambria Math");
text->get_Format()->set_LatinFont(font);
return text;
};
auto presentation = System::MakeObject<Presentation>();
presentation->get_SlideSize()->SetSize(780, 200, SlideSizeScaleType::DoNotScale);
auto slide = presentation->get_Slide(0);
MathVerticalAlignment alignments[] = {MathVerticalAlignment::Top, MathVerticalAlignment::Center, MathVerticalAlignment::Bottom};
System::String labels[] = {u"Top", u"Center", u"Bottom"};
for (auto i = 0; i < 3; i++)
{
auto label = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 20 + i * 260, 10, 240, 30);
label->get_FillFormat()->set_FillType(FillType::NoFill);
label->get_LineFormat()->get_FillFormat()->set_FillType(FillType::NoFill);
label->get_TextFrame()->set_Text(labels[i]);
auto labelFormat = label->get_TextFrame()->get_Paragraph(0)->get_Portion(0)->get_PortionFormat();
labelFormat->set_FontHeight(16);
labelFormat->get_FillFormat()->set_FillType(FillType::Solid);
labelFormat->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Black());
auto mathShape = slide->get_Shapes()->AddMathShape(20 + i * 260, 60, 240, 130);
mathShape->get_TextFrame()->get_TextFrameFormat()->set_AnchoringType(TextAnchorType::Top);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
mathParagraph->set_Justification(MathJustification::LeftJustified);
auto rows = System::MakeArray<System::SharedPtr<IMathElement>>({createText(u"x+y=3"), createText(u"x-y=1"), createText(u"x=2")});
auto equationArray = System::MakeObject<MathArray>(rows);
equationArray->set_BaseJustification(alignments[i]);
auto leftText = createText(u"A=");
auto rightText = createText(u"=B");
auto equation = System::MakeObject<MathBlock>(leftText)->Join(equationArray)->Join(rightText);
mathParagraph->Add(equation);
}
presentation->Save(u"equation-array-alignment.pptx", SaveFormat::Pptx);
presentation->Dispose();
Poniższe porównanie pokazuje zapisaną prezentację w PowerPoint. Zwróć uwagę na pozycję A= i =B obok każdej tablicy.

Skonfiguruj odstępy wierszy
set_RowSpacingRule wybiera regułę odstępu dla wierszy wewnątrz tablicy. set_RowSpacing podaje wartość liczbową dla wyraźnej reguły odstępu i jest ignorowane przy użyciu reguł wstępnych.
Dokładny odstęp mierzony jest w punktach. Odstęp proporcjonalny liczony jest w półwierszach: wartość 3 w przykładzie oznacza 1,5 wiersza. Wywołaj oba settery przy określaniu wartości liczbowej; zmiana samej wartości nie wybiera reguły odstępu.
Poniższy przykład zapisuje pięć prezentacji z tymi samymi równaniami, wyrównaniem i ustawieniami czcionki. Trzy pierwsze używają ustawień wstępnych; dwie ostatnie pokazują wartości wyraźne.
#include <system/array.h>
#include <system/console.h>
#include <drawing/color.h>
#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/IPortion.h>
#include <DOM/IPortionFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/Fonts/FontData.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathArray.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathJustification.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathVerticalAlignment.h>
#include <DOM/MathText/MathRowSpacingRule.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto createText = [](System::String value)
{
auto text = System::MakeObject<MathematicalText>(value);
text->get_Format()->set_FontHeight(24);
auto font = System::MakeObject<FontData>(u"Cambria Math");
text->get_Format()->set_LatinFont(font);
return text;
};
struct ArraySettings
{
MathRowSpacingRule rule;
uint32_t spacing;
System::String name;
};
ArraySettings settings[] =
{
{MathRowSpacingRule::SingleLineGap, 0, u"SingleLineGap"},
{MathRowSpacingRule::OneAndAHalfLineGap, 0, u"OneAndAHalfLineGap"},
{MathRowSpacingRule::TwoLineGap, 0, u"TwoLineGap"},
{MathRowSpacingRule::Exactly, 20, u"Exactly"},
{MathRowSpacingRule::Multiple, 3, u"Multiple"}
};
for (const auto& setting : settings)
{
auto fileName = u"equation-array-" + setting.name + u".pptx";
auto presentation = System::MakeObject<Presentation>();
auto mathShape = presentation->get_Slide(0)->get_Shapes()->AddMathShape(20, 20, 600, 300);
auto paragraph = mathShape->get_TextFrame()->get_Paragraph(0);
paragraph->get_ParagraphFormat()->set_SpaceBefore(0);
paragraph->get_ParagraphFormat()->set_SpaceAfter(0);
auto mathPortion = System::ExplicitCast<MathPortion>(paragraph->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
mathParagraph->set_Justification(MathJustification::LeftJustified);
auto rows = System::MakeArray<System::SharedPtr<IMathElement>>({createText(u"x+y=3"), createText(u"x-y=1"), createText(u"x=2")});
auto equationArray = System::MakeObject<MathArray>(rows);
equationArray->set_BaseJustification(MathVerticalAlignment::Center);
equationArray->set_RowSpacingRule(setting.rule);
equationArray->set_RowSpacing(setting.spacing);
auto leftText = createText(u"A=");
auto rightText = createText(u"=B");
auto equation = System::MakeObject<MathBlock>(leftText)->Join(equationArray)->Join(rightText);
mathParagraph->Add(equation);
presentation->Save(fileName, SaveFormat::Pptx);
presentation->Dispose();
}
Odstępy wierszy tablicy są oddzielne od odstępów akapitu. set_SpaceBefore i set_SpaceAfter dodają odstęp wokół całego akapitu, nie między wierszami tablicy. Podobnie IMathParagraph::set_Justification pozycjonuje cały akapit matematyczny w poziomie; nie zastępuje ustawienia pionowego wyrównania tablicy.
Dodaj funkcje trygonometryczne
Użyj AsArgumentOfFunction gdy argument jest bieżącym elementem, a nazwa funkcji jest znana.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathFunctionsOfOneArgument.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto cosine = System::MakeObject<MathematicalText>(u"2x")
- >AsArgumentOfFunction(MathFunctionsOfOneArgument::Cos);
mathParagraph->Add(System::MakeObject<MathBlock>(cosine));
presentation->Save(u"trigonometric-function.pptx", SaveFormat::Pptx);
presentation->Dispose();
Dodaj indeksy dolne i górne
Użyj pomocników indeksu dolnego i górnego dla indeksów i potęg. Gdy indeksy mają pojawić się po lewej stronie podstawy, użyj SetSubSuperscriptOnTheLeft.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto scripts = System::MakeObject<MathematicalText>(u"Y")
- >SetSubSuperscriptOnTheLeft(u"1", u"n");
mathParagraph->Add(System::MakeObject<MathBlock>(scripts));
presentation->Save(u"subscript-superscript.pptx", SaveFormat::Pptx);
presentation->Dispose();
Dodaj delimitery
Użyj Enclose aby umieścić wyrażenie w delimiterach. Możesz także ustawić znak separatora dla wyrażeń delimiterów zawierających kilka elementów.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto delimiter = System::MakeObject<MathematicalText>(u"x")
- >Join(u"y")
- >Join(u"z")
- >Enclose(u'<', u'>', u'|');
mathParagraph->Add(System::MakeObject<MathBlock>(delimiter));
presentation->Save(u"delimiters.pptx", SaveFormat::Pptx);
presentation->Dispose();
Rozmiar i wyrównanie delimiterów
Przekaż true do set_GrowToMatchOperandHeight aby nawiasy rosły wokół wysokiego składnika, lub false aby zachować ich normalny rozmiar. set_DelimiterShape przyjmuje jedną z dwóch wartości MathDelimiterShape. Centered centruje nawiasy na osi matematycznej, która przechodzi przez środek znaku równości. Match wyrównuje je z zawartością. Oba ustawienia wpływają wyłącznie na delimitery. Wyrażenie wewnątrz pozostaje niezmienione.
Przykład umieszcza ułamek w wykładniku x, tak że wyrażenie rozciąga się wyżej nad linią bazową niż poniżej. Wszystkie cztery równania używają tych samych nawiasów i ustawień czcionki.
#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/IPortionFormat.h>
#include <DOM/MathText/IMathBlock.h>
#include <DOM/MathText/IMathDelimiter.h>
#include <DOM/MathText/IMathFraction.h>
#include <DOM/MathText/IMathSuperscriptElement.h>
#include <DOM/MathText/MathDelimiterShape.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto addExpression = [slide](float left, float top, bool grow, MathDelimiterShape shape)
{
auto fraction = System::MakeObject<MathematicalText>(u"a + b")->Divide(u"c + d");
auto power = System::MakeObject<MathematicalText>(u"x")->SetSuperscript(fraction);
auto delimiter = power->Enclose(u'(', u')');
delimiter->set_GrowToMatchOperandHeight(grow);
delimiter->set_DelimiterShape(shape);
auto mathShape = slide->get_Shapes()->AddMathShape(left, top, 300, 100);
auto portion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
portion->get_PortionFormat()->set_FontHeight(32);
auto equation = System::MakeObject<MathematicalText>(u"y = ")->Join(delimiter);
portion->get_MathParagraph()->Add(equation);
};
addExpression(20, 20, true, MathDelimiterShape::Centered);
addExpression(350, 20, true, MathDelimiterShape::Match);
addExpression(20, 140, false, MathDelimiterShape::Centered);
addExpression(350, 140, false, MathDelimiterShape::Match);
presentation->Save(u"delimiter-sizing.pptx", SaveFormat::Pptx);
presentation->Dispose();
W PowerPoint porównaj wiersze, aby zobaczyć efekt wzrostu. W górnym wierszu nawiasy rosną, aby objąć wykładnik i wyglądają tak samo dla obu kształtów. W dolnym wierszu wzrost jest wyłączony. Mniejsze nawiasy po lewej (Centered) wyrównują się ze znakiem równości, natomiast po prawej (Match) są wyżej wokół wyrażenia.

Dodaj ramkę obramowania
Wywołaj ToBorderBox na ułamku, aby otoczyć całą ekspresję. Zwrócony IMathBorderBox domyślnie pokazuje wszystkie cztery strony. Użyj set_HideTop, set_HideBottom, set_HideLeft i set_HideRight, aby usunąć poszczególne strony.
Przykład umieszcza sześć kopii tego samego ułamka na jednym slajdzie. Aby pokazać anulowanie, ukryj wszystkie cztery strony i ustaw set_StrikethroughBottomLeftToTopRight dla rosnącej przekątnej (↗) lub set_StrikethroughTopLeftToBottomRight dla opadającej przekątnej (↘). Można także użyć set_StrikethroughHorizontal lub set_StrikethroughVertical z dowolną kombinacją widocznych stron.
#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IPortionFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ISlideSize.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathBorderBox.h>
#include <DOM/MathText/IMathFraction.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <DOM/SlideSizeScaleType.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
presentation->get_SlideSize()->SetSize(540, 220, SlideSizeScaleType::DoNotScale);
auto slide = presentation->get_Slide(0);
auto addFraction = [slide](float x, float y, bool hideBorder = false)
{
auto fraction = System::MakeObject<MathematicalText>(u"x+1")->Divide(u"y+2");
auto box = fraction->ToBorderBox();
box->set_HideTop(hideBorder);
box->set_HideBottom(hideBorder);
box->set_HideLeft(hideBorder);
box->set_HideRight(hideBorder);
auto shape = slide->get_Shapes()->AddMathShape(x, y, 160, 90);
auto portion = System::ExplicitCast<MathPortion>(shape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
portion->get_PortionFormat()->set_FontHeight(28);
auto mathBlock = System::MakeObject<MathBlock>(box);
portion->get_MathParagraph()->Add(mathBlock);
return box;
};
addFraction(10, 10);
auto partial = addFraction(190, 10);
partial->set_HideTop(true);
partial->set_HideRight(true);
addFraction(370, 10, true)->set_StrikethroughBottomLeftToTopRight(true);
addFraction(10, 120, true)->set_StrikethroughTopLeftToBottomRight(true);
addFraction(190, 120, true)->set_StrikethroughHorizontal(true);
addFraction(370, 120)->set_StrikethroughVertical(true);
presentation->Save(u"border-box.pptx", SaveFormat::Pptx);
presentation->Dispose();

Na tym ułamku poziome przekreślenie zachodzi na kreskę ułamkową. Pionowe przekreślenie przecina zarówno licznik, jak i mianownik, podczas gdy otaczające obramowanie pozostaje widoczne. Linijki te zdobią całe wyrażenie. Zwykłe przekreślenie tekstu dotyczy znaków w ciągu tekstowym. Po ponownym otwarciu prezentacji w PowerPoint możesz nadal edytować licznik i mianownik niezależnie.
Kontroluj widoczność i układ za pomocą elementów Phantom
Umieść wyrażenie w MathPhantom, aby sterować jego widocznością i przestrzenią, jaką przyczynia się do równania, niezależnie. Metody ustawiające w IMathPhantom kontrolują następujące:
| Metoda | Efekt |
|---|---|
| set_Show | Przekaż false, aby ukryć wyrażenie. Jego wymiary nadal wpływają na układ, chyba że odpowiednie ustawienia poniżej są true. |
| set_ZeroWidth | Traktuj poziomą szerokość wyrażenia jako zero, co pozwala sąsiednim elementom zbliżyć się do siebie. |
| set_ZeroAsc | Traktuj jego wzniesienie, czyli wysokość powyżej linii bazowej, jako zero. To może zmniejszyć przestrzeń nad sąsiednimi elementami. |
| set_ZeroDesc | Traktuj jego opad, czyli głębokość poniżej linii bazowej, jako zero. To może przesunąć kreskę ułamkową lub inną treść poniżej wyrażenia bliżej sąsiadów. |
Linia bazowa jest linią odniesienia, na której znajdują się zwykłe litery matematyczne. Ukrywanie treści nie usuwa jej wymiarów, a traktowanie wymiaru jako zero nie usuwa wyrażenia. Podstawowe wyrażenie pozostaje dostępne przez get_Base. Przekaż true do set_Show, aby ponownie je wyświetlić; ustawienia wymiarów pozostają niezmienione.
Poniższy przykład tworzy pięć wariantów obok siebie: widoczny ułamek, ukryty ułamek rezerwujący miejsce oraz trzy ukryte ułamki, w których jeden wymiar jest traktowany jako zero. Każdy wariant używa tego samego otaczającego wyrażenia i czcionki Cambria Math 24 pt. Wszystkie kształty równań mają tę samą pozycję górną, oznaczoną szarym prowadnikiem. Umieszczenie elementu phantom w liczniku zewnętrznego ułamka ułatwia dostrzeżenie zmian w układzie pionowym.
#include <array>
#include <drawing/color.h>
#include <DOM/FillType.h>
#include <DOM/Fonts/FontData.h>
#include <DOM/IAutoShape.h>
#include <DOM/IColorFormat.h>
#include <DOM/IFillFormat.h>
#include <DOM/ILineFormat.h>
#include <DOM/IParagraph.h>
#include <DOM/IPortion.h>
#include <DOM/IPortionFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ISlideSize.h>
#include <DOM/ITextFrame.h>
#include <DOM/ITextFrameFormat.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathFraction.h>
#include <DOM/MathText/MathPhantom.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <DOM/SlideSizeScaleType.h>
#include <DOM/TextAnchorType.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto createText = [](System::String value)
{
auto text = System::MakeObject<MathematicalText>(value);
text->get_Format()->set_FontHeight(24);
auto font = System::MakeObject<FontData>(u"Cambria Math");
text->get_Format()->set_LatinFont(font);
return text;
};
auto presentation = System::MakeObject<Presentation>();
presentation->get_SlideSize()->SetSize(1000, 180, SlideSizeScaleType::DoNotScale);
auto slide = presentation->get_Slide(0);
std::array<System::String, 5> labels = {u"Visible", u"Hidden: reserves space", u"Hidden: ZeroWidth", u"Hidden: ZeroAsc", u"Hidden: ZeroDesc"};
auto guide = slide->get_Shapes()->AddAutoShape(ShapeType::Line, 10, 60, 980, 0);
guide->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
guide->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_LightGray());
for (auto i = 0; i < labels.size(); i++)
{
auto left = 10 + i * 200;
auto label = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, left, 10, 190, 30);
label->get_FillFormat()->set_FillType(FillType::NoFill);
label->get_LineFormat()->get_FillFormat()->set_FillType(FillType::NoFill);
label->get_TextFrame()->set_Text(labels[i]);
auto labelFormat = label->get_TextFrame()->get_Paragraph(0)->get_Portion(0)->get_PortionFormat();
labelFormat->set_FontHeight(14);
labelFormat->get_FillFormat()->set_FillType(FillType::Solid);
labelFormat->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Black());
auto fractionNumerator = createText(u"a+b");
auto fractionDenominator = createText(u"c+d");
auto fraction = System::MakeObject<MathFraction>(fractionNumerator, fractionDenominator);
auto phantom = System::MakeObject<MathPhantom>(fraction);
phantom->set_Show(i == 0);
phantom->set_ZeroWidth(i == 2);
phantom->set_ZeroAsc(i == 3);
phantom->set_ZeroDesc(i == 4);
auto leadingText = createText(u"x+");
auto trailingText = createText(u"+y");
auto numeratorBlock = System::MakeObject<MathBlock>(leadingText);
auto numerator = numeratorBlock->Join(phantom)->Join(trailingText);
auto denominator = createText(u"z");
auto equation = System::MakeObject<MathFraction>(numerator, denominator);
auto shape = slide->get_Shapes()->AddMathShape(left, 60, 190, 100);
shape->get_TextFrame()->get_TextFrameFormat()->set_AnchoringType(TextAnchorType::Top);
auto mathPortion = System::ExplicitCast<MathPortion>(shape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto mathBlock = System::MakeObject<MathBlock>(equation);
mathParagraph->Add(mathBlock);
}
presentation->Save(u"math-phantom.pptx", SaveFormat::Pptx);
presentation->Dispose();

Grupuj wyrazy
Użyj Group aby umieścić znak grupujący nad lub pod wyrażeniem. Dodaj limit, aby oznaczyć grupowane wyrazy.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathGroupingCharacter.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathTopBotPositions.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 120.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto grouped = System::MakeObject<MathematicalText>(u"x + y")
- >Group(u'\u23DF', MathTopBotPositions::Bottom, MathTopBotPositions::Top)
- >SetLowerLimit(u"any text");
mathParagraph->Add(System::MakeObject<MathBlock>(grouped));
presentation->Save(u"grouped-terms.pptx", SaveFormat::Pptx);
presentation->Dispose();
Formatuj elementy matematyczne
Używaj pomocników formatowania tylko tam, gdzie wyjaśniają formułę. Na przykład Overbar umieszcza pasek nad elementem matematycznym.

#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/MathBlock.h>
#include <DOM/MathText/MathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto mathShape = slide->get_Shapes()->AddMathShape(20.0f, 20.0f, 700.0f, 100.0f);
auto mathPortion = System::ExplicitCast<MathPortion>(mathShape->get_TextFrame()->get_Paragraph(0)->get_Portion(0));
auto mathParagraph = mathPortion->get_MathParagraph();
auto overbar = System::MakeObject<MathematicalText>(u"ABC")->Overbar();
mathParagraph->Add(System::MakeObject<MathBlock>(overbar));
presentation->Save(u"overbar.pptx", SaveFormat::Pptx);
presentation->Dispose();
Formatuj tekst w istniejącym równaniu
Aby sformatować tekst w całym istniejącym równaniu, przejdź po drzewie elementów każdego bloku matematycznego. IMathElement::GetChildren zwraca tylko bezpośrednie dzieci, więc wywołuj ją rekurencyjnie, aby dotrzeć do tekstu wewnątrz ułamków, skryptów, pierwiastków i innych zagnieżdżonych struktur. Sprawdzaj bieżący element oraz jego dzieci, aby uwzględnić element początkowy, gdy jest MathematicalText.
Ten przykład zakłada, że prezentacja zawiera równanie takie jak z = xᵢ / ∛y, z ułamkiem zawierającym indeks dolny w liczniku oraz pierwiastkiem w mianowniku. Przetwarzanie jedynie elementów najwyższego poziomu bloku pominęłoby tekst wewnątrz ułamka. Przykład znajduje fragmenty matematyczne w ramkach tekstowych slajdów, uzyskuje dostęp do ich bloków przez IMathPortion::get_MathParagraph, i ustawia wysokość czcionki na 28 punktów przy pomocy set_FontHeight, odwołując się do formatowania poprzez metodę get_Format każdego elementu tekstowego.
#include <functional>
#include <system/array.h>
#include <DOM/IAutoShape.h>
#include <DOM/IParagraph.h>
#include <DOM/IParagraphCollection.h>
#include <DOM/IPortion.h>
#include <DOM/IPortionCollection.h>
#include <DOM/IPortionFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ISlideCollection.h>
#include <DOM/ITextFrame.h>
#include <DOM/MathText/IMathBlock.h>
#include <DOM/MathText/IMathElement.h>
#include <DOM/MathText/IMathParagraph.h>
#include <DOM/MathText/IMathPortion.h>
#include <DOM/MathText/MathematicalText.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace Aspose::Slides::MathText;
std::function<void(System::SharedPtr<IMathElement>)> formatMathText;
formatMathText = [&formatMathText](System::SharedPtr<IMathElement> element)
{
auto text = System::DynamicCast<MathematicalText>(element);
if (text != nullptr)
text->get_Format()->set_FontHeight(28.0f);
for (auto child : element->GetChildren())
formatMathText(child);
};
auto presentation = System::MakeObject<Presentation>(u"input.pptx");
for (auto slide : presentation->get_Slides())
{
for (auto shape : slide->get_Shapes())
{
auto autoShape = System::DynamicCast<IAutoShape>(shape);
if (autoShape == nullptr || autoShape->get_TextFrame() == nullptr)
continue;
for (auto paragraph : autoShape->get_TextFrame()->get_Paragraphs())
{
for (auto portion : paragraph->get_Portions())
{
auto mathPortion = System::DynamicCast<IMathPortion>(portion);
if (mathPortion != nullptr)
{
for (auto block : mathPortion->get_MathParagraph())
formatMathText(block);
}
}
}
}
}
presentation->Save(u"formatted-equations.pptx", SaveFormat::Pptx);
presentation->Dispose();
Zapisana prezentacja zawiera zaktualizowane formatowanie tekstu na każdym poziomie każdej przetworzonej formuły, zachowując jednocześnie jej treść i strukturę matematyczną.
Szybkie odniesienie
| Zadanie | Główne API |
|---|---|
| Utwórz tekst matematyczny | MathematicalText |
| Połącz elementy | IMathElement.Join |
| Utwórz ułamki | IMathElement.Divide |
| Dodaj indeks górny lub dolny | SetSuperscript, SetSubscript |
| Dodaj funkcje | Function, AsArgumentOfFunction |
| Dodaj pierwiastki | IMathElement.Radical |
| Dodaj granice | SetLowerLimit, SetUpperLimit |
| Dodaj skrypty po lewej stronie | SetSubSuperscriptOnTheLeft |
| Dodaj sumy i całki | Nary, Integral |
| Dodaj macierze | MathMatrix |
| Dodaj tablice równań | ToMathArray |
| Dodaj delimitery | Enclose |
| Dodaj kreski i obramowania | Overbar, ToBorderBox |
| Grupuj wyrazy | Group |
FAQ
Czy mogę edytować istniejące równanie PowerPointa?
Tak. Otwórz prezentację, znajdź kształt zawierający MathPortion, wywołaj get_MathParagraph, i zaktualizuj bloki matematyczne w tym akapicie.
Czy równania są zapisywane jako edytowalna matematyka PowerPointa?
Tak. Podczas zapisu do PPTX Aspose.Slides zapisuje równanie jako edytowalną zawartość Office Math.
Czy mogę wyeksportować równania do LaTeX?
Tak. Pobierz IMathParagraph z jego IMathPortion, i wywołaj IMathParagraph::ToLatex, aby wyeksportować je bezpośrednio. Pełny przykład znajdziesz w Export Math Equations from Presentations in C++.