[Tex/LaTex] Insert figure in a table, how to align figures with text in a table

floatstables

I am inserting multiple figures into a table, and would like to make the following change:

  1. center the text (1st column) in the cell (all the text currently are at the bottom)

  2. center the figures (2nd and 3rd column) so that it doesn't cut the horizontal lines. The figures all have slightly different size. Is there a way to auto-adjust the height of each row so that all figures will fit it?

  3. If possible, I would like to show some of the long text in two rows. For example, instead of :

    Inverting op-amp (linear amplifier)
    

    I want it to be in two lines, both horizontally centered in the cell:

    Inverting op-amp
    (linear amplifier)
    

Any suggestions would be highly appreciated! Thanks!

Here is my latex code:

\begin{table}[ht] 
\centering 
\begin{tabular}{  p{4.5cm}  p{5cm}  p{5cm}  }      % centered columns (3 columns) 
\hline\hline                                      %inserts double horizontal lines 
Building Block  & Circuits & Frequency Response \\ [0.5ex] % inserts table heading 
\hline
        Inverting op-amp
        (linear amplifier)
        & \includegraphics[height=1in]{figures/servoblockAB.png}& \includegraphics[height=1in]{figures/servoblockAC.png} \\ [1ex]
\hline  
        Integrator 
        & \includegraphics[height=1in]{figures/servoblockBB.png}& \includegraphics[height=1in]{figures/servoblockBC.png} \\
\hline  
        AC integrator with DC gain
        & \includegraphics[height=1in]{figures/servoblockCB.png}& \includegraphics[height=1in]{figures/servoblockCC.png} \\
\hline  
        Differentiator
        & \includegraphics[height=1in]{figures/servoblockDB.png}& \includegraphics[height=1in]{figures/servoblockDC.png} \\
\hline  
        AC differentiator with DC gain
        & \includegraphics[height=1in]{figures/servoblockEB.png}& \includegraphics[height=1in]{figures/servoblockEC.png} \\
\hline  
    \end{tabular}
    \caption{A few basic circuit blocks and their frequency response for servo design.}
    \label{table4.2}
\end{table}

enter image description here

Best Answer

I made \Includegraphics (cap I) to insert a picture shifted down half its height. I also used some \linebreaks and \raggedrights.

I also added some gap above/below the pictures, as requested with \addstackgap. I can take an optional argument (default 3pt) to specify the gap.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{stackengine}
\newsavebox\mybox
\newcommand\Includegraphics[2][]{\sbox{\mybox}{%
  \includegraphics[#1]{#2}}\abovebaseline[-.5\ht\mybox]{%
  \addstackgap{\usebox{\mybox}}}}
\begin{document}
\begin{table}[ht] 
\centering 
\begin{tabular}{  p{4.5cm}  p{5cm}  p{5cm}  }      % centered columns (3 columns) 
\hline\hline                                      %inserts double horizontal lines 
Building Block  & Circuits & Frequency Response \\ [0.5ex] % inserts table heading 
\hline
        \raggedright Inverting op-amp\linebreak
        (linear amplifier)
        & \Includegraphics[height=1in]{figures/servoblockAB.png}& \Includegraphics[height=1in]{figures/servoblockAC.png} \\ [1ex]
\hline  
        Integrator 
        & \Includegraphics[height=1in]{figures/servoblockBB.png}& \Includegraphics[height=1in]{figures/servoblockBC.png} \\
\hline  
        \raggedright AC integrator\linebreak with DC gain
        & \Includegraphics[height=1in]{figures/servoblockCB.png}& \Includegraphics[height=1in]{figures/servoblockCC.png} \\
\hline  
        Differentiator
        & \Includegraphics[height=1in]{figures/servoblockDB.png}& \Includegraphics[height=1in]{figures/servoblockDC.png} \\
\hline  
        \raggedright AC differentiator\linebreak with DC gain
        & \Includegraphics[height=1in]{figures/servoblockEB.png}& \Includegraphics[height=1in]{figures/servoblockEC.png} \\
\hline  
    \end{tabular}
    \caption{A few basic circuit blocks and their frequency response for servo design.}
    \label{table4.2}
\end{table}
\end{document}

enter image description here

Related Question