虎(牛)龍未酉2.1

記録帳|+n年後のジブンが思い出せますように……

【記録】beamerでスライド(目処がついた)

ロードマップw

というロードマップでいきたい。これは、やりながらのほぼ時系列での記録。

 

terminal + latex + beamer(とにかくコンパイル

なにせはじめてなので、とにかくコンパイルを通して、PDFを作成する。

Beamerによるプレゼンテーション作成Tutorial - Qiita

を写経。

\documentclass[12pt, unicode]{beamer}
\usetheme{CambridgeUS}
\usepackage{luatexja}

\title{Beamer Tutorial}
\author{@termoshtt}
\date[2014/12/21]{\TeX \& \LaTeX Advent Calender 2014 12/21}
\institute[某大学]{某大学院 物理っぽい研究室}
% [..]に省略名が書ける

\begin{document}

\frame{\maketitle}

\begin{frame}{frame title}
\end{frame}

\frame{\centering \Large Thank you for your attention !!}

\end{document}

という.texファイルを作って

lualatex hoge.tex

これでPDFまで行ってくれた。すばらしい!!

 

terminal + latex + beamer(Metropolisでコンパイル

次はxalatexで。

今さら人に聞けない「日本語でBeamer」のキホン - Qiita

を参考に、上の方を下記と置き換えた。

\documentclass[unicode,12pt]{beamer}
\usepackage{zxjatype}
\usepackage[ipaex]{zxjafont}

\usetheme{Copenhagen}

$ xelatex hoge.tex でPDF生成。すばらしい!(2回xelatexやらなあかんの?)

 

続いて、テーマ変更で

\usetheme{Metropolis}

とした。これも$ xelatex hoge.tex でPDF生成。すばらしい!

 

terminal + latex + beamer(Metropolis+良いフォント)

はいこのあたりから鬼門がやってきますよ。

\documentclass[unicode,12pt]{beamer}
\usepackage{zxjatype}
\usepackage[hiragino]{zxjafont}

\usetheme{Metropolis}

にすると、

! Package fontspec Error: The font "Hiragino Mincho Pro W2" cannot be found.

For immediate help type H <return>.
...

l.547 \zxjf@use@preset{\zxjf@main@preset}

? H

A font might not be found for many reasons.
Check the spelling, where the font is installed etc. etc.

When in doubt, ask someone for help!

ヒラギノ明朝ProのW2がないと言われる。org-modeでもこのあたりに苦労していたのであった。

\usepackage[yu-osx]{zxjafont}

にすると通るので、ヒラギノがなんらかの理由で見つけられないのであろう。

hiragino-pro / hiragino-pron にしても結果は変わらず。

 

hiragino-highsierra-pronにすると、エラーメッセージは変わった。

! Package keyval Error: hiragino-highsierra-pron undefined.

See the keyval package documentation for explanation.
Type H <return> for immediate help.
...

l.175 \ProcessOptions*

? H
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.

 

フォントはyu-osx(游ゴシック、游明朝)であきらめるか……。

 

terminal + latex + beamer(スライド内容充実)

mtheme/demo at master · matze/mtheme · GitHub

MetropolisのGitHubから、demo.texを取ってきて、コンパイルしてみる。

$ xelatex demo.tex

無事にPDF化。多少ワーニングも出てるけど、気にしない。

 

アタマのところを

\documentclass[unicode,10pt]{beamer}
\usepackage{zxjatype}
\usepackage[yu-osx]{zxjafont}

に変更し、日本語を入れても大丈夫だった。

 

emacs + org-mode + latex + beamer

日本語フォント(ヒラギノを使おう)は後回しにして、org-modeで使えるように頑張ってみよう。

Beamer presentations using the new export engine

を見ながらやってみる。

 

init.el(init.org経由)側

(require 'ox-latex)

(setq org-latex-pdf-process
'("xelatex %f"
"xelatex %f"))

(add-to-list 'org-latex-classes
'("beamer"
"\\documentclass[unicode, 12pt]{beamer}"
("\\section\{%s\}" . "\\section*\{%s\}")
("\\subsection\{%s\}" . "\\subsection*\{%s\}")
("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}")))

.orgファイルのヘッダ側

#+STARTUP: indent showall
#+LaTeX_CLASS: beamer
#+BEAMER_THEME: Metropolis

* test
** subsection
** subsection2
** 日本語も
| table | is possible? | 3rd column |
| a | a | a |
| 表 | 可能? | 3番目 |
| あ | あ | あ |

とりあえずPDFは生成されるものの、日本語がうまく出ない。

 

emacs の org-beamer-export-to-pdf 設定手順 - Qiita

のとおりにやってみるかー。

 

emacs + org-mode + latex + beamer (ox-latex & ox-beamer)

#+BEAMER_THEME: metropolis

 ここを大文字にしていてハマった。

 

(require 'ox-latex)
(require 'ox-beamer)

 

;;; LaTeX 形式のファイル PDF に変換するためのコマンド
(setq org-latex-pdf-process
'("xelatex %f"
"xelatex %f"))

 

;;; \hypersetup{...} を出力しない
(setq org-latex-with-hyperref nil)

(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(setq org-latex-default-class "bxjsarticle")

 

(add-to-list 'org-latex-classes
'("koma-article"
"\\documentclass{scrartcl}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

 

(add-to-list 'org-latex-classes
'("koma-jarticle"
"\\documentclass{scrartcl}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{xunicode}
\\usepackage{fixltx2e}
\\usepackage{zxjatype}
\\usepackage[yu-osx]{zxjafont}
\\usepackage{xltxtra}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{hyperref}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

 

(add-to-list 'org-latex-classes
'("beamer"
"\\documentclass[unicode, 12pt]{beamer}
\\usepackage{zxjatype}
\\usepackage[yu-osx]{zxjafont}"
("\\section\{%s\}" . "\\section*\{%s\}")
("\\subsection\{%s\}" . "\\subsection*\{%s\}")
("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}")))

thesis(jarticleベース)は外して、koma-jarticleを使う(游字体)。

beamerも使えるようにした。

C-c C-e l oでLaTeX、OでbeamerをPDFにする。

ところまでは来た気がするよ!

 

さて、beamerスライドで、ちょっとまともなアウトプットづくりを。

 

beamer by .org

ox-beamerのドキュメントその1:Writing Beamer presentations in org-mode

ox-beamerのドキュメントその2:Beamer presentations using the new export engine

Metropolisのドキュメント:Metropolisのドキュメント

orgファイルのサンプルあり:emacs の org-beamer-export-to-pdf 設定手順 - Qiita

 

これらを参考にして、

# -*- Mode: org ; Coding: utf-8-unix -*-
#+STARTUP: beamer indent showall

#+TITLE: やつしろ丸の大冒険
#+AUTHOR: foo foo foo
#+DATE: 2020年05月18日(月)
#+OPTIONS: H:1 toc:nil num:t
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport

#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [presentation, aspectratio=169]
#+latex_header: \usetheme[numbering=fraction, progressbar=foot]{metropolis}


* 背景

** 現状

** 問題点

* 期待

* 対策案

** ベースアイディア
** メリット
** 懸念
 

* その1: 基本的な使い方 :noexport:
* その2: 装飾など :noexport:

みたいな感じで。とりあえずとても基本的なスライドは作れる。

見どころwは

  • :noexport:タグの宣言と、使い方(青字)
  • beamerクラスオプションの指定(presentationの威力は不明、aspectratioは便利)
  • metropolisテーマへのオプション指定(#+BEAMER_THEME: metropolisは削除)

最後のmetropolisテーマへのオプション指定は、他ではあまり記載がない。org-mode(ox-beamer) + metropolisの人が、あまり多くないのでしょう。

 

基本的なスライドは作れるようになったので、今回は無事に終了。

 

おまけ

現時点での設定など。hoge.orgは上記の通り。

init.elの関係する部分は

(require 'ox-latex)
(require 'ox-beamer)

;;; LaTeX 形式のファイル PDF に変換するためのコマンド
(setq org-latex-pdf-process
'("xelatex %f"
"xelatex %f"))

;;; \hypersetup{...} を出力しない
(setq org-latex-with-hyperref nil)

(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(setq org-latex-default-class "bxjsarticle")

(add-to-list 'org-latex-classes
'("koma-article"
"\\documentclass{scrartcl}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

(add-to-list 'org-latex-classes
'("koma-jarticle"
"\\documentclass{scrartcl}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{xunicode}
\\usepackage{fixltx2e}
\\usepackage{zxjatype}
\\usepackage[yu-osx]{zxjafont}
\\usepackage{xltxtra}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{hyperref}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

(add-to-list 'org-latex-classes
'("beamer"
"\\documentclass[unicode, 12pt]{beamer}
\\usepackage{zxjatype}
\\usepackage[yu-osx]{zxjafont}"
("\\section\{%s\}" . "\\section*\{%s\}")
("\\subsection\{%s\}" . "\\subsection*\{%s\}")
("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}")))

(setq org-beamer-frame-default-options "t")

そうだ最後の、本文を上寄せにするのも、目玉だった。

org-modeのBeamerクラスのフレームの縦位置を中間ではなく上に固定する – My備忘録