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 を使うと、新しいドキュメントを作成できます。

ドキュメントの保存

to: はブロックが終わるとドキュメントを保存します。拡張子によって形式が決まり、パスのリストを指定すると複数の形式で保存されます:

<KScript.Document title="Notes" to="notes.pdf, notes.docx, notes.tex">
  <Paragraph>Saved three ways.</Paragraph>
</KScript.Document>
import KScript.Document

Document(title: 'Notes', to: ['notes.pdf', 'notes.docx', 'notes.tex']) {
  Paragraph "Saved three ways."
}
拡張機能 できること
.pdf KScriptでレイアウトされたPDFです。ページ番号、クリック可能な目次とブックマーク、リンク、画像を含みます。
.docx 見出し、番号付きリスト、脚注、Word で編集できる数式、Word が自動で入力する目次を備えた実際の Word 文書です。
.tex pdflatex、\section、\label/\ref、amsmath、booktabs、\bibitemを使った LaTeX ファイルです。画像はパスで参照されます。
.md 数式 $...$、GitHub 形式の表、脚注に対応した Markdown。
.html 1つの HTML ページです。スタイル、MathML の数式、画像をすべて含みます。

into:の代わりに(あるいは加えて)、ドキュメントを変数に保持するため、後で保存したりテキストに変換したりできます:

<import package="KScript.Document" />

<Document title="Report" into="doc">
  <Paragraph>Hello.</Paragraph>
</Document>
<do>$doc->save('report.pdf')</do>
<echo>{ $doc->pages() } pages, { $doc->words() } words</echo>
import KScript.Document

Document(title: 'Report', into: doc) {
  Paragraph "Hello."
}
$doc->save('report.pdf')
echo "{ $doc->pages() } pages, { $doc->words() } words"
メソッド 機能
->save(path, as?) ファイル名の拡張子、またはas:で選択された形式で保存します。
->pages() PDFのページ数です。
->words() 数式とコードを除いて、テキストの単語数です。
->convert(to: markdown)、->convert(to: latex)、->convert(to: html) ご自身で印刷、送信、または保存するためのテキスト版のドキュメントです。
->bytes(as: pdf|docx|html) ファイルに書き出さず、レンダリング結果を base64 の値として返します。

$doc.title はタイトルです。

ルートは、ドキュメントを保存せずに送信できます。->bytes(as: pdf) はメモリ上でそれをレンダリングし、@response() はそのバイト列を送信します:

<import package="KScript.Http" />
<import package="KScript.Document" />

<fn name="invoice" params="id: int">
  <Document title="Invoice { $id }" into="doc">
    <Paragraph>Thank you for your order.</Paragraph>
  </Document>
  <return value="@response($doc->bytes(as: pdf), type: 'application/pdf', headers: { 'Content-Disposition': &quot;inline; filename=invoice-{ $id }.pdf&quot; })" />
</fn>
import KScript.Http
import KScript.Document

fn invoice(id: int) {
  Document(title: "Invoice { $id }", into: doc) {
    Paragraph "Thank you for your order."
  }
  return @response($doc->bytes(as: pdf), type: 'application/pdf', headers: { 'Content-Disposition': "inline; filename=invoice-{ $id }.pdf" })
}

ソースからのドキュメント

Markdown または LaTeX のフェンスは、インポートなしで markdown または latex の値を作成します。.text はそのソースで、.extension はそのファイル拡張子です。以下のメソッドを使うには KScript.Document をインポートしてください。@document(source) はフェンスをドキュメントに変換します。LaTeX のソースを文字列にする場合は as: latex を使います。単純な文字列の既定値は Markdown です。

<import package="KScript.Document" />

