LoginSignup
1
0

More than 3 years have passed since last update.

LaTeX ファイルからコメントを取り除く

Last updated at Posted at 2016-02-24

各行のコメント以降を取り除く

\% という文字列がファイルに出現しないのを確認した後に以下を実行する。

sed -e 's/^\([^%]*\)%.*/\1%/' input.tex | sed "/^%/d" > output.tex

ただし、\% という文字の並びが出て来た場合は、その行のそれ以降を削除してしまうので注意すること。

複数行のコメント行を取り除く

Emacs 上で Query replace regexp (C-M-%) を用います。

^%.*\(^J%.*\)* -> %

(^J は改行です。C-q C-j で入力できます)

さらに、前後に空行の % だけの行も取り除きます。

^^J%^J^J -> ^J

これを行った理由

校正を依頼する前の原稿からコメント行を取り除きたかったからです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0