How to have a vertically centered image in a 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
Graphics, Figures & Tables ⇒ Figure alignment in table cell
NEW: TikZ book now 40% off at Amazon.com for a short time.

Figure alignment in table cell
The suggestion of this other thread might be useful here too.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Figure alignment in table cell
By doing many trials and errors, I found the exact (hopely
) method to vertically center an image in a 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:
The image cannot be attached to this post because this site blocks eps type.
Thank myself.
regards,
Yuko

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
This is my last modification.
Let me know if there is any other better way.
Thank you.
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.