<fn name="notes" value="```md
    # Notes
    Ship *soon*.
    ```" />

<fn name="paper" value="```latex
    \section{Draft}
    ```" />

<echo value="@notes()->convert(to: html)" />
<do>@notes()->save('notes.pdf')</do>
<do>@paper()->replace('Draft', 'Final')->save('paper')</do>
import KScript.Document

fn notes() => ```md
  # Notes
  Ship *soon*.
  ```

fn paper() => ```latex
  \section{Draft}
  ```

echo @notes()->convert(to: html)
@notes()->save('notes.pdf')
@paper()->replace('Draft', 'Final')->save('paper')

どちらの種類のフェンスも、最初のソースオフセットには->find(text)、一致するリテラルごとには->replace(search, replacement)、テキストまたは同じ形式のフェンスを挿入するには->insert(content, at?)を使います。オフセットはゼロベースで、省略すると末尾に追加されます。これらのメソッドは、編集ごとに新しい値を返します。パスが.mdまたは.texで終わるか、拡張子がない場合は、->save(path, as?)でソースを書き込みます。

Markdownのフェンスは、それ自体がドキュメントです。->convert(to: html)、->convert(to: latex)、->words()、->pages()を持ち、->save()はパスの拡張子またはas:に従って、PDF、Word、LaTeX、HTMLとしてレンダリングします。

LaTeX のフェンスも文書です。->convert(to: html)、->convert(to: markdown)、->words()、->pages() を持ち、->save('paper.pdf') または ->save('paper.docx') でレンダリングします。KScript は 文書パート が読むのと同じ LaTeX を読みます。つまりセクション、段落、リスト、数式、引用、図、一般的な文章コマンドです。読めないコマンドはエラーとなり、フェンスのレンダリング時にその名前を示します。->save('paper.tex') を使うと、pdflatex などの LaTeX エンジン向けに LaTeX をそのまま残せます。

テンプレート

テンプレートは文書全体の見た目です。template: で全体の見た目を選びます。その後は ページとスタイル のすべての設定で変更できます。

テンプレート 概要
plain 既定値:セリフ体の本文、番号付きのセクション、上部にタイトル。
paper 科学論文:中央揃えのタイトル、所属を付記した著者名、要旨、字下げされた段落、番号付きの数式および参考文献。
report タイトルページ、目次、色付きのサンセリフ見出し、トップレベルの各セクションを新しいページに配置し、タイトルとページ番号を入れたフッターを付けます。
letter Letter要素と併せて使用します:住所、日付、件名、挨拶文、署名。
invoice Invoice 要素と併用します: 住所、請求書の詳細、税額と合計を含む品目表。

@document_templates() がそれらを一覧表示します。

テキストの記述

Paragraph、Item、キャプションおよびタイトルで使用できるテキストは以下のとおりです:

書き方 for
**bold**, *italic* 太字と斜体(__bold__ と _italic_ も)。
`code` コード。
[text](https://...) リンク:ウェブアドレス、mailto:、またはスキームを持たないファイルや#placeです。javascript:などのその他の内容はテキストのまま残ります。
\( x^2 \) 行内の数式。\[ ... \] も使えます。
[@key], [@a; @b] 参考文献にある資料の引用です。
[#id] idで示される節、表、図、または式の番号を示す相互参照です。
^[text] 脚注です。
--, --- en ダッシュと em ダッシュ。

テキスト内の空白行は新しい段落を開始します。{ }は、KScriptの他の場所と同様に値を挿入します。$nameは変数を挿入するため、数式では$ではなく\( \)を使用します。\( \)の内側では、中括弧はLaTeX用に残されます。\( \frac{1}{2} \)は分数であり、KScriptではありません。

Paragraph(lines: true) は、住所や詩のように改行を保持します。align:(left、center、right、justify)は、ドキュメントの配置を上書きします。

構造

<KScript.Document template="report" title="Annual Report" author="The team" to="'report.pdf'">
  <Contents />

  <Section title="Summary" id="summary">
    <Paragraph>Visits rose every quarter.</Paragraph>

    <Section title="Details">
      <List style="number">
        <Item>First point.</Item>
        <Item>Second point.</Item>
        <List>
          <Item>A point under the second.</Item>
        </List>
      </List>
    </Section>
  </Section>

  <Section title="Appendix" numbered="false" new_page="true">
    <Quote by="John Conway">I'm not a mathematician who's interested in applications.</Quote>
    <Code language="python">print('hello')</Code>
  </Section>
</KScript.Document>
import KScript.Document

Document(template: report, title: 'Annual Report', author: 'The team', to: 'report.pdf') {
  Contents

  Section(title: 'Summary', id: 'summary') {
    Paragraph "Visits rose every quarter."

    Section(title: 'Details') {
      List(style: number) {
        Item "First point."
        Item "Second point."
        List {
          Item "A point under the second."
        }
      }
    }
  }

  Section(title: 'Appendix', numbered: false, new_page: true) {
    Quote(by: 'John Conway') "I'm not a mathematician who's interested in applications."
    Code(language: 'python') "print('hello')"
  }
}
要素 概要
Author(affiliation, email) 作成者です。テキストは名前になります。または文書にauthor: "Ada Lovelace; Alan Turing"を指定してください。
Abstract タイトルの下の概要です。
Section(title, id, numbered, new_page) セクションです。セクションの中にあるセクションはサブセクションとなり、六階層まで使えます。七階層目はエラーになります。
Paragraph(id, align, lines) 段落です。
List(style, start) と Item リスト: bullet、number、letter、またはroman。Itemの直後にあるListは、その中にネストされます。
Quote(by) ブロック引用です。
Code(language) 書かれたとおりに保持される、等幅フォントのコードです。
Contents(title, depth) PDF内のページ番号を付けた目次です。
Markdown(path) テキストまたはファイルから Markdown を作成します: 下記を参照。
Latex(path, value) テキスト、latex の値、または .tex ファイルから LaTeX を作成します: 下記を参照。
PageBreak, VSpace(height), Rule 新しいページ、VSpace(height: '1cm')のような隙間、そしてページを横切る線。

数式

Math は独立した行の数式です。その本文は LaTeX で、書かれたとおりに保持されるため、波括弧やバックスラッシュをエスケープする必要はありません。長い数式は ```latex ブロックで複数行にまたがって記述できます。長い Paragraph では行末に \ を付けられます(長い文字列とテキストのブロックを参照)。数式には番号が付きます。id: を使うと、本文から [#id] でその番号を参照できます:

<KScript.Document title="Maths" to="'maths.pdf'">
  <Math id="eq-gauss">\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}</Math>
  <Math numbered="false">\sum_{k=1}^{n} k = \frac{n(n+1)}{2}</Math>
  <Math>A = \begin{pmatrix} a &amp; b \\ c &amp; d \end{pmatrix}, \quad \det A = ad - bc</Math>
