2

Numbering inside the table (in second column) is not coming to the proper position, going below the figure. If we use \begin{enumerate} it shows error.

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{enumerate}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|}
            \hline
            abcd & xyz\\
            \hline
            \multirow{2}{*}{C}  &(a)~\includegraphics[height=2.0cm]{square.png}\\
            &(b)~\includegraphics[height=1.4cm]{circle.png}\\
            \hline  
        \end{tabular}
\end{document}

(a) & (b) are not at middle of figure

  • @gernot I think that the OP wants an enumeration if possible, so probably no duplicate. – TeXnician Apr 6 '17 at 8:40
1

I'm not sure whether I got your question right, but in my understanding, you want to be able to use an enumerate-environment inside a tabular. In this case, you might do the following:

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{pbox}
\begin{document}
\begin{tabular}{|c|c|}
    \hline
    abcd & xyz\\
    \hline
    C & \parbox{0.3\textwidth}{
        \begin{enumerate}[(a)]
            \item\pbox[c]{\textwidth}{\includegraphics[height=2.0cm]{example-image-a}}
            \item\pbox[c]{\textwidth}{\includegraphics[height=1.4cm]{example-image-b}}
        \end{enumerate}
    }\\
    \hline  
\end{tabular}
\end{document}

The \pbox is only used to center the enumerate-labels vertically. In this rather simple solution you have to adjust the width of the \parbox yourself.

results

If you don't want to use enumerate inside the table, still the \usepackage{pbox} and \pbox[c]{\textwidth}{\includegraphics{...}} works to vertically center the labels. Note that the \textwidth inside the \pbox is the maximum allowed width, but \pbox only uses the necessary space.

1

Two things need to be fixed. First, the c column type does not support enumerate, you need p, X, or m. If you don't like using X with tabularx, then m from the array package will be the best choice. Second, to vertically center the images, the valign=m option from adjustbox package comes in handy.

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{enumerate}
\usepackage{array}
\usepackage[export]{adjustbox}
\begin{document}
\begin{tabular}{|c|m{5cm}|}
            \hline
            abcd & xyz\\
            \hline
            C &
            \begin{enumerate}[(a)]
            \item \includegraphics[height=2.0cm,valign=m]{example-image-a}
            \item \includegraphics[height=1.4cm,valign=m]{example-image-b}
            \end{enumerate} \\            
            \hline  
        \end{tabular}
\end{document}

enter image description here

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.