Orgmode-수직 헤더

Sep 12 2020

조직 모드에서도 세로 헤더를 만들 수 있습니까?

다음과 같은 것 (청록색 필드) :

다음과 같이 수평 헤더를 만들 수 있습니다.

| Header  | Header  | Header  | Header  | Header  |
|---------+---------+---------+---------+---------|
| Content | Content | Content | Content | Content |

하지만 수직 헤더도 원합니다.

| Header | Header  | Header  | Header  | Header  |
|--------+---------+---------+---------+---------|
| Header | Content | Content | Content | Content |
| Header | Content | Content | Content | Content |

그 이유는 HTML로 내보내고 싶기 때문입니다.

HTML은 다음과 같습니다.

<table border="2" cellpadding="6" cellspacing="0" frame="hsides" rules="groups">
        <colgroup>
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
        </colgroup>
        <thead>
            <tr>
                <th class="org-right" scope="col">.</th>
                <th class="org-right" scope="col">1</th>
                <th class="org-right" scope="col">2</th>
                <th class="org-right" scope="col">3</th>
                <th class="org-right" scope="col">4</th>
                <th class="org-right" scope="col">5</th>
                <th class="org-right" scope="col">6</th>
                <th class="org-right" scope="col">7</th>
                <th class="org-right" scope="col">8</th>
                <th class="org-right" scope="col">9</th>
                <th class="org-right" scope="col">10</th>
                <th class="org-right" scope="col">11</th>
                <th class="org-right" scope="col">12</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class="org-right">1</td>
                <td class="org-right">1</td>
                <td class="org-right">2</td>
                <td class="org-right">3</td>
                <td class="org-right">4</td>
                <td class="org-right">5</td>
                <td class="org-right">6</td>
                <td class="org-right">7</td>
                <td class="org-right">8</td>
                <td class="org-right">9</td>
                <td class="org-right">10</td>
                <td class="org-right">11</td>
                <td class="org-right">12</td>
            </tr>
        </tbody>
    </table>

세로 헤더를 지원하는 경우 다음과 같아야합니다.

<table border="2" cellpadding="6" cellspacing="0" frame="hsides" rules="groups">
        <colgroup>
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
            <col class="org-right">
        </colgroup>
        <thead>
            <tr>
                <th class="org-right" scope="col">.</th>
                <th class="org-right" scope="col">1</th>
                <th class="org-right" scope="col">2</th>
                <th class="org-right" scope="col">3</th>
                <th class="org-right" scope="col">4</th>
                <th class="org-right" scope="col">5</th>
                <th class="org-right" scope="col">6</th>
                <th class="org-right" scope="col">7</th>
                <th class="org-right" scope="col">8</th>
                <th class="org-right" scope="col">9</th>
                <th class="org-right" scope="col">10</th>
                <th class="org-right" scope="col">11</th>
                <th class="org-right" scope="col">12</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th class="org-right">1</th>
                <td class="org-right">1</td>
                <td class="org-right">2</td>
                <td class="org-right">3</td>
                <td class="org-right">4</td>
                <td class="org-right">5</td>
                <td class="org-right">6</td>
                <td class="org-right">7</td>
                <td class="org-right">8</td>
                <td class="org-right">9</td>
                <td class="org-right">10</td>
                <td class="org-right">11</td>
                <td class="org-right">12</td>
            </tr>
        </tbody>
    </table>

노트 th번째 코드 블록의 대신에 요소 td상의 소자 tbody. JavaScript로이 작업을 수행 할 수 있다는 것을 알고 있지만 org-mode이미 지원할 수 있는지 알고 싶습니다. 이렇게하면 작업이 훨씬 쉬워집니다.

답변

NickD Sep 12 2020 at 04:46

첫 번째 열을 "헤더"열로 만들기 위해해야 ​​할 일은

(setq org-html-table-use-header-tags-for-first-column t)

전역 적으로 또는 로컬 파일 변수로 :

# Local Variables:
# org-html-table-use-header-tags-for-first-column: t
# End:

AFAIK, 테이블별로 지정할 수는 없습니다.

예를 들면 :

