LaTex:演習
列に古い子の加算と減算の例を与えるために、例付きのLaTeXを生成するGroovyスクリプトを書きました。
目標は、手作業で例を書くのにうんざりして、溝を練習することでした。
以前、私はラテックスで何も書いていませんでしたが、Univerからそれが何であり、なぜそれが必要なのかを知っていました。
2時間の間、LaTeXで目的のタイプの列を作成する方法に夢中でした。
LaTeXを使用するために、CygWinから適切なパッケージをインストールしました。
スクリプトは次のとおりです。誰かが役に立つといいのですが。
////////////////////////////////////////////////////
int n = 30
def f1 = new File("d:\\temp\\ex.tex")
def f2 = new File("d:\\temp\\sol.tex")
/////////////////////////////////////////////////////
def r = new Random(System.currentTimeMillis())
f1.delete();
f2.delete();
def header = """
\\documentclass[a4paper,12pt,twocolumn]{article}
\\begin{document} \n"""
f1<< header
f2<< header
n.times {
int a = r.nextInt(10000)
int b = r.nextInt(10000)
boolean plus = r.nextBoolean()
if (a<b) { def t =a; a= b; b = t}
int c = plus?a+b:ab
def sign = plus?"+":"-"
f1<< """\$\$ \\frac{$sign \\begin{array}{rcc}
$a \\\\
$b
\\end{array}}{} \$\$\n"""
f2<< """\$\$ \\frac{$sign \\begin{array}{rcc}
$a \\\\
$b
\\end{array}}{$c} \$\$\n"""
}
def footer = """
\\end{document} \n"""
f1<<footer
f2<<footer
これは次のようなものです。

PS最適なブログは開発のようです。 または、他の人に転送しますか?
Source: https://habr.com/ru/post/J108431/
All Articles