1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

<U+FEFF>のせいで.styファイルを読み込めない

1
Posted at

人からもらった.styなどを読み込もうとすると、

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.1 �
     ��%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

などと怒られることがある。
これは、utfで書かれたファイルをオリジナルのtexに近いtex(例えば、マルチバイトを想定してないpdflatex)に読ませることで起こる。

何にも無いはずのファイルの先頭が引っかかるのでめっちゃ焦るが、何の事はない。

lessで見てみるとすぐに分かるように.styファイルの先頭に

<U+FEFF>

というコードが入っている。
これは、Byte Order Marker(BOM)という代物で、解説はこちらを見てください。

U+FEFF

マルチバイトのスタイルファイルをpdflatexに読ませるなといえば、それまでですが。
どうしても回避した人は、

nkf -w hoge.sty

などとしてください。ここで、おせっかいにも

nkf -w8 hoge.sty

とかすると、ダメです。-wはBOM無し、-w8BOM有りです。(<ー実はここでハマったw)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?