</KScript.Document>
import KScript.Document

Document(title: 'Maths', to: 'maths.pdf') {
  Math(id: 'eq-gauss') "\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}"
  Math(numbered: false) "\sum_{k=1}^{n} k = \frac{n(n+1)}{2}"
  Math "A = \begin{pmatrix} a & b \\\\ c & d \end{pmatrix}, \quad \det A = ad - bc"
}

KScriptで"..."文字列の中では、\\とすると円記号(バックスラッシュ)1つを表します。そのため、LaTeXの改行\\は\\\\と書きます。環境の中で改行すると、その時点で行も区切られます:

<KScript.Document title="Cases" to="'cases.pdf'">
  <Math>|x| = \begin{cases}
    x &amp; \text{if } x \ge 0
    -x &amp; \text{otherwise}
  \end{cases}</Math>
</KScript.Document>
import KScript.Document

Document(title: 'Cases', to: 'cases.pdf') {
  Math "|x| = \begin{cases}
    x & \text{if } x \ge 0
    -x & \text{otherwise}
  \end{cases}"
}

数学が理解するもの:

  • 英字、数字、演算子を TeX の間隔で表示します。上付き文字は ^、下付き文字は _、プライムは ' を使います。
  • \frac, \dfrac, \tfrac, \binom, \sqrt, \sqrt[n].
  • ギリシャ文字(\alphaから\Omegaまで)、関係子(\le、\approx、\in、\subseteq、\to...)、演算子(\pm、\times、\cdot、\cup...)、矢印、および\infty、\partial、\nabla、\forall、\existsなどの記号。
  • 上限と下限を持つ大型演算子: \sum, \prod, \int, \iint, \oint, \bigcup...; 関数として \sin, \log, \lim, \max, \operatorname{name}。
  • \left( ... \right) やその他の区切り文字は、内容に合わせて大きくなります。
  • matrix、pmatrix、bmatrix、vmatrix、cases、aligned、array 環境。
  • \text{...}、\mathbf、\mathit、\mathrm、\mathbb、\mathcal、\mathsf、\mathtt。アクセント記号(\hat、\bar、\vec、\dot、\tilde、\overline、\underline)、および空白(\,、\;、\quad、\qquad)。

