その他のTEX変換出力形式| 。ネット
現在、ラテックス以外の形式で記述されたTEXファイルを変換したいと思う可能性は非常に低いです。しかし、これは、何らかの理由でTex言語や内部を勉強している場合に可能です。とにかく、Aspose.TeX for .netでは、プレーンTex形式で記述されたファイルを変換できます。また、これらの形式で設計されたカスタム形式とタイプセットドキュメントを作成することもできます。
カスタム形式の作成から始めます。
カスタム形式の作成
フォーマットファイルは、TEXエンジンの内部状態のバイナリダンプであることを覚えておいてください。
1// Create TeX engine options for no format upon ObjectTeX engine extension.
2TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectIniTeX);
3// Specify a file system working directory for the input.
4options.InputWorkingDirectory = new InputFileSystemDirectory(RunExamples.InputDirectory);
5// Specify a file system working directory for the output.
6options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
7
8// Run format creation.
9TeXJob.CreateFormat("customtex", options);
10
11// For further output to look fine.
12options.TerminalOut.Writer.WriteLine();
ご覧のとおり、コードはTEXファイルを変換するためのコードに似ています。しかし、いくつかの違いがあります。
まず、 texconfig.objectinitexジョブ構成を使用します。これは、エンジンの状態「Virgin」を離れる特別な構成です。つまり、内部パラメーターにはデフォルト値があり、コントロールシーケンスのセットはプリミティブのセットと一致します。私たちの例では、プリミティブのセットは、 ここに言及された意味で拡張されます。
次に、通常どおり、入力および出力作業ディレクトリを設定します。入力作業ディレクトリには、メイン形式のソースファイルとそのすべての依存関係を含める必要があります。
そして、2番目の重要な違いは、私たちが仕事をする方法です。今回は、static createformat()メソッドを使用します。これは、オプションとともにメインソースファイルの名前を取得し、形式名と同じでなければなりません。
カスタム形式でTEXファイルを植林します
独自のTex形式ができたので、この形式で記述されたTexファイルを整形したいと考えています。これがコードです:
1// Create the file system input working directory.
2// Create the format provider using the file system input working directory.
3// We use the project output directory as our custom format file is supposed to be located there.
4using (FormatProvider formatProvider =
5 new FormatProvider(new InputFileSystemDirectory(RunExamples.OutputDirectory), "customtex"))
6{
7 // Create conversion options for a custom format upon ObjectTeX engine extension.
8 TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX(formatProvider));
9 options.JobName = "typeset-with-custom-format";
10 // Specify the input working directory. This is not required here as we are providing the main input as a stream.
11 // But it is required when the main input has dependencies (e.g. images).
12 options.InputWorkingDirectory = new InputFileSystemDirectory(RunExamples.InputDirectory);
13 // Specify a file system working directory for the output.
14 options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
15
16 // Run the job.
17 new TeXJob(new MemoryStream(Encoding.ASCII.GetBytes(
18 "Congratulations! You have successfully typeset this text with your own TeX format!\\end")),
19 new XpsDevice(), options).Run();
20
21 // For further output to look fine.
22 options.TerminalOut.Writer.WriteLine();
23}
明らかに、形式を何らかの形で指定する必要があります。まず、 formatproviderクラスのインスタンスを作成する必要があります。次に、オプションコンストラクターで texconfig.objecttex()構成を使用します。これは、フォーマットプロバイダーを引数として受け取り、エンジンの「処女」状態の上に形式をロードします。
残りのコードはあなたに馴染みがあるはずです。この ガイドで前述した機能を使用します。
Plain Tex形式でTexファイルを植林します
実証されたコードからフォーマットプロバイダーを捨てると、エンジンはデフォルト形式をロードします。これは オブジェクトTexである4番目の意味でです。したがって、Plain Tex形式でTexファイルが書かれている場合、この方法では、サポートされているターゲット形式に変換できます。