前回までの悪戦苦闘……
taipapa氏の解説どおりにやればいいんじゃんということでやり直し。
How to install Emacs & LaTeX to MacBook Pro 16-inch on Catalina | A perfect autumn day
taipapa氏の書いていらっしゃるとおりなので、あらためて書くのもアレだけど、自分の記録として。
emacs
emacs-macの(再)インストール
.emacs.dをバックアップしておき
emacs-macをアンインストール(自分の場合はcaskだった)。
$ cd
$ mv .emacs.d .emac.d.old # change name of old .emacs.d
$ brew tap railwaycat/emacsmacport
$ brew cask uninstall emacs-mac # uninstall old emacs-mac
$ brew install emacs-mac --with-modern-icon --with-imagemagick # install new emacs-mac
$ ln -s /usr/local/opt/emacs-mac/Emacs.app /Applications
Prelude導入
Preludeインストール。
$ curl -L https://git.io/epre | sh
emacs起動。.emacs.d/personal/prelude-module.elのコメントをいくつか外す。
(require 'prelude-helm) ;; Interface for narrowing and search
(require 'prelude-helm-everywhere) ;; Enable Helm everywhere
..................
(require 'prelude-latex)
prelude-auto-save と super-save はとりあえずそのままに。
ちょっとビックリしたのは、M-xがoption(alt)ではなくて、コマンドキーになっていたこと(⌘)。一瞬慣れなかったけど、まあこれはこれでよいか? Preludeのためなのか、emacs-macの設定なのか不明。
⇒たぶんPreludeのおかげ。Emacs > Preferences...の
Mac Command Modifier を no modifier に
Mac Option Modifier を meta に変更した
init.elをorg-modeで編集
~/.emacs.d/personal/emacs-init.el を作成。
(require 'org)
(defvar my-config-dir (concat user-emacs-directory "personal/"))
(org-babel-load-file
(expand-file-name "init.org" my-config-dir))
~/.emacs.d/personal/init.org を作成し
* Coding System Environment
** 言語を日本語にする
#+BEGIN_SRC lisp
(set-language-environment 'Japanese)
#+END_SRC
** 極力UTF-8とする
#+BEGIN_SRC lisp
(prefer-coding-system 'utf-8)
#+END_SRC
などと書いておけば、~/.emacs.d/personal/init.el が生成されるはずなんだけど、ダメ!
⇒taipapa氏のサイトの
#+BEGIN_SRC lisp
部分はすべて
に置き換え! これでうまく動いている。
LaTeX
MacTeX 2020
前回のポストで、MacTeX 2020をインストールしていたので、略。でいいのかな?
ヒラギノフォントのインストール
要るのかなと思いつつ、せっかくMacだし。
$ sudo tlmgr update --self --all
は前にやったのでスキップ。続いて
$ sudo tlmgr repository add http://contrib.texlive.info/current tlcontrib
$ sudo tlmgr pinning add tlcontrib '*'
$ sudo tlmgr install japanese-otf-nonfree japanese-otf-uptex-nonfree ptex-fontmaps-macos cjk-gs-integrate-macos
続いてパスを通し、以前のリンクなど削除、リンクをあらためて作成、mk、マップファイル作成(らしい)。指示通りにコマンドを打つ……。
$ sudo tlmgr path add
$ sudo cjk-gs-integrate --link-texmf --cleanup
$ sudo cjk-gs-integrate-macos --link-texmf
$ sudo mktexlsr
$ sudo kanji-config-updmap-sys --jis2004 hiragino-highsierra-pron
念のため確認しておくと……
$ kanji-config-updmap-sys status
CURRENT family for ja: hiragino-highsierra-pron (variant: -04)
Standby family : haranoaji
Standby family : hiragino-highsierra
Standby family : hiragino-highsierra-pron
Standby family : ipa
Standby family : ipaex
Standby family : toppanbunkyu-highsierra
ちなみにbeforeは
$ kanji-config-updmap-sys status
Cannot find ptex-fontmaps-macos-data.dat, skipping!
CURRENT family for ja: haranoaji (variant: -04)
Standby family : haranoaji
Standby family : ipa
Standby family : ipaex
pdffontsコマンドで埋め込みを確認しようと思ったが、そもそもpdffontsが入っていないので断念。
せってい(あとでかく)
ヒラギノ問題
Emacsのorg-modeで論文を書く(その1:pdfとhtmlへの出力) | A perfect autumn day
の解説通りやろうとして挫折。init.elに(init.org経由で)
(require 'ox-latex)
(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[hiragino-dx]{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}")))
(setq org-latex-pdf-process
'("xelatex -interaction nonstopmode -output-directory %o %f"
"bibtex %b"
"xelatex -interaction nontopmode -output-directory %o %f"
"xelatex -interaction nonstopmode -output-directory %o %f"))
としておいて、サンプルの.orgをox-latexから通そうとするんだけれども、
- hiragino-oxだと文字化けする
- hiragino-highsierra / -pronでも文字化けする
- hiragino-pro / pronだとPDF生成時にエラーが出る
yu-osxだと大丈夫なので、いったん逃げるが……なんだか納得がいかない
べつにLaTeXを使いたいわけではないので
pandocにするか?
どっちにしろLaTeXは必要なはずだよなあブツブツと思いつつpandocへ
pandoc
$ brew install pandoc
文献引用はいらないので、pandoc-citeproc はインストールしない。
M-x package-install で ox-pandoc をインストール。
personao/init.org に
(require 'ox-pandoc)
;; default options for all output formats
(setq org-pandoc-options '*1;;; \hypersetup{...} を出力しない
(setq org-latex-with-hyperref nil)(add-to-list 'org-latex-classes
'("thesis"
"\\documentclass[a4j]{jarticle}
[NO-PACKAGES]
[NO-DEFAULT-PACKAGES]
\\usepackage[dvipdfmx]{graphicx}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
と書いて、だいたいOKな感じ。
dvi→pdfを、dvipdfmxでやるのか、xelatexでやるのかなど、このあたりに深い溝がありそうだが、いまはlatexを追求したいわけではないので……。
たぶん、海外のジャーナルに投稿する場合には、dvipdfmxではもうだめとか、unicodeの問題とか、なんじゃらかんじゃらあるのだと思われる。
なんかinit.elに書く内容は読めるようになってはきた。
で、原点に帰ると、やりたいのはbeamerであった。
そこからあまりブレないようにやっていこうっと。
*1:standalone . t)))
;; cancel above settings only for 'docx' format
(setq org-pandoc-options-for-docx '((standalone . nil)))
;; special settings for beamer-pdf and latex-pdf exporters
(setq org-pandoc-options-for-beamer-pdf '((pdf-engine . "xelatex")))
(setq org-pandoc-options-for-latex-pdf '((pdf-engine . "xelatex")))
を書いておく。後半のlatexはまだ適当。赤字のところを入れなあかんことがわからなくて大苦戦。
latex再挑戦
今度は
を参考にしつつやってみる。
(require 'ox-latex)
;(require 'ox-bibtex);;; LaTeX 形式のファイル PDF に変換するためのコマンド
(setq org-latex-pdf-process
'("platex %f"
"platex %f"
; "bibtex %b"
; "platex %f"
; "platex %f"
"dvipdfmx %b.dvi"