# Vertical alignment of image an text within tabular environment placed in header using fancyhdr package

The adjustbox package provides a way to vertically align image and a paragraph of text within the tabular environment; I have included an example which shows this:

mwea.tex

\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage[demo]{graphicx}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tabular}
\setlength\PreviewBorder{5pt}
\newlength{\parboxwidth}
\setlength{\parboxwidth}{8.0cm}
\begin{document}
\begin{tabular}[t]{rl}
\midrule
\parbox[t]{\parboxwidth}{%
\lipsum[1]}
} \\
\midrule
\end{tabular}
\end{document}


Which gives the following output:

Ultimately, I'd like to place a feature very similar to the above as a header using the fancyhdr package. I have included my attempt at this below, however, as the output will attest, I cannot seem to align both the image and the text such that their tops meet the top of the header area. They are aligned to the same vertical position, however, this position is not at the top of the header.

mweab.tex

\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage[demo]{graphicx}
\usepackage{fancyhdr}
\usepackage[showframe,textwidth=245.0pt,%
top=2in,
\newlength{\parboxwidth}
\setlength{\parboxwidth}{8.0cm}
\begin{document}
\fancypagestyle{plain}{%
\begin{tabular}{rl}
\parbox[t]{\parboxwidth}{%
content content content content content content content content content content     content content content content content content content content content content content     content content content content content content content}
}
\end{tabular}
}%
}%
\makeatletter
\let\ps@firstpage\ps@plain%
\makeatother
\thispagestyle{plain}
\section*{Body}
\lipsum[1]
\end{document}


This gives the ouput:

Any comments or suggestions are most appreciated.

Supplementary material:

• Your MWE returns this output for me. As such, it's perfectly fine in terms of the vertical alignment.
– Werner
Apr 15, 2014 at 19:01
• Please see revision. Apr 15, 2014 at 19:11
• @StevenB.Segletes, Thanks for the revision, I have attached my output; I'm still seeing a gap between the top of the header area and the top of the image and text. I also note that changing the value associated with the textwidth option of the geometry package call on my system is not showing any thinning or broadening of the text. I don't understand why there is no effect. Apr 15, 2014 at 19:24

You don't need the tabular. One problem was that your figure width plus parbox width plus any left-gap and inter-gap have to add up to \textwidth, so I defined it that way, using \theleftgap, \themidgap and \figurewidth as settable dimensions. Instead of adjustbox, I used \belowbaseline[-\ht\strutbox]{...} to vertically adjust the figure to match a [t] parbox. To get the whole kit and caboodle top aligned, I set a \rule of negative height equal to \headheight.

I commented out the string textwidth=245.0pt, which was causing my MWE to produce very narrow output.

\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage[demo]{graphicx}
\usepackage{fancyhdr}
\usepackage[showframe,%textwidth=245.0pt,%
top=2in,
\newlength{\parboxwidth}
\def\figurewidth{3cm}
\def\themidgap{1em}
\def\theleftgap{.5\textwidth}
\setlength{\parboxwidth}{\dimexpr\textwidth-\theleftgap-\figurewidth-\themidgap\relax}
\usepackage{stackengine}
\begin{document}
\fancypagestyle{plain}{%
\hspace{\theleftgap}%
\belowbaseline[-\ht\strutbox]{\includegraphics[width=\figurewidth, height=1cm]{image.png}}%
\hspace{\themidgap}\parbox[t]{\parboxwidth}{%
content content content content content content content content content content
content}
}%

• @JohnChris Please see revision. I used a \rule to top align the content. Apr 15, 2014 at 19:32