未知のコマンドはエラーとなり、そのコマンド名が表示されるため、タイプミスは完成したPDFではなく、スクリプトの実行時に検出されます。各形式には、その形式に合った数式が使われます。PDFでは描画され、LaTeXではamsmath、.docxではWord数式、HTMLではMathMLになります。

表

テーブルはデータから作成できます。通常はマップのリストです:

<let name="people" value="[{ name: 'Ada', born: 1815 }, { name: 'Alan', born: 1912 }]" />

<import package="KScript.Document" />

<Document title="People" to="'people.pdf'">
  <Table caption="Two mathematicians." id="tab-people" rows="$people" columns="{ Name: 'name', Born: 'born' }" align="['left', 'right']" />
</Document>
$people = [{ name: 'Ada', born: 1815 }, { name: 'Alan', born: 1912 }]

import KScript.Document

Document(title: 'People', to: 'people.pdf') {
  Table(caption: 'Two mathematicians.', id: 'tab-people', rows: $people, columns: { Name: 'name', Born: 'born' }, align: ['left', 'right'])
}

columns: は、見出しからキーへの対応表です(見出しとしてのキーのリストでも構いません)。これを省略すると、最初の対応表のキーが列になります。行のフィールドが既知の場合、たとえばスクリプト内に記述された対応表のリストやモデルのレコードでは、エディタがキーを補完し、kscript check は行に存在しないキーを報告します。数値は、align: で別の指定がない限り右揃えになります。

または、行をTrで、セルを|で区切って書きます:

<KScript.Document title="Scores" to="'scores.pdf'">
  <Table caption="Scores." align="['left', 'right', 'right']" widths="[3, 1, 1]" rules="grid">
    <Tr header="true">Team | Played | Points</Tr>
    <Tr>Red | 3 | 7</Tr>
    <Tr>Blue | 3 | **9**</Tr>
  </Table>
</KScript.Document>
import KScript.Document

Document(title: 'Scores', to: 'scores.pdf') {
  Table(caption: 'Scores.', align: ['left', 'right', 'right'], widths: [3, 1, 1], rules: grid) {
    Tr(header: true) "Team | Played | Points"
    Tr "Red | 3 | 7"
    Tr "Blue | 3 | **9**"
  }
}

widths: は、テーブルの幅をテキストの幅に合わせ、その比率に従って幅を配分します。指定しない場合、列の幅はそれぞれのテキストの幅になります。rules: は booktabs(ヘッダーの上、下、および下線を含む、横線付き。既定値)、grid、または none です。size: 0.9 を指定すると、テキストが小さくなります。キャプションはテーブルに番号を付けます。また、テーブルが新しいページにまたがるとき、見出し行が繰り返し表示されます(LaTeX では、同じ理由から、30行を超えるテーブルは longtable になります)。行のないテーブルは、LaTeX および Markdown ファイルから除外されます。

図

<KScript.Document title="Gliders" to="'gliders.pdf'">
  <Figure path="glider.png" caption="A glider over four generations." id="fig-glider" width="0.8" />
</KScript.Document>
import KScript.Document

Document(title: 'Gliders', to: 'gliders.pdf') {
  Figure(path: 'glider.png', caption: 'A glider over four generations.', id: 'fig-glider', width: 0.8)
}

