KScript 문서
KO

언어

영어에서 자동 번역되었습니다. 원문은 영어입니다.

문서: KScript.Document

표

테이블은 데이터에서 만들 수 있으며, 데이터는 보통 맵의 목록이에요:

<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 파일에서 제외됩니다.