外部乳胶软件包| Python

外部乳胶软件包

Aspose.TeX库带有各种 常见的乳胶包裹,因此无需手动向Tex发动机提供这些软件包。但是,在某些情况下,您的乳胶文件需要一个包装中未包含的软件包。在这种情况下,您可以尝试通过 queld_input_directory texoptions类实例提供必要的输入,例如所需软件包的源文件。我们将探讨这两个示例的工作方式。

所需的输入以未包装的形式(``Fancybox’‘软件包)提供。

假设我们有以下名为ruild-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}

文件的第三行表示它需要`fancybox“软件包,fancybox”包中未包含在“本机”支持中。假设我们有“ Fancybox”软件包的源文件。由于这是一个由单个文件组成的简单软件包,我们可以将此文件放在文件系统中的任何位置,并指定目录路径如下:

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

一旦我们使用此选项运行TEX作业(请记住要根据需要调整其他选项),我们将获得输出文档,在这种情况下,这是PNG图像。

输出文档

这是该示例的完整源代码:

 1# Create conversion options for Object LaTeX format upon Object TeX engine extension.
 2options = TeXOptions.console_app_options(TeXConfig.object_latex)
 3# Specify a file system working directory for the output.
 4options.output_working_directory = OutputFileSystemDirectory(Util.output_directory)
 5# Specify a file system working directory for the required input.
 6# The directory containing packages may be located anywhere.
 7options.required_input_directory = InputFileSystemDirectory(path.join(Util.input_directory, "packages"))
 8# Initialize the options for saving in PNG format.
 9options.save_options = PngSaveOptions()
10# Run LaTeX to PNG conversion.
11TeXJob(path.join(Util.input_directory, "required-input-fs.tex"), ImageDevice(True), options).run()

提供所需的输入以存档的形式(``pgfplots’软件包)提供

现在,假设我们有以下名为“必需input-zip.tex”的乳胶文件,这也是我们示例解决方案的简单文件:

 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}

在第三行上,可以观察到该文件需要“ PGFPLOTS”软件包,而不是“本地”支持。再一次,假设我们拥有“ PGFPLOTS”软件包的源文件,这些文件很多,并且位于任何乳胶排放应用程序的安装目录中的两个不同目录中。可以在\ tex \ generic\ tex \ latex目录”中找到“ pgfplots”文件夹。为了使aspose.tex库正确运行,必须提供两个文件夹的内容作为输入。为了实现这一目标,我们希望将这些源文件包装到ZIP档案中。以下是档案的所需布局:

存档的布局

这是我们定义这些源文件的可访问性的方法:

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

通过此选项运行Tex作业后,我们将获得输出文档:

输出文档

这是该示例的完整源代码:

 1# Create conversion options for Object LaTeX format upon Object TeX engine extension.
 2options = TeXOptions.console_app_options(TeXConfig.object_latex)
 3# Specify a file system working directory for the output.
 4options.output_working_directory = OutputFileSystemDirectory(Util.output_directory)
 5# Initialize the options for saving in PNG format.
 6options.save_options = PngSaveOptions()
 7# Create a file stream for the ZIP archive containing the required package.
 8# The ZIP archive may be located anywhere.
 9with open(path.join(Util.input_directory, "packages\\pgfplots.zip"), "rb") as zip_stream:
10    # Specify a ZIP working directory for the required input.
11    options.required_input_directory = InputZipDirectory(zip_stream, "")
12
13    # Run LaTeX to PNG conversion.
14    TeXJob(path.join(Util.input_directory, "required-input-zip.tex"), ImageDevice(True), options).run()

注意: 结果是使用 pgfplots 软件包版本 1.18.1 验证的。而 Aspose.TeX 库中包含的 pfg 软件包版本为 3.1.9a。

限制

如果您遇到乳胶文件所需的latex3ekernel an的软件包,则不太可能与Aspose.TeX库一起使用。这是因为库基于 latex2e内核。

此外,在某些情况下,您的乳胶文件要求的包装直接使用了Aspose.TeX library的object tex引擎不支持设备的原始命令。在这种情况下,该软件包将无法与库一起使用。

Have any questions about Aspose.TeX?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.