I am trying to put logos in the background of minipages. I want them to have the same hight as the minipage, since it is quite short, and be horizontally centered.
To do this I have tried to combine the solutions of these two questions: background-image-for-minipage (Gets the right height but not centered or see through) using-tikz-to-position-a-background-image-in-mini-page (Centered ans see through but wrong height)
What I have come up with is this:
\documentclass{article}
\usepackage{lipsum}%
\usepackage{fullpage}%
\usepackage{tikz}%
\usepackage{graphicx}%
\newsavebox\mysavebox
\newcommand{\bgfield}[2]{
\begin{tikzpicture}
\node[inner sep=0pt,outer sep=0pt,text width=\textwidth](a){%
\kern\dimexpr-\fboxsep-\fboxrule\relax
\begin{lrbox}{\mysavebox}%
\begin{minipage}{\textwidth}
{\Large\bfseries Title}\par%
\emph{Subtitle}%
\begin{flushleft}
#1 % \lipsum[1]
\end{flushleft}
\end{minipage}
\end{lrbox}
\sbox\mysavebox{\usebox\mysavebox}%
\mbox{\usebox\mysavebox}%
};
\node[anchor=north ,inner sep=0pt,outer sep=0pt,opacity=0.5] at (a.north) {
\includegraphics[width=\textwidth %, height=\dimexpr\ht\mysavebox+\dp\mysavebox\relax]{#2}};
\end{tikzpicture}
}
\begin{document}
\bgfield{\lipsum[1]}{LaTeX.png}
\end{document}
If I use it this way I get the wrong height of the logo:
If I un-comment the height of the \includegraphics
,
so that it becomes \includegraphics[width=\textwidth, height=\dimexpr\ht\mysavebox+\dp\mysavebox\relax]{#2}
the Logo simply disappears.
Any ideas on how to solve this?