\includegraphicsのエラーを解消するのに3時間かかった[Tex][OverLeaf]
先に解決法
\usepackage{graphics}ではなく\usepackage{graphicx}を使ったら普通にコンパイルできた
以降、経緯をだらだらと書く
OverLeafで図を挿入しようとして、以下のようなコマンドを書いた。
\usepackage{graphics}
\begin{figure}[htbp]
\centering
\includegraphics[width=7cm]{fig/sample}
\caption{This is figure.}
\label{fig:sample}
\end{figure}
そして、コンパイルを行うと画面に沢山のエラーがでた。

検索で引っかかるようエラー本文も以下に載せる。
Runaway argument?
width=7cm]{fig/framework} \caption {Our proposal pipeline is an end-t\ETC.
! Paragraph ended before \Gin@iii was complete.
<to be read again>
\par
l.62
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
emnlp-ijcnlp-2019.tex, line 123
LaTeX Error: \begin{figure} on input line 56 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.123 \end{document}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
ん?なんのエラー?
中身を読んでもいまいちエラーの原因はわからないが、とりあえずコードの書き方やパッケージを見直したり、試行錯誤していると以下のことがわかった。
\includefraphicsの[with=7]というオプション指定を外すとコンパイルが成功する。
コンパイルに成功したコマンド。だけどオプションの指定がない。
\usepackage{graphics}
\begin{figure}[htbp]
\centering
\includegraphics{fig/sample} % ただ単にwithのオプション指定を外しただけ
\caption{This is figure.}
\label{fig:sample}
\end{figure}
えっ?\includegraphicsのオプションが原因?なにそれ?
オプション指定なしでコンパイル通っても図の大きさ変えれないから困るじゃん。
って考えて対策をググるもググるも適切な回答が出てこない
そして、なんとなく見つけた以下の記事を参考に\usepackage{graphics}を\usepackage{graphicx} に変更してみた。
そしたらなんと、コンパイルに成功したのだ!
成功したコマンド。オプション付き。
\usepackage{graphicx}
\begin{figure}[htbp]
\centering
\includegraphics[width=7cm]{fig/sample} % ただ単にwithのオプション指定を外しただけ
\caption{This is figure.}
\label{fig:sample}
\end{figure}
直接的な原因は全然わからなかったのだが、ここまで苦戦して本当に疲れたので、原因を究明する気にはなれなかった。ひとまず、ここまでをブログに共有。
この記事を読まれる方は論文を頻繁に書く人で、査読付き論文にもよく投稿されていることであろう。基本的だけども日本人研究者がおかしがちなミスを網羅した以下の本はきっとあなたの論文執筆の役に立つはずだ。



ディスカッション
コメント一覧
まだ、コメントがありません