2

platexを使っていてドキュメントクラスはjlreqです。

表と図を左右に配置したく書いていたのですがcaptionのところでエラーがでてしまいpdfに出力できません。
エラーが出たコードは以下になります。

\begin{figure}
    \centering
    \begin{minipage}{0.45\linewidth}
        \begin{table}
            \caption{左の表}
            \label{tab:table1}
            \begin{tabular}{cl} \toprule
                表の内容(省略) \\ \bottomrule
            \end{tabular}
        \end{table}
    \end{minipage}
    \begin{minipage}{0.45\linewidth}
        \centering
        \includegraphics[オプション]{figure5.pdf}
        \caption{右の図}
        \label{fig:figure5}
    \end{minipage}
\end{figure}%

これを実行すると

! LaTeX Error: Not in outer par mode.

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

l.64 ^^I^^I^^I^^I\caption {左の表} ?

となります。
初めは\begin{figure}で左右に図を並べるといったにも関わらず\begin{minipage}では\begin{table}と表を作りますといってるからかなと考えたのですがそれならエラーはcaptionではなくてtableででるはずだなと思いました。
修正方法がわかりません。分かる方よろしくお願いいたします。

wtsnjp
  • 1,182
  • 1
  • 8
  • 29
manatsu
  • 187
  • 2
  • 15

2 Answers2

1

figure環境内でtable環境は使えません。
また minipage環境内に table環境を閉じ込めないで下さい。

\@captype を操作すれば、figure環境内で図の \caption を、table環境内で表の \caption を使うことが出来ます。プリアンブルで以下のように指定して

\makeatletter%% プリアンブルで定義する場合は必須
\newcommand{\figcaption}[1]{\def\@captype{figure}\caption{#1}}
\newcommand{\tblcaption}[1]{\def\@captype{table}\caption{#1}}
\makeatother%% プリアンブルで定義する場合は必須

例えば本文中で

\begin{table}
  % 実際の表は省略
    \figcaption{table環境内で図のキャプション}
\end{table}

のようにします。
なので figure環境内で図と表を並べて、表には\tblcaptionを使います。

anonymous
  • 26
  • 3
1

表と図を横に並べるには \@captype を直接変更する他に float パッケージの H オプション(図表の「その場」強制出力)を使用するという方法もあります.

%#!platex
\documentclass{jlreq}
\usepackage{float}
\begin{document}
表を左,図を右に並べてみる:

\begin{figure}\centering \parbox{.45\linewidth}{% % 表の横幅を \parbox の横幅に合わせる \setlength{\columnwidth}{\linewidth}% \setlength{\intextsep}{0pt}% \begin{table}[H]\centering \caption{右側に表} \begin{tabular}{|c|} \hline 何らかの表 \ \hline \end{tabular} \end{table}}\qquad \parbox{.45\linewidth}{\centering \fbox{何らかの図} \caption{右側に図}} \end{figure} \end{document}

表と図を横に並べた例

参考文献:吉永徹美『LaTeX2e辞典 増補改訂版』p.307

wtsnjp
  • 1,182
  • 1
  • 8
  • 29