Render Equations and Math Formulas using C#

LaTeX는 수학적 콘텐츠를 표준화하기위한 특별한 도구이며, 수식과 방정식을 쉽게 삽입할 수 있습니다. 텍스 이 소스 문서, LaTeX와 함께 만들어진, 형식 텍스트, 상징, 수학 표현 및 그래픽을위한 명령의 포괄적 인 범위를 제공합니다.이 기사에서, 당신은 널리 알려진 Aspose TeX API를 사용하여 효율적으로 라텍스 방정식과 수학과 수식을 수행하는 방법을 배울 것입니다.

테이블 콘텐츠

C# API to Render LaTeX 평등 및 수학 수식

LaTeX 수학 수식을 제공하기 위해, 우리는 .NET을 위한 ASPOSE.TEX API. 이 강력한 .NET LaTeX 방정식 렌더링 라이브러리는 PDF, XPS 또는 이미지를 포함하여 다양한 형식으로 TeX 파일을 튜토리얼 할 수 있습니다. C#에서 높은 성능의 라텍스 레너링을위한 완벽하며 LaTEX 리너닝에 대한 최고의 C # 라이버러리로 인식됩니다.

당신도 할 수 있습니다 DLL 다운로드 API 또는 설치를 통해 나그네:

PM> Install-Package Aspose.TeX

Render LaTeX Inline 수학 수식을 사용하여 C#

간단한 인라인 수학 수식이나 평등을 제출하는 것은 간단합니다.이 단계를 따르십시오 :

  • MathRendererOptions 클래스의 예를 만드십시오.
  • LaTeX 문서 사전을 지정합니다.
  • 선택적으로, 예를 들어 특성 조정 스케일, TextColor, BackgroundColor, 그리고 등등
  • 수식 이미지에 대한 출력 스트림을 만듭니다.
  • Render() 방법을 호출하여 수식 줄, 흐름, MathRendeerOptions 및 출력 이미지 크기를 논쟁으로 전달합니다.

다음은 코드 샘플을 보여줍니다 C#를 사용하여 수학 공식을 프로그래밍하는 방법 :

// This code example demonstrates how to render math formulas and equations
// Create rendering options specifying the image resolution 150 dpi
MathRendererOptions options = new PngMathRendererOptions() { Resolution = 150 };
// Specify the preamble.
options.Preamble = @"\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color}";
// Specify the scaling factor 300%.
options.Scale = 3000;
// Specify the foreground color.
options.TextColor = System.Drawing.Color.Black;
// Specify the background color.
options.BackgroundColor = System.Drawing.Color.White;
// Specify the output stream for the log file.
options.LogStream = new MemoryStream();
// Specify whether to show the terminal output on the console or not.
options.ShowTerminal = true;
// The variable in which the dimensions of the resulting image will be written.
System.Drawing.SizeF size = new System.Drawing.SizeF();
// Create the output stream for the formula image.
using (Stream stream = File.Open(@"D:\Files\Tex\math-formula.png", FileMode.Create))
// Run rendering.
MathRenderer.Render(@"This is a sample formula $f(x) = x^2$ example.", stream, options, out size);
// Show other results.
System.Console.Out.WriteLine(options.ErrorReport);
System.Console.Out.WriteLine();
System.Console.Out.WriteLine("Size: " + size);
Render Inline Math Formulas using C#

Render Inline Math Formulas using C#

렌더 컴플렉스 LaTeX 균형 C# {# 렌더 컴플렉스-균형-CSharp}

복잡한 LaTeX 방정식은 이전과 동일한 단계를 따르지만 단계 #4에서 더 흥미로운 수식 줄을 가지고 있습니다.

