LoginSignup
19
13

More than 5 years have passed since last update.

Texで表の中に図を埋め込む

Last updated at Posted at 2014-12-14

表と図を挿入するのは簡単ですが、その2つを同時に使うときにとても苦労しています。
現在の私の書き方のテンプレートを以下に紹介します。

書き方テンプレ

Figure
\begin{table}[h]
  \caption{表タイトル}
  \begin{tabular}{|l|c|r|} % l:左寄せ,c:中央揃え r:右寄せ 
    \hline \rm タイトル1 & \rm タイトル2 & \\ \hline
    \hline
    \begin{minipage}{20mm}
      \centering
      \scalebox{0.5}{\includegraphics{画像名1.拡張子}}
    \end{minipage} &
    \begin{minipage}{20mm}
      \centering
      \scalebox{0.5}{\includegraphics{画像名2.拡張子}}
    \end{minipage} \\ \hline
  \end{tabular}
  \label{ラベル名} % \ref{ラベル名}で表番号を参照
\end{table}

\scaleboxのあとの{}の中で画像のサイズを、\begin{minipage}のあとの{}の中で表のセルのサイズを指定します。

サンプル

cat_turtle.tex
% プリアンブル
\documentclass[10pt]{article}
\usepackage[dvipdfmx]{graphicx}

% 本文
\begin{document}
\begin{table}[h]
  \caption{ねこさんとかめさん}
  \begin{tabular}{|c|c|} % l:左寄せ,c:中央揃え r:右寄せ 
    \hline \rm ねこさん & \rm かめさん \\ \hline
    \hline
    \begin{minipage}{50mm}
      \centering
      \scalebox{0.3}{\includegraphics{cat.eps}}
    \end{minipage} &
    \begin{minipage}{50mm}
      \centering
      \scalebox{0.3}{\includegraphics{turtle.eps}}
    \end{minipage} \\ \hline
  \end{tabular}
  \label{cat_turtle} % \ref{ラベル名}で表番号を参照
\end{table}\ref{cat_turtle}は,ねこさんとかめさんの表です.
\end{document}

これをビルドして出力すると…
ねこさんとかめさん.png

このように表の中に図を埋め込むことができます!

本題

同様の出力をするためにもっとスマートな書き方があれば教えて下さいm(_ _)m
また、サイズは出力を見つつ調整してください。

19
13
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
19
13