外部ラテックスパッケージ| Python

外部ラテックスパッケージ

Aspose.TeXライブラリには、さまざまな 一般的なラテックスパッケージが付属しているため、これらのパッケージをTexエンジンに手動で提供する必要はありません。ただし、ラテックスファイルには、ライブラリのパッケージの「バンドル」に含まれていないパッケージが必要な状況がある場合があります。そのような場合、 rebused_input_directory texoptionsクラスインスタンスのオプションを介して、必要なパッケージのソースファイルなど、必要な入力を提供してみてください。これが2つの例でどのように機能するかを探ります。

未梱包のフォーム(「ファンシーボックス」パッケージ)で提供される必要な入力。

「required-input-fs.tex」という名前の次の基本的なラテックスファイルがあるとします。これは サンプルソリューションの一部です。

 1\documentclass{article}
 2\usepackage[a6paper,landscape]{geometry}
 3\usepackage{fancybox}
 4\begin{document}
 5Test: \fbox{
 6  \begin{Bitemize}[b]
 7  \item First item
 8  \item A second one\\ on two lines
 9  \item(2pt) A third with extra space
10  \end{Bitemize}
11}
12\par\bigskip
13Test: \fbox{
14  \begin{Beqnarray}[t]
15  y & = & x^2 \\
16  a^2 + 2ab + b^2 & = & (a + b)^2 \\
17  \int_0^\infty e^{-ax} dx & = & \frac{1}{a}
18  \end{Beqnarray}
19}
20\end{document}

ファイルの3行目は、「ネイティブ」サポートには含まれていない「Fancybox」パッケージが必要であることを示しています。 「Fancybox」パッケージのソースファイルがあると仮定しましょう。単一のファイルで構成される単純なパッケージであるため、このファイルをファイルシステムのどこにでも配置して、次のようにディレクトリパスを指定できます。

1options.required_input_directory = InputFileSystemDirectory('path-to-directory-where-fancybox.sty-located')

このオプションでTEXジョブを実行したら(必要に応じて他のオプションを調整することを忘れないでください)、この場合はPNG画像である出力ドキュメントを取得します。

出力ドキュメント

これが例の完全なソースコードです。

 1from aspose.tex import *
 2from aspose.tex.io import *
 3from aspose.tex.presentation.image import *
 4from util import Util
 5from os import path
 6###############################################
 7###### Class and Method declaration here ######
 8###############################################
 9
10# Create conversion options for Object LaTeX format upon Object TeX engine extension.
11options = TeXOptions.console_app_options(TeXConfig.object_latex)
12# Specify a file system working directory for the output.
13options.output_working_directory = OutputFileSystemDirectory(Util.output_directory)
14# Specify a file system working directory for the required input.
15# The directory containing packages may be located anywhere.
16options.required_input_directory = InputFileSystemDirectory(path.join(Util.input_directory, "packages"))
17# Initialize the options for saving in PNG format.
18options.save_options = PngSaveOptions()
19# Run LaTeX to PNG conversion.
20TeXJob(path.join(Util.input_directory, "required-input-fs.tex"), ImageDevice(True), options).run()

アーカイブフォームで必要な入力を提供する(「pgfplots」パッケージ)

次に、「必要な入力Zip.tex」という名前の次のLaTexファイルがあるとします。これは、例のソリューションからの簡単なファイルでもあります。

 1\documentclass{article}
 2\usepackage[margin=0.25in]{geometry}
 3\usepackage{pgfplots}
 4\pgfplotsset{width=10cm,compat=1.18}
 5\begin{document}
 6
 7First example is 2D and 3D math expressions plotted side-by-side.
 8
 9%Here begins the 2D plot
10\begin{tikzpicture}
11\begin{axis}
12\addplot[color=red]{exp(x)};
13\end{axis}
14\end{tikzpicture}
15%Here ends the 2D plot
16\hskip 5pt
17%Here begins the 3D plot
18\begin{tikzpicture}
19\begin{axis}
20\addplot3[
21    surf,
22]
23{exp(-x^2-y^2)*x};
24\end{axis}
25\end{tikzpicture}
26%Here ends the 3D plot
27
28\end{document}

3行目では、ファイルが「ネイティブに」サポートされていない「pgfplots」パッケージが必要であることが観察できます。繰り返しになりますが、「PGFPlots」パッケージのソースファイルを所有していると仮定すると、これらのファイルは非常に多く、LaTexタイプセットアプリケーションのインストールディレクトリ内の2つの異なるディレクトリにあります。 pgfplotsフォルダーは、「\ tex \ generic」と \ tex \ latexディレクトリの両方にあります。 Aspose.TeXライブラリが正しく機能するには、これらの両方のフォルダーの内容を入力として提供する必要があります。これを達成するために、これらのソースファイルをzipアーカイブにパッケージ化したいと考えています。以下は、アーカイブの目的のレイアウトです。

アーカイブのレイアウト

そして、これらのソースファイルへのアクセシビリティを定義する方法は次のとおりです。

1with open("path-to-zip-with-pgfplots-sources") as zipStream:
2    ...
3    options.required_input_directory = InputZipDirectory(zipStream)
4    ...

このオプションでTEXジョブを実行した後、出力ドキュメントを取得します。

出力ドキュメント

これが例の完全なソースコードです。

 1from aspose.tex import *
 2from aspose.tex.io import *
 3from aspose.tex.presentation.image import *
 4from util import Util
 5from os import path
 6###############################################
 7###### Class and Method declaration here ######
 8###############################################
 9
10# Create conversion options for Object LaTeX format upon Object TeX engine extension.
11options = TeXOptions.console_app_options(TeXConfig.object_latex)
12# Specify a file system working directory for the output.
13options.output_working_directory = OutputFileSystemDirectory(Util.output_directory)
14# Initialize the options for saving in PNG format.
15options.save_options = PngSaveOptions()
16# Create a file stream for the ZIP archive containing the required package.
17# The ZIP archive may be located anywhere.
18with open(path.join(Util.input_directory, "packages\\pgfplots.zip"), "rb") as zip_stream:
19    # Specify a ZIP working directory for the required input.
20    options.required_input_directory = InputZipDirectory(zip_stream, "")
21
22    # Run LaTeX to PNG conversion.
23    TeXJob(path.join(Util.input_directory, "required-input-zip.tex"), ImageDevice(True), options).run()

注意: この結果は pgfplots パッケージのバージョン 1.18.1 を使用して検証されました。Aspose.TeX ライブラリに含まれる pfg パッケージのバージョンは 3.1.9a です。

制限

latex3eカーネルANの下で開発されたパッケージに出くわした場合、LaTexファイルで必要とされている場合、Aspose.TeXライブラリを使用する可能性は低いです。これは、ライブラリが * latex2e *カーネルに基づいているためです。

さらに、ラテックスファイルに必要なパッケージが、Aspose.TeXライブラリのオブジェクトtexエンジンによってサポートされていないデバイス依存のプリミティブコマンドを直接使用する場合があります。そのような場合、パッケージはライブラリで動作しません。

Have any questions about Aspose.TeX?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.