3

I am trying to create a situation with three columns from left to right:

one with an image top-edge aligned to the top of the center column and the left of itself;

one with wrap-around text having manual breaks. Some of the text will be left aligned, some right;

and one with an image bottom-edge aligned to the bottom of the center column.

I have tried using three minipages, I also tried tabular (see mwe). I tried solution like Aligning image and text on top, with minipages, but I still could not figure out how to get the image in the right column to align to the bottom.

\documentclass{article}%

\usepackage{graphicx}%

\newlength{\myheadskip}
\setlength\myheadskip{2ex plus 1ex minus 0.5ex}
\newlength{\imagewid}
\setlength{\imagewid}{0.162\textwidth}


\newcommand{\partnerimageone}[6]{
\vspace{1.0\myheadskip}
\begin{minipage}[b][][t]{0.18\textwidth}
\flushleft
% \vspace{0pt}
\includegraphics[height=\imagewid]{#5}
% \vspace*{\fill}
\end{minipage}
\begin{minipage}[c]{0.62\textwidth}
\begin{flushleft}
\textbf{\Large #1}

\emph{#2}\vspace{-0.5\myheadskip}
\end{flushleft}

\begin{flushright}
\textbf{\Large #3}

\emph{#4}
\end{flushright}
\end{minipage}
\begin{minipage}[b][][b]{0.18\textwidth}
\flushright
\vspace*{\fill}
\includegraphics[height=\imagewid]{#6}
\end{minipage}
}

\newcommand{\partnerimagetwo}[6]{
\vspace{1.0\myheadskip}
\begin{tabular}{@{}p{0.18\textwidth} p{0.62\textwidth} p{0.18\textwidth}}
\vspace{-2ex}\includegraphics[height=\imagewid]{#5} & 
\textbf{\Large #1} \newline
\emph{#2}\vspace{-0.5\myheadskip} \newline
{\flushright\hfill\textbf{\Large #3}} \newline
{\raggedleft\emph{#4}} &
% \end{flushright} & 
\vspace*{\fill}
\includegraphics[height=\imagewid]{#6}
\end{tabular}
}

\begin{document}

\partnerimageone{
Your Favorite Food Truck
}{
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you\vspace{3ex}
}{
A Nice Bakery
}{
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
}{l_sq}{r_sq}

\partnerimagetwo{
Your Favorite Food Truck
}{
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you\vspace{3ex}
}{
A Nice Bakery
}{
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
This place is magnificent! 
}{l_sq}{r_sq}

\end{document}

mwe

2 Answers 2

3

Here is one option, provided by the environment foodstuff below:

enter image description here

\documentclass{article}
\usepackage{graphicx,tabularx,environ}
\usepackage{lipsum}

\makeatletter
\newcommand{\@leftimage}{}
\newcommand{\@rightimage}{}
\let\leftimage\@gobble
\let\rightimage\@gobble
\long\def\extractleftimage#1\leftimage#2#3\null{\renewcommand{\@leftimage}{#2}}
\long\def\extractrightimage#1\rightimage#2#3\null{\renewcommand{\@rightimage}{#2}}
\NewEnviron{foodstuff}{%
  \expandafter\extractleftimage\BODY\null% Extract left image
  \expandafter\extractrightimage\BODY\null% Extract right image
  \noindent
  \begin{tabularx}{\textwidth}{
      @{} p{.2\textwidth}% Left image column
      X% Center text column
      p{.2\textwidth} @{}}% Right image column
    & \strut%
    \if$\@leftimage$\else\llap{\raisebox{\dimexpr-\height+.7\normalbaselineskip}[0pt][0pt]{%
      \includegraphics[width=.2\textwidth]{\@leftimage}\hspace*{\tabcolsep}}}\fi%
    \BODY\par
    \vspace*{-\normalbaselineskip}\leavevmode\hfill%
    \strut%
    \if$\@rightimage$\else\rlap{\hspace*{\tabcolsep}\raisebox{0pt}[0pt][0pt]{%
      \includegraphics[width=.2\textwidth]{\@rightimage}}}\fi &
  \end{tabularx}
}
\makeatother
\newcommand{\heading}[1]{{\large\bfseries #1\par}}
\begin{document}

\begin{foodstuff}
  \leftimage{example-image-a}% Specify left column image
  \rightimage{example-image-b}% Specify right column image
  \heading{Lorem ipsum dolor sit amet}
  \lipsum[1]

  \bigskip

  \heading{Nullam sagittis neque ac lacus}
  \raggedleft\lipsum[2]
\end{foodstuff}

\end{document}

The use of an environment allows you freedom to style the inner/centre column contents to suit your needs.

The left and right (image) columns have width .25\textwidth, with the centre column being a tabularx X-column.

A requirement is that you have to specify \leftimage and \rightimage inside the foodstuff environment. If you're not using an image, you still need to use \leftimage{} (or \rightimage{}), since they necessarily have to form part of the environment body.

1

Once again, it's \raisebox to the rescue.

\documentclass{article}
\usepackage{graphicx}
\usepackage{mwe}% for image

\newsavebox{\tempbox}
\newlength{\tempheight}
\newlength{\tempdepth}

\begin{document}

\savebox{\tempbox}{\parbox[c]{0.63\textwidth}
{\hfil\textbf{Your Favorite Food Truck}\newline
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you
Offering gourmet local eats prepared daily for you}}

\settoheight{\tempheight}{\usebox{\tempbox}}
\settodepth{\tempdepth}{\usebox{\tempbox}}% not quite equal

\noindent\raisebox{\tempheight}{\raisebox{-\height}% ugly, but it works
{\includegraphics[width=0.15\textwidth]{example-image-a}}}\hfill
\usebox{\tempbox}\hfill
\raisebox{-\tempdepth}{\includegraphics[width=0.15\textwidth]{example-image-b}}

\end{document}

vertical alignment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .