KScript ドキュメント
JA

言語

英語から自動翻訳されています。原文は英語です。

ドキュメント: KScript.Document

はじめに

KScript.Documentは、論文、報告書、手紙、請求書などの科学・ビジネス文書を作成します。1つのスクリプトで、同じ文書をPDF、Word(.docx)、LaTeX(.tex)、Markdown、HTMLとして保存できます。LaTeXの数式、番号付きの節、表と図、BibTeXからの引用、脚注、相互参照に対応しています。PDFはKScript自体が生成するため、TeX、Word、その他のソフトウェアをインストールする必要はありません。

<KScript.Document template="paper" title="How Gliders Move" author="Ada Lovelace" to="'gliders.pdf'">
  <Abstract>A glider returns to its own shape every \( p = 4 \) generations, one cell further on.</Abstract>

  <Section title="Introduction">
    <Paragraph>The Game of Life [@gardner1970] is played on a square grid. Each cell has **eight neighbours**.</Paragraph>

    <Math id="eq-speed">v = \frac{\max(|\Delta x|, |\Delta y|)}{p} \, c</Math>

    <Paragraph>Equation [#eq-speed] gives a pattern's speed.</Paragraph>
  </Section>

  <Bibliography>
    <Source id="gardner1970" type="article" author="Martin Gardner" title="Mathematical Games" journal="Scientific American" year="1970" />
  </Bibliography>
</KScript.Document>
import KScript.Document

Document(template: paper, title: 'How Gliders Move', author: 'Ada Lovelace', to: 'gliders.pdf') {
  Abstract "A glider returns to its own shape every \( p = 4 \) generations, one cell further on."

  Section(title: 'Introduction') {
    Paragraph "The Game of Life [@gardner1970] is played on a square grid. Each cell has **eight neighbours**."

    Math(id: 'eq-speed') "v = \frac{\max(|\Delta x|, |\Delta y|)}{p} \, c"

    Paragraph "Equation [#eq-speed] gives a pattern's speed."
  }

  Bibliography {
    Source(id: 'gardner1970', type: 'article', author: 'Martin Gardner', title: 'Mathematical Games', journal: "Scientific American", year: 1970)
  }
}

はじめるには、import KScript.Documentを使います。これはDocumentと、その中に入れる要素を読み込みます。Documentブロック内はすべて通常のKScriptなので、要素の間でfor、if、変数や関数を使えます。たとえば、表をデータから生成したり、リストの各項目についてセクションを繰り返したりできます。

samples/documents フォルダーには、論文、報告書、手紙、請求書の完全なサンプルがあります。kscript make document を使うと、新しいドキュメントを作成できます。