MacTex
しばらく前にがっつりめのドキュメントを書くためにmacOSにHomebrewでTeX環境を作った時のメモが出てきたので、体裁だけ整えて置いておく。
インストール
3種類ある。
$ brew search tex
*snip*
If you meant "tex" specifically:
There are three versions of MacTeX.
Full installation:
brew install --cask mactex
Full installation without bundled applications:
brew install --cask mactex-no-gui
Minimal installation:
brew install --cask basictex
GUIアプリケーションは不要なのでmactex-no-gui
をインストールした。
かなりデカい。
basictex
でも良いのかもしれないけれど試していない。
更新履歴を載せる
vhistoryを使う。 rcsでも良かったが粒度が細かすぎるきらいがあったのと、あとLogがうまく出なかった。
\usepackage[tocentry,owncaptions,hideauthorcolumn]{vhistory}
\renewcommand{\vhhistoryname}{更新履歴}
\renewcommand{\vhversionname}{版}
\renewcommand{\vhdatename}{更新日}
\renewcommand{\vhchangename}{概要}
\def\docauthor{筆者}
\begin{versionhistory}
\vhEntry{1.0}{\today}{\docauthor}{初版作成}
\end{versionhistory}
hideauthorcolumn
オプションはドキュメントには載っていない気がするが、ソースを見たらあった。
ページのヘッダ・フッタ
fancyhdrと、ページ総数を入れるためにlastpageを合わせて使う。
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\lhead{}
\chead{\doctitle}
\rhead{}
\lfoot{\vhCurrentDate (v\vhCurrentVersion)}
\cfoot{}
\rfoot{ページ \thepage{} / \pageref{LastPage}}
- ヘッダに文書タイトル
- フッタに最終更新日と版数、およびページ番号
- ヘッダとフッタに罫線(それっぽい)
vhistoryの最新のエントリから、最終更新日と版数が\vhCurrentDate
, \vhCurrentVersion
で取れる。便利。
初版以降の更新の際は、まずvhistoryのエントリを追加してから手をつける流れにするのが良さそう。
URLを記述
urlを使う。それだけ。
\usepackage{url}
\url{http://example.com}
電話番号とか似た感じで扱いたければ、
\DeclareUrlCommand\tel{}
\tel{000-0000-0000}
項名を参照
namerefを使う。
項番号とついでにカッコも一緒に記載するには、\ref
コマンドと\nameref
コマンドを組み合わせた新しいコマンドを定義する。
\usepackage{nameref}
\newcommand*{\fullref}[1]{「\ref{#1} \nameref{#1}」}
画像
graphicxを使う。
\usepackage[dvipdfmx]{graphicx}
\begin{figure}[h]
\begin{center}
\includegraphics[width=3.0cm]{Hoge.jpg}
\caption{タイトル}
\label{fig:hoge}
\end{center}
\end{figure}
脚注
罫線なしにする。
\renewcommand{\footnoterule}{}
sectionで自動改ページ
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\paragraph
でエラーが出て使えなくなるけど、特に困らないので調べてない。