1

Perhaps I am doing it the wrong way, but I have a table with 3 tabulars arranged within minipage each, such that I end up with 3 tables side by side. Each table only has 2 columns: 1 for text and one has includegraphics. I am trying to vertically align text in the first column to be in the middle of the cell.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabu, lscape}
\begin{document}
\begin{landscape}
\begin{table}[!t]
\centering
\begin{minipage}[t]{0.25\linewidth}
    \vspace{0pt}
\begin{tabular}{cc}
    Col1 & Col2 \\
    Text & \includegraphics{<path>} \\ 
\end{tabular}
\end{minipage}
\begin{minipage}[t]{0.25\linewidth}
    \vspace{0pt}
\begin{tabular}{cc}
    Col1 & Col2 \\
    Text & \includegraphics{<path>} \\
\end{tabular}
\end{minipage}
\hspace{1.5cm}
\begin{minipage}[t]{0.25\linewidth}
    \vspace{0pt}
\begin{tabular}{cc}
    Col1 & Col2 \\
    Text & \includegraphics{<path>} \\
\end{tabular}
\end{minipage}
\end{table}
\end{landscape}
\end{document}

enter image description here

I tried using m{'width'} from the array package but no luck. I was wondering if anyone had a suggestion how to achieve this?

Alex
  • 113

1 Answers1

0

Maybe I don't understand your question correctly, but to me the cells get centered when using m{width} as column definition (from the array package), as you suggested.

Here is the code I used:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabu, lscape, array}
\begin{document}
\begin{landscape}
\begin{table}[!t]
\centering
\begin{minipage}[t]{5cm}
  \begin{tabular}{@{}C{1.5cm}@{}C{3.5cm}@{}}
    Col1 & Col2 \\
    Text & \includegraphics[width=2cm]{<path>} \\ 
  \end{tabular}
\end{minipage}
\begin{minipage}[t]{5cm}
  \begin{tabular}{@{}C{1.5cm}@{}C{3.5cm}@{}}
    Col1 & Col2 \\
    Text & \includegraphics[width=2cm]{<path>} \\
  \end{tabular}
\end{minipage}
\hspace*{1.5cm}
\begin{minipage}[t]{5cm}
  \begin{tabular}{@{}C{1.5cm}@{}C{3.5cm}@{}}
    Col1 & Col2 \\
    Text & \includegraphics[width=2cm]{<path>} \\
  \end{tabular}
\end{minipage}
\end{table}
\end{landscape}
\end{document}

and here is the output:

Output

If you want to also center the columns horizontally, you will need to define a new C column type as such:

\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

and replace m by C in the column definitions of the tabulars of the code above. The result is then:

Result with columns also centered horizontally

Two last note: - I've replaced the references to \columnwidth in the width of the column definitions by set values. References to \columnwidth would not be appropriate nor working / constant here (see the answer to Difference between \textwidth, \linewidth and \hsize to understand why). - In your code, the minipages are not necessary at all.

Xavier
  • 13,947
  • This is most excellent! But I only have 1 question is there a way to keep column headings in aligned to center? – Alex Aug 05 '13 at 22:38
  • I edited my answer to show you how to do this with \newcolumntype. – Xavier Aug 06 '13 at 02:44