Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Welcome to TeX.SX! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Jubobs Aug 5 '13 at 21:43
    
You may want to have a look at the subcaption package and its subtable command: ctan.mirrorcatalogs.com/macros/latex/contrib/caption/… –  pluton Aug 5 '13 at 21:51
    
Oh yeah :) thanks –  Alex Aug 5 '13 at 22:39
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
This is most excellent! But I only have 1 question is there a way to keep column headings in aligned to center? –  Alex Aug 5 '13 at 22:38
    
I edited my answer to show you how to do this with \newcolumntype. –  Xavier Aug 6 '13 at 2:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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