0

I've used a table of figures in order to format their presentation and order. But essentially the whole thing is a figure, so I want it now to get "Figure 5" as a caption. To do that I guess I have to put the entire table inside a figure.

This is what I'm doing, but all that happens is that the caption shows up, but the table isn't there, and there is an error:

! LaTeX Error: Not in outer par mode.

The code is as follows:

\begin{figure*}
\centering
\caption{Confusion matrices: Single 29-class model}
\label{Figure 5}
\begin{table}
\begin{tabularx}{\textwidth}{c X c }
\textbf{GentleBoost} & & \textbf{Baseline} \\ \noalign{\smallskip}\\ 
\includegraphics[width=7.25cm]{singlematrix_g1} & & \includegraphics[width=7.25cm]{singlematrix_b1} \\ \noalign{\smallskip}\\ 
\includegraphics[width=7.25cm]{singlematrix_g2} & & \includegraphics[width=7.25cm]{singlematrix_b2} \\ \noalign{\smallskip}\\ 
\includegraphics[width=7.25cm]{singlematrix_g3} & & \includegraphics[width=7.25cm]{singlematrix_b3} \\ \noalign{\smallskip}\\ 
\end{tabularx}
\end{table}
\end{figure*}

However, my only issue is to have it show up as a figure and not table. If it's possible to change the caption from Table to Figure easily - then I'd prefer that!

1

I had to reduce the image size, but there you are:

% arara: pdflatex

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage{caption}

\begin{document}
    \begin{table}
        \begin{tabularx}{\textwidth}{c X c }
            \textbf{GentleBoost} & & \textbf{Baseline} \\ \noalign{\bigskip} 
            \includegraphics[width=1.25cm]{singlematrix_g1} & & \includegraphics[width=1.25cm]{singlematrix_b1} \\ \noalign{\bigskip}
            \includegraphics[width=1.25cm]{singlematrix_g2} & & \includegraphics[width=1.25cm]{singlematrix_b2} \\ \noalign{\bigskip} 
            \includegraphics[width=1.25cm]{singlematrix_g3} & & \includegraphics[width=1.25cm]{singlematrix_b3} \\ \noalign{\bigskip} 
        \end{tabularx}
    \captionof{figure}{Confusion matrices: Single 29-class model}\label{Figure 5}
    \end{table}
\end{document}

enter image description here

  • This has the disadvantage of not being guaranteed to be in the correct order with respect to other figures – David Carlisle Apr 30 '15 at 13:58
  • @user961627 I just corrected your error. But if your final result will stay like it is here (empty middle column) I would strongly recommend David's answer. – LaRiFaRi Apr 30 '15 at 14:10
1

Don't use afigure environment, but rather \captionof, defined in the caption package. Here is a fragment of code:

\begin{table}
\centering
\captionof{figure}{Confusion matrices: Single 29-class model}
\label{Figure 5}
\begin{tabularx}{\textwidth}{c X c }
\textbf{GentleBoost} & & \textbf{Baseline} \\ \noalign{\smallskip}\\
\includegraphics[width=7.25cm]{singlematrix_g1} & & \includegraphics[width=7.25cm]{singlematrix_b1} \\ \noalign{\smallskip}\\
\includegraphics[width=7.25cm]{singlematrix_g2} & & \includegraphics[width=7.25cm]{singlematrix_b2} \\ \noalign{\smallskip}\\
\includegraphics[width=7.25cm]{singlematrix_g3} & & \includegraphics[width=7.25cm]{singlematrix_b3} \\ \noalign{\smallskip}\\
\end{tabularx}
\end{table}

enter image description here

  • This has the disadvantage of not being guaranteed to be in the correct order with respect to other figures – David Carlisle Apr 30 '15 at 13:58
  • @David Carlisle: You're right. Anyway, as far as I know, LaTeX makes no semantic analysis to detect whether the contents of a figure environment is indeed a figure. So a simple figure would do — but you've already answered that, and added some useful comments… – Bernard Apr 30 '15 at 14:05
1

Just use figure not table

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabularx}


\begin{document}
    \begin{figure}
        \begin{tabularx}{\textwidth}{c X c }
            \textbf{GentleBoost} & & \textbf{Baseline} \\ \noalign{\bigskip} 
            \includegraphics[width=1.25cm]{singlematrix_g1} & & \includegraphics[width=1.25cm]{singlematrix_b1} \\ \noalign{\bigskip}
            \includegraphics[width=1.25cm]{singlematrix_g2} & & \includegraphics[width=1.25cm]{singlematrix_b2} \\ \noalign{\bigskip} 
            \includegraphics[width=1.25cm]{singlematrix_g3} & & \includegraphics[width=1.25cm]{singlematrix_b3} \\ \noalign{\bigskip} 
        \end{tabularx}
    \caption{Confusion matrices: Single 29-class model}\label{Figure 5}
    \end{figure}
\end{document}

But don't use tabularx for this it is slow and painful and since the X column is empty not doing anything very useful.

\documentclass{article}
\usepackage[demo]{graphicx}


\begin{document}
    \begin{figure}

            \makebox[5.25cm]{\textbf{GentleBoost}}\hfill \makebox[5.25cm]{\textbf{Baseline} }

\bigskip


            \includegraphics[width=5.25cm]{singlematrix_g1}\hfill\includegraphics[width=5.25cm]{singlematrix_b1}

\bigskip

            \includegraphics[width=5.25cm]{singlematrix_g2}\hfill\includegraphics[width=5.25cm]{singlematrix_b2}

\bigskip
            \includegraphics[width=5.25cm]{singlematrix_g3}\hfill\includegraphics[width=5.25cm]{singlematrix_b3}

\bigskip

    \caption{Confusion matrices: Single 29-class model}\label{Figure 5}
    \end{figure}
\end{document}
  • Thanks a lot. The reason for the X column was that the images are actually pretty big and fat, they take up most of the page and so the empty column in the middle ends up just being a narrow space. – user961627 Apr 30 '15 at 15:50
  • 1
    @user961627 but \hfill is a space that stretches for exactly that reason and takes exactly one cycle of TeX's inner loop to digest that token. I wrote tabularx and I have no idea how many thousands of cycles of the inner loop it takes to make tabularx achieve the same thing with an empty column. – David Carlisle Apr 30 '15 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.