[Tex/LaTex] Align text and logo in footer

graphicsheader-footervertical alignment

I can't seem to be able to align our logo and page number in the footer. I have the code below:

\pagestyle{fancy} % enable fancy page style
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0pt}
\fancyhf{} % clear header and footer
\fancyhead[L]{\leftmark} % leftmark shows the chapter, rightmark shows the section.
\fancyfoot[C]{\thepage}
\fancyfoot[R]{ % right
   \includegraphics[scale=0.5]{general_images/logo.png}
}

How can I align the page number and the logo? Any ideas?

Best Answer

With \includegraphics, the base line for alignment is at the bottom. You could use \raisebox to raise or to lower the image. The calc package can help in calculating if required. For example for top alignment

\usepackage{calc}
\fancyfoot[R]{
  \raisebox{1.2ex-\height}{\includegraphics{logo.png}}}

or with more calculation

\usepackage{calc}
\newlength{\myheight}
\fancyfoot[R]{
  \settoheight{\myheight}{\thepage}
  \raisebox{\myheight-\height}{\includegraphics{logo.png}}}

or for middle alignment instead

\raisebox{.5\myheight-.5\height}{\includegraphics{logo.png}}