path:は、スクリプトを基準とした相対パスのPNGまたはJPEGです。width:は、テキスト幅に対する割合です(0.5または'50%')。キャプション付きの図には、[#id]の番号が付けられます。

引用と参考文献

[@key]を使用して引用します。出典は、BibTeXファイル、Source要素、またはその両方から取得されます:

<KScript.Document template="paper" title="Cited" to="'cited.pdf'">
  <Paragraph>Life is universal [@berlekamp1982; @rendell2002].</Paragraph>

  <Bibliography path="refs.bib">
    <Source id="rendell2002" type="inproceedings" author="Paul Rendell" title="Turing Universality of the Game of Life" booktitle="Collision-Based Computing" year="2002" />
  </Bibliography>
</KScript.Document>
import KScript.Document

Document(template: paper, title: 'Cited', to: 'cited.pdf') {
  Paragraph "Life is universal [@berlekamp1982; @rendell2002]."

  Bibliography(path: 'refs.bib') {
    Source(id: 'rendell2002', type: 'inproceedings', author: 'Paul Rendell', title: 'Turing Universality of the Game of Life', booktitle: "Collision-Based Computing", year: 2002)
  }
}

引用された文献のみが一覧に掲載されます。citations: numeric(既定)を使用すると、初めて引用された順に[1]のように番号が付けられます。citations: author-yearを使用すると、(Berlekamp et al., 1982)の形式で表示され、一覧は著者順に並べられます。Sourceでは、任意のBibTeXフィールドを属性として指定できます。authorでは、人物をandで区切ります。文献を引用しているもののBibliographyを省略した場合、参考文献は末尾に配置されます。

存在しない id を指す引用や相互参照はエラーです。同じ id が二度使われている場合も、エラーになります。id: は他のテキストと同じ扱いなので、ループで各項目に対して作成することができます: Section(title: $chapter.title, id: "ch-{ $chapter.number }")。

脚注と相互参照

^[text] は、ページの下部に番号付きの脚注を配置します(Word では実際の脚注になり、HTML と Markdown では文書の末尾に注釈として配置されます)。[#id] は、指定した id を持つセクション、表、図、または数式の番号に置き換えられるため、語句は自分で記述します。Section [#methods] は「Section 2」、Equation [#eq-speed] は「Equation (3)」と表示されます。PDF と Word では、番号がリンクになります。

Markdown

MarkdownはMarkdownを文書の内容として追加します。#見出しは(レベルに応じてネストされた)セクションになり、段落、リスト、表、コードブロック、引用、---罫線、![caption](image.png){#id}図を含めることができます。見出しと数式にはidを付けられます:## Results {#results}、\[ E = mc^2 \] {#eq-energy}。

<KScript.Document title="From Markdown" to="'notes.pdf'">
  <Markdown path="chapters/introduction.md" />
  <Markdown>
    ## Summary

    - Every chapter is a Markdown file.
    - The script puts them together.
  </Markdown>
</KScript.Document>
import KScript.Document

Document(title: 'From Markdown', to: 'notes.pdf') {
  Markdown(path: 'chapters/introduction.md')
  Markdown "
    ## Summary

    - Every chapter is a Markdown file.
    - The script puts them together.
  "
}

Markdownファイルでは、$x$と$$ ... $$も数式として扱われます。スクリプト内のテキストでは、\( \)と\[ \]を使用してください。そこでは$は変数になるためです。

LaTeX

Latex は LaTeX を文書の内容として追加し、文書パート と同じように読み込みます。本文はそのまま使われるため、波括弧やバックスラッシュは LaTeX のものです。value: を使って latex の値を渡すことも、path: を使って .tex ファイルを渡すこともできます。

  <import package="KScript.Document" />

  <fn name="method" value="```latex
      \subsection{Method}
      We counted \textbf{gliders} by hand.
      ```" />

  <Document title="From LaTeX" to="paper.pdf">
    <Latex>\section{Results}
Gliders travel \emph{diagonally}, and $N(t) = N_0 e^{rt}$.</Latex>
    <Latex value="@method()" />
    <Latex path="chapters/discussion.tex" />
  </Document>
import KScript.Document

fn method() => ```latex
  \subsection{Method}
  We counted \textbf{gliders} by hand.
  ```

Document(title: "From LaTeX", to: "paper.pdf") {
  Latex ```latex
    \section{Results}
    Gliders travel \emph{diagonally}, and $N(t) = N_0 e^{rt}$.
    ```
  Latex(value: @method())
  Latex(path: "chapters/discussion.tex")
}

読み取れないコマンドは、そのコマンド名を示すエラーになります。

コンポーネントとしてのパーツ

所見、方法、署名欄などのように複数の文書で使うパーツは、コンポーネントにできます。その render は文書要素を保持するか、md または latex ブロックとしてパーツを返します。文書は名前で呼び出して描画します: Finding(title: 'Gliders', count: 3)。

手紙と請求書

Letter は、その中にある段落を中心に手紙のレイアウトを整えます。住所では、\n によって新しい行が始まります:

<KScript.Document template="letter" to="'letter.pdf'">
  <Letter from="{'Life Lab\n12 Grid Street\nCambridge'}" to="{'Dr Ada Lovelace\nExample University'}" subject="Invitation to speak" opening="Dear Dr Lovelace," closing="Yours sincerely," signature="Alan Turing">
    <Paragraph>We would be delighted if you would give the opening talk.</Paragraph>
  </Letter>
</KScript.Document>
import KScript.Document

Document(template: letter, to: 'letter.pdf') {
  Letter(from: 'Life Lab\n12 Grid Street\nCambridge', to: 'Dr Ada Lovelace\nExample University', subject: 'Invitation to speak', opening: 'Dear Dr Lovelace,', closing: 'Yours sincerely,', signature: 'Alan Turing') {
    Paragraph "We would be delighted if you would give the opening talk."
  }
}

Invoice は項目のリストから請求書全体を作成します。各項目には description、quantity(既定値は 1)、そして price または amount があります。小計、税額、合計は自動で計算されます:

<let name="items" value="[{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]" />

<import package="KScript.Document" />

<Document template="invoice" to="'invoice.pdf'">
  <Invoice number="INV-042" from="{'Life Lab Ltd\n12 Grid Street'}" to="Example University" due="20 December 2026" items="$items" currency="GBP" tax="20" notes="Please pay within 30 days." />
</Document>
$items = [{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]

import KScript.Document

Document(template: invoice, to: 'invoice.pdf') {
  Invoice(number: 'INV-042', from: 'Life Lab Ltd\n12 Grid Street', to: 'Example University', due: '20 December 2026', items: $items, currency: 'GBP', tax: 20, notes: 'Please pay within 30 days.')
}

currency:は、GBP、USD、EUR、JPYなどのコード、または任意の記号です。tax:はパーセンテージ、tax_name:はその名称(既定のVAT)、paid:は支払い済みの金額で、これにより未払い残高が加算されます。

ページとスタイル

これらはDocumentに設定され、テンプレートセットの内容を変更します:

属性 機能
paper a4(既定値)、a3、a5、b5、letter、legal、または'15cm x 20cm'のように引用符で囲んだサイズを指定できます。landscape: trueで有効になります。
margin 1つのサイズ('2.5cm')、または'2cm 3cm'(上下、左右)、またはCSSのように4つのサイズを指定できます。サイズはmm、cm、in、ptのいずれかで、引用符で囲んで指定します。
font, heading_font serif(Times)、sans(Helvetica)、またはmono(Courier)。
size, line_height 文字サイズ(ポイント単位、11)と、それに対する行間の倍率(1.4)です。
align justify、left、center、またはright。
accent 見出しとタイトルページの色(引用符付き):'#1f4e79' または 'navy' などの名前。
numbered false は番号のないセクションを残します。
title_page, chapters trueはタイトルを独立したページに配置し、トップレベルの各セクションを新しいページから始めます。
citations numeric または author-year。
header, footer 'left | centre | right'、[page]、[pages]、[title]、[author]、[date]と併用できます。footer: '| Page [page] of [pages] |'はページ数を中央に配置します。footer: ''にはありません。
rules 既定の表の罫線: booktabs、grid、またはnone。
language テキストの言語です。例えば 'en-GB' のように指定します。Word のスペルチェックや HTML で使われます。

フォントと文字

このPDFは、どのPDFリーダーにも備わっているフォント(Times、Helvetica、Courier、Symbol)を使用するため、フォントは埋め込まれず、ファイルサイズは小さく抑えられます。これらのフォントは、西ヨーロッパの言語、基本的なギリシャ文字、および数学記号に対応しています。中国語、絵文字、アクセント付きのギリシャ文字(ά)など、これら以外の文字はPDFでは?と表示されます。Word、HTML、Markdown、LaTeXのファイルでは、これらの文字もそのまま保持されます。

コマンド

コマンド 機能
@latex_escape(text) LaTeXファイルに安全に入れられるように変換されたテキストです。\ { } $ & % # _ ~ ^ はエスケープされています。
@document_templates() テンプレートと、それぞれの用途です。