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?




transparentpackage to make the background image more like a watermark. – Kajsa Oct 06 '16 at 10:18decodearrayparameter of\includegraphicsas in\includegraphics[decodearray={.7 1 .7 1 .7 1},height=\dimexpr\ht0+\dp0\relax]{#3}}}. Changing the.7's to0recovers the original image. Increasing towards1fades it completely. – Steven B. Segletes Oct 06 '16 at 10:29\dp0? When I use it theminipagehas to get bigger to fit the image but if I don't use it the image does not fill the last line of the text. – Kajsa Oct 06 '16 at 10:52\dp0is the depth of box 0 (into which I had shoved theminipagetemporarily), meaning the distance from the "baseline" to the bottom of the box. Because I used the[b]option tominipage, the last line of theminipagesits on the baseline (rather than theminipagebeing vertically centered about the baseline [which is the default]). Thus, with the[b]option in place,\dp0only accounts for the small amount of vertical space if the last (bottom) line of text has any descending letters likegorq. – Steven B. Segletes Oct 06 '16 at 10:57\documentclass{article} \begin{document} \noindent\setbox0=\hbox{X}\copy0: \the\dp0, \the\ht0, \the\wd0\par \noindent\setbox0=\hbox{g}\copy0: \the\dp0, \the\ht0, \the\wd0 \end{document}, which show the depth, height and width of the lettersXandg, respectively. – Steven B. Segletes Oct 06 '16 at 11:02minipagealignment, compile this:\documentclass{article} \usepackage{lipsum} \parskip 1ex \begin{document} I sit on the baseline \begin{minipage}[t]{3.5in}\lipsum[4]\end{minipage}\par I sit on the baseline \begin{minipage}{3.5in}\lipsum[4]\end{minipage}\par I sit on the baseline \begin{minipage}[b]{3.5in}\lipsum[4]\end{minipage}\par \end{document}, which sets aminipagewith top, center (default) and bottom alignments, respectively. – Steven B. Segletes Oct 06 '16 at 11:06