こえむのちょこっとメモ

大きなまとめにする程でもないけど記録したい事を残します

PNG, JPEG画像をLaTeXに埋め込む

(UpTeX 20111010版で動作させている事を前提に記述)

PNG, JPEG画像などは、bounding box情報があるとLaTeXに埋め込める。情報はebbを使って生成。

$ ebb [FILENAME].png

一気にやりたければshellでこうしちゃえばいい。なお、同じファイルを何回ebbしても壊れないのでご安心を。

$ find . \( -name '*.jpg' -o -name '*.png' \) | xargs -t -I{} ebb {}

使用例

$ ll
total 3288
-rw-r--r--  1 koemu  staff   1.6M 10 26 12:35 image.jpg
-rw-r--r--  1 koemu  staff    49K 12 13 15:30 master_thesis-1.png

$ find . \( -name '*.jpg' -o -name '*.png' \) | xargs -t -I{} ebb {}
ebb ./image.jpg
ebb ./master_thesis-1.png

$ ll
total 3304
-rw-r--r--  1 koemu  staff   122B  1  1 19:26 image.bb
-rw-r--r--  1 koemu  staff   1.6M 10 26 12:35 image.jpg
-rw-r--r--  1 koemu  staff   130B  1  1 19:26 master_thesis-1.bb
-rw-r--r--  1 koemu  staff    49K 12 13 15:30 master_thesis-1.png

"*.bb"ファイルが、bounding box情報が収まったファイル。中身はテキストファイル。

$ cat master_thesis-1.bb 
%%Title: ./master_thesis-1.png
%%Creator: extractbb 20110311
%%BoundingBox: 0 0 464 464
%%CreationDate: Tue Jan  1 19:26:11 2013

LaTeX内に埋め込む時は、こんな感じで良い。

\begin{figure}[htbp]
  \begin{center}
    \includegraphics[width=5cm]{./master_thesis-1.png}
    \caption{図の説明を書く}
    \label{dev_model}
  \end{center}
\end{figure}

めでたしめでたし。