Aspellを用いて複数の英文TeXファイルをスペルチェックして表示する方法

Aspellを用いて複数の英文TeXファイルをスペルチェックして表示する方法をメモ書きする。



準備

Aspellは既にインストール済みと仮定する。
ちなみに、Mac (Homebrew) では、brew install aspell --lang=en でインストールする。

以下のようなTeXソースファイルがあるとする。
テキストは英語のダミーテキストジェネレータを使用し、部分的にスペルミスを発生させた。
Dummy Text Generator – Free, For Web Designers – Lorem Ipsum, Filler Text & Placeholder Text

single.tex : 単独で完結するTeXファイル

\documentclass[11pt,a4paper]{article}
\begin{document}

\section{Introduction}
One begining life. In. Beginning greater moveth together every from isn't
herb baest whose meat all two for, a moving, from firmament. Herb subdue
fourth. Said beast first spirit morning For fruitful you'll beginning one.

\end{document}

multi.tex : 実際によくやるような、複数のTeXファイルに分割するやつ。

\documentclass[11pt,a4paper]{article}
\begin{document}

\input{section1.tex}
\input{section2.tex}

\end{document}
section1.tex

\section{Introduction}
Forth us spirit seed light saying face from also all. Creature fourth years
beginning earth sixth heaven unto fish seas forth, divide whose wherein
earth beginning give doesnt together their face earth likeness, signs
divided god he moveth deep.
section2.tex

\section{Conclusion}
Waters kind firmament made bearing open. Likeness don't created spirit good
morning heaven image form sixth give form which greeen male their you a
every craeted.

.aspell.conf : Aspellの設定ファイル。通常は ~/.aspell.conf に置く。

lang en
ignore-case true
ignore-accents false
mode tex
backup true

.aspell.en.pws : スペルチェックで無視する単語のリスト (改行区切り)。~/.aspell.en.pws に置く。 本当は別ファイルに書いておいた方がよいかもしれない。
このファイルには名前とか専門用語とか略語とかを書いておく。

personal_ws-1.1 en 0
Kotaro
Terada
FPGA
FPGAs

スペルチェック

単一TeXファイルの場合

スペルミスが発生している単語をリストアップする。

$ aspell --lang=en -t list < single.tex
begining
moveth
baest

-t は TeX モードのオプションで --mode=tex と同じ。
標準入力に与えればいいから以下のコマンドでも等価。

$ cat single.tex | aspell --lang=en -t list
begining
moveth
baest

複数TeXファイルの場合

単純に cat *.tex してパイプでaspellに与えてもよいが、せっかくならファイル名を表示させたい。
次のようにすれば実現できる。

$ for f in *.tex; do echo "[$f]"; aspell --lang=en -t list < $f; done
[multi.tex]
[section1.tex]
doesnt
moveth
[section2.tex]
greeen
craeted

おしまい

参考文献

この記事をシェアする:Tweet about this on Twitter
Twitter
Share on Facebook
Facebook
Email this to someone
email