kobapan@wiLiki
Login
org-mode/latex

org-mode/latex:目次(tableofcontents,toc)を整える

概要

org-mode で書いた文章を、latex/lualatex を使って、pdfにエクスポートする際の、「目次ページ」と「表紙ページ」の体裁を整えるための設定やorg文書の書き方。

.emacs の設定

まず、export時に目次を出力するデフォルト設定をオフ

(setq org-export-with-toc nil)

次に、目次のリンクには、色も枠もいらないので、hyperrefパッケージを使い、hidelinksオプションを指定する。

文書クラスは、lualatexの横書き。

a5paperにしてるのは、コピー機でA4用紙を使った製本印刷をするため。

(add-to-list 'org-latex-classes
             '("ltjsarticle"
               "
\\documentclass[a5paper,fleqn]{ltjsarticle}
\\usepackage[unicode=true,luatex]{hyperref}
\\hypersetup{%
hidelinks}
[NO-DEFAULT-PACKAGES]
[PACKAGES]
[EXTRA]
"
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")
               ("\\subparagraph{%s}" . "\\subparagraph*{%s}")
               ))

(setq org-latex-default-class "ltjsarticle")
(setq org-latex-pdf-process '("lualatex %b" "lualatex %b"))

ついでに、TITLEやAUTHORなどは要らないときもあるので、デフォルトは出力しないようにしておく。

(setq org-export-with-title nil) ; >= org-mode v9.1
(setq org-export-with-date nil)
(setq org-export-with-author nil)
(setq org-export-with-creator nil)
(setq org-export-with-footnotes nil)

org ファイルの書き方

 #+LATEX: \title{org-mode で書いて、latex 経由で pdf にして製本}
 #+LATEX: \author{小林ガット}
 #+LATEX: \maketitle
 
 #+LATEX: \thispagestyle{empty}
 
 ここは表紙ページ。写真とか、まえがきを置くとよい。
 
 #+LATEX: \clearpage\setcounter{page}{0}\pagenumbering{roman}\pagestyle{plain}
 #+LATEX: \tableofcontents
 #+LATEX: \clearpage\setcounter{page}{0}\pagenumbering{arabic}
 
 * ゲリラ
 なんせ、ゲリラ豪雨、ゲリラ豪雪の多い昨今である。ただただ木を伐採し、化石燃料を使い続けていてはいけないよ。植林しよう。化石燃料に頼らない経済活動を模索しよう。
 
 #+LATEX: \clearpage
 
 * 今年の干し柿
 暖冬で完熟前に全部落ちるのではと心配した渋柿も、ちゃんと干し柿になった。

表紙ページには、ページ番号を入れたくないので、\thispagestyle{empty}で、ヘッダー/フッターを空白にする。

\clearpage 改ページ。

\setcounter{page}{0} ページ番号のリセット。

\pagenumbering{roman} 目次ページのページ番号はローマ数字にする。

\pagestyle{plain} これからフッターにページ番号を挿入していくよ。

\setcounter{tocdepth}{2} subsection 小節までの目次にする。

\tableofcontents 任意の場所に目次の挿入。

\clearpage\setcounter{page}{0}\pagenumbering{arabic} 改ページ、ページ番号のリセット、ページ番号を数字にする。

PDF 出力結果(4ページ目は省略)

[image]

[image]

[image]

Debian
Emacs
Firefox
Gauche
JavaScript
Linux
Scheme
org-mode/latex

More ...