MathRenderer.Render(@"\begin{equation*}
                e^x = x^{\color{red}0} + x^{\color{red}1} + 
                \frac{x^{\color{red}2}}{2} + 
                \frac{x^{\color{red}3}}{6} + 
                \cdots = \sum_{n\geq 0} \frac{x^{\color{red}n}}{n!}
                \end{equation*}", stream, options, out size);
Render Complex Equations in C#

Render Complex Equations in C#

C#에서 긴 평등을 표시

여러 라인에 걸쳐 긴 평등을 표시하려면 LaTeX Multline 환경에서 다음과 같은 접근 방식을 사용하십시오.

MathRenderer.Render(@"\begin{document}
                    \begin{multline*}
	            p(x) = x^1+x^2+x^3+x^4\\ 
	            - x^4 - x^3 - x^2 - x
	            \end{multline*}
                    \end{document}", stream, options, out size);
Display Long Equations

Display Long Equations in C#

C#를 사용하여 여러 평등을 조정

당신은 단계 #4에서 수식 줄을 변경하여 여러 방정식을 조정할 수 있습니다 :

MathRenderer.Render(@"\begin{document}
                         \begin{align*}
                         a+b   &  a-b   &  (a+b)(a-b)\\
                         x+y   &  x-y   &  (x+y)(x-y)\\
                         p+q   &  p-q   &  (p+q)(p-q)
                         \end{align*}
                         \end{document}", stream, options, out size);
Align Several Equations using C#

Align Several Equations using C#

C#를 사용하여 그룹 및 센터 평등

여러 평등을 그룹화하고 중심화하려면 다음 코드를 사용하십시오.

MathRenderer.Render(@"\begin{gather*} 
                (a+b)=a^2+b^2+2ab \\ 
                (a-b)=a^2+b^2-2ab \\ 
                (a-b)=a^2+b^2-2ab
                \end{gather*}", stream, options, out size);
Group and Center Equations using C#

Group and Center Equations using C#

Render Matrices, Parentheses, and Brackets in C# {#Render-Matrices,-Parenthesis,-and-Brackets-in-CSharp}

당신은 매트리스, 파렌테세스 및 브래켓을 비슷하게 수행 할 수 있습니다 :

MathRenderer.Render(@"\begin{document}
	            [ 
	            \left \{
	              \begin{tabular}{ccc}
	              1 & 4 & 7 \\
	              2 & 5 & 8 \\
	              3 & 6 & 9 
	              \end{tabular}
	            \right \}
	            ]
	            \end{document}", stream, options, out size);
Render Matrices, Parenthesis, and Brackets in C#

Render Matrices, Parenthesis, and Brackets in C#

C#를 사용하여 Render Fractions and Binomials-using-CSharp}

fractions 및 binomials를 수행하려면,이 구조를 따르십시오 :

MathRenderer.Render(@"\begin{document}
	            [
	                \binom{n}{k} = \frac{n!}{k!(n-k)!}
	            ]
	            \end{document}", stream, options, out size);
Render Fractions and Binomials using C#

Render Fractions and Binomials using C#

무료 라이센스를 얻으십시오

당신은 할 수 무료 임시 라이센스를 받으십시오. 제한 없이 도서관을 평가할 수 있습니다.

결론

이 기사에서 우리는 다음과 같은 방법을 조사했습니다 :

  • C#에서 간단하고 복잡한 수학 수식과 방정식을 제공합니다.
  • 일관성과 그룹 방정식은 프로그래밍으로 진행됩니다.
  • 렌더 매트리스, 파렌테세스, 브래켓, 부분 및 binomials.

C#에서 LaTeX 방정식과 수학 수식을 제시하는 것 외에도, 당신은 더 깊이 탐색 할 수 있습니다. .NET을 위한 ASPOSE.TEX API를 참조하여 문서화당신이 어떤 질문이 있다면, 우리에 도달 할 수있는 자유를 느끼십시오. 무료 지원 포럼.

Aspose 플러그인을 사용하면 C#에서 높은 품질의 LaTeX 프레젠테이션을 달성하고 WinForms, WPF 또는 .NET MAUI를 사용하는지 여부를 응용 프로그램에 LaTeX 평등을 통합 할 수 있습니다. C# ASP.NET 응용 프로그램에서 수학 표현을 프레젠테이션하기 시작하십시오.

또한, LaTeX를 수행하는 방법을 이해하는 것은 수학적 콘텐츠로 일하는 개발자에게 필수적입니다. C# La TeX와 같은 적절한 도구를 사용하면 복잡한 수식을 프로젝트에 쉽게 통합 할 수 있습니다. *LaTex 그룹 방정식에 관심이 있거나 *Latex 긴 방향을 수송해야하는지 여부는, 이 가이드는 당신에게 필요한 개념을 제공해야합니다.

More in this category