Graphics, Figures & Tables ⇒ Figure alignment in table cell
Figure alignment in table cell
Is it possible to use \depth or \totalheight or other to adjust vertical alignment of the image exactly?
Related to: Figures in tables
Thank you in advance.
Yuko
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Figure alignment in table cell
Figure alignment in table cell

Just enclose the image in a minipage.
Make sure you set the outer and inner vertical alignment option of minipage to c (center). Adjust the height and width of the minipage until they suit your need.
The following is my output. I have also checked the dimension using pdf-xchange viewer tools.
Here is the minimal code:
Code: Select all
\documentclass{book}
\usepackage{graphicx,array}
\begin{document}
\begin{tabular}{|>{\begin{minipage}[c][7cm][c]{6cm}\centering}m{6cm}<{\end{minipage}}|c|}\hline
\fbox{\includegraphics[height=4.5cm]{sample}} & sample.eps\\\hline
\rule{4cm}{4cm} & rule of 4cm by 4cm\\\hline
\end{tabular}
\end{document}
The image cannot be attached to this post because this site blocks eps type.
Thank myself.
regards,
Yuko
Figure alignment in table cell
Let me know if there is any other better way.
Code: Select all
\documentclass[a4paper]{article}
\usepackage{array,longtable,calc,xcolor,graphicx}
\usepackage[margin=2cm]{geometry}
\newcounter{SET}
\renewcommand{\theSET}{\stepcounter{SET}\arabic{SET}.}
\newcolumntype{X}[2]{>{\begin{minipage}[c][#1][c]{#2\textwidth}\begin{center}\arraybackslash}m{#2\textwidth}<{\end{center}\end{minipage}}}
\newenvironment{MyFancyTable}[4][10cm]
{\begin{longtable}{|>{\fbox{\theSET}\arraybackslash}X{#1}{#2}|*{2}{X{#1}{#4}|}}\hline\ignorespaces}
{\end{longtable}}
\setlength{\fboxsep}{0.1pt}
\setlength{\fboxrule}{0.05pt}
\begin{document}
\begin{MyFancyTable}[7cm]{0.05}{0.6}{0.35}
%==========================================================
&
\fbox{\color{cyan}\rule{\linewidth-2\fboxsep}{5cm}}
&
\fbox{Function $f(x)=x^2-1$.}
\\\hline
%==========================================================
&
\fbox{\scalebox{1.2}{$\displaystyle\int_a^bf(x)\,dx=F(b)-F(a)$}}
&
\fbox{\parbox{\linewidth-2\fboxsep}{Function $f(x)=x^2-1$ and $g(x)=f(x-1)$.}}
\\\hline
%==========================================================
&
\fbox{\color{cyan}\rule{\linewidth-2\fboxsep}{5cm}}
&
\fbox{Function $f(x)=x^2-1$.}
\\\hline
%==========================================================
&
\fbox{\scalebox{1.2}{$\displaystyle\int_a^bf(x)\,dx=F(b)-F(a)$}}
&
\fbox{\parbox{\linewidth-2\fboxsep}{Function $f(x)=x^2-1$ and $g(x)=f(x-1)$.}}
\\\hline
%==========================================================
&
\fbox{\color{cyan}\rule{\linewidth-2\fboxsep}{5cm}}
&
\fbox{Function $f(x)=x^2-1$.}
\\\hline
%==========================================================
&
\fbox{\scalebox{1.2}{$\displaystyle\int_a^bf(x)\,dx=F(b)-F(a)$}}
&
\fbox{\parbox{\linewidth-2\fboxsep}{Function $f(x)=x^2-1$ and $g(x)=f(x-1)$.}}
\\\hline
\end{MyFancyTable}
\end{document}
Thank you.