* Multiplication table

  #+ATTR_HTML: :border 3 :rules all :frame border
  |  . |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |   9 |  10 |
  |----+----+----+----+----+----+----+----+----+-----+-----|
  |  1 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |   9 |  10 |
  |  2 |  2 |  4 |  6 |  8 | 10 | 12 | 14 | 16 |  18 |  20 |
  |  3 |  3 |  6 |  9 | 12 | 15 | 18 | 21 | 24 |  27 |  30 |
  |  4 |  4 |  8 | 12 | 16 | 20 | 24 | 28 | 32 |  36 |  40 |
  |  5 |  5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 |  45 |  50 |
  |  6 |  6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 |  54 |  60 |
  |  7 |  7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 |  63 |  70 |
  |  8 |  8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 |  72 |  80 |
  |  9 |  9 | 18 | 27 | 36 | 45 | 54 | 63 | 72 |  81 |  90 |
  | 10 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |  90 | 100 |
  #+TBLFM: @2$2..@>$> = @1$0 * @0$1


* Local variables                                      :noexport:
# Local Variables:
# org-html-table-use-header-tags-for-first-column: t
# End:

표시 한 그대로 HTML로 내보내집니다 (색상 제외).

다른 변수에 대해서는 매뉴얼의 HTML 내보내기 의 테이블 섹션을 참조 하되 #+ATTR_HTML구문에 유의하십시오 . 위의 Org 모드의 최신 버전에 대해 보여준 것과 같지만 매뉴얼에는 이전 구문이 표시됩니다.

 #+ATTR_HTML: border="2" rules="all" frame="border"

버전에 따라 여전히 사용해야 할 수도 있습니다. 문서에 대한 버그를 열겠습니다.


[이전 답변 : 다음은 질문에 대한 답이 아니지만 여기에 남겨두면 충분히 흥미로울 수 있습니다.]

다음과 같은 것을 의미하는 경우 :



* Multiplication table


  |  . |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |   9 |  10 |  11 |  12 |
  |  1 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |   9 |  10 |  11 |  12 |
  |  2 |  2 |  4 |  6 |  8 | 10 | 12 | 14 | 16 |  18 |  20 |  22 |  24 |
  |  3 |  3 |  6 |  9 | 12 | 15 | 18 | 21 | 24 |  27 |  30 |  33 |  36 |
  |  4 |  4 |  8 | 12 | 16 | 20 | 24 | 28 | 32 |  36 |  40 |  44 |  48 |
  |  5 |  5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 |  45 |  50 |  55 |  60 |
  |  6 |  6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 |  54 |  60 |  66 |  72 |
  |  7 |  7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 |  63 |  70 |  77 |  84 |
  |  8 |  8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 |  72 |  80 |  88 |  96 |
  |  9 |  9 | 18 | 27 | 36 | 45 | 54 | 63 | 72 |  81 |  90 |  99 | 108 |
  | 10 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |  90 | 100 | 110 | 120 |
  | 11 | 11 | 22 | 33 | 44 | 55 | 66 | 77 | 88 |  99 | 110 | 121 | 132 |
  | 12 | 12 | 24 | 36 | 48 | 60 | 72 | 84 | 96 | 108 | 120 | 132 | 144 |
  #+TBLFM: @2$2..@>$> = @1$0 * @0$1

대답은 단호한 '예'입니다.

다음과 같은 지침으로 테이블을 만들었습니다.

  • M-x org-create-table RET 1x13 RET: 13 개의 행이있는 단일 열 테이블을 만듭니다.
  • 입력 ., 첫 번째 행에 1계속 입력 한 후 두 번째 행과 S-<Enter>행의 나머지 부분을 채우기 위해.
  • M-x org-table-transpose-table-at-point RET 단일 행 테이블로 만듭니다.
  • 를 눌러 TAB두 번째 행을 만들고 첫 번째 열로 이동합니다.
  • 입력 1계속 입력 한 후 두 번째 행의 첫 번째 열에 및 S-<Enter>해당 열의 나머지 부분을 작성.

이제 첫 번째 열과 첫 번째 행이 표에 표시된 내용으로 채워집니다. 이제 위와 같이 표 아래에 표 수식을 추가하고 키를 누릅니다 C-c C-c. 나머지 표가 채워집니다 (사전에 Calc를 활성화해야합니다 : 입력 M-x calc RET q을 수행합니다).

표 공식은 다음과 같습니다. 표의 다른 모든 셀 (2 행에서 마지막으로, 2 열에서 마지막으로)을 (1 행, 현재 열) 및 (현재 행, 1 열)에서 찾은 숫자의 곱으로 채 웁니다.