Aligning graphical elements with flowfram

1,232

It is a little difficult to tell just what you are trying to do so I'm not sure this is what you are looking for. However, you do say that you want the text printed "on top of" the picture. I'm not sure if this means above the picture or over the picture.

This code puts the picture under the text so that the text is printed on top of the picture. That is, the picture forms a background. The text is printed on the background.

\documentclass[a4paper,11pt,draft]{memoir}

\pagestyle{empty}

\usepackage{flowfram}
\usepackage{graphicx}
\usepackage{tikz}

% left frame
\newflowframe{0.2\textwidth}{\textheight}{0pt}{0pt}[left]
  \newlength{\LeftMainSep}
  \setlength{\LeftMainSep}{0.2\textwidth}
  \addtolength{\LeftMainSep}{2\columnsep}
% right frame
\newflowframe{0.7\textwidth}{\textheight}{\LeftMainSep}{0pt}[main01]


\begin{document}

\begin{tikzpicture}[remember picture, overlay, x=4cm, y=20cm]
    \node at (0,0) {\includegraphics[width=4cm,height=20cm]{symbol_strip.jpg}};
\end{tikzpicture}

\begin{figure}
\begin{flushright}
\vspace{-2cm}
 Tractor beat trailer give backwoods hee-haw gold frogskin plumb nugget. Liniment fancy rightly work chicken what cipherin' how ya. Heapin' backwoods her hospitality em got creosote overalls rodeo up. Townfolk soap out.
\end{flushright}
\end{figure}

\end{document}

Note that I used the draft option to quell errors about not finding the image. This produces this:

Text superimposed on image as background

I'm not sure why you have made this a figure. If you want things positioned precisely, you don't want TeX moving them around and that's what the figure environment tells it to do!

EDIT (DELETION):

Based on your edited question, I assume you don't want the text above the image. Since this pushed stuff off the page, I'm deleting this part of my original answer.

EDIT (UPDATE BASED ON UPDATED QUESTION):

Based on the image you posted, you might try something like the following but replacing the tikzpicture with the background image you have on hand.

\documentclass[a4paper,11pt,final]{memoir}

\pagestyle{empty}

\usepackage{flowfram}
\usepackage{graphicx}% not needed to produce my demo
\usepackage{xcolor}% not needed if you use a background image
\usepackage{tikz}

% left frame - alternatively, specify a larger proportion of \textwidth or set this width absolutely
\newflowframe{0.2\paperwidth}{\textheight}{0pt}{0pt}[left]
  \newlength{\LeftMainSep}
  \setlength{\LeftMainSep}{0.2\paperwidth}
  \addtolength{\LeftMainSep}{2\columnsep}
% right frame - alternatively, specify a smaller proportion of \textwidth or calculate width from the absolute width of the left flow frame etc.
\newflowframe{0.7\paperwidth}{\textheight}{\LeftMainSep}{0pt}[main01]

% recalculate left/right margins - or see alternatives above
\newlength{\mywidth}
\setlength{\mywidth}{\LeftMainSep}
\addtolength{\mywidth}{0.7\paperwidth}
\settypeblocksize{\textheight}{\mywidth}{*}

\begin{document}

  \begin{tikzpicture}[remember picture, overlay]
      \fill [fill=blue!20] (0,1cm) -- (0,-14cm) -- (4cm,-19cm) -- (4cm,1cm) -- cycle;
  \end{tikzpicture}

\vfill% or set \vspace*{whatever you like}
\hspace*{\parindent}% text in specimen is set into page somewhat
\begin{minipage}[c]{3cm}% adjust to taste
  \raggedleft
  Tractor beat trailer give backwoods hee-haw gold frogskin plumb nugget. Liniment fancy rightly work chicken what cipherin' how ya. Heapin' backwoods her hospitality em got creosote overalls rodeo up. Townfolk soap out.
\end{minipage}
\hspace*{1em}% avoid text hitting edge of frame or background - adjust to taste
\vfill\vfill% adjust to taste or reduce to one \vfill if setting \vspace*{} to a specific value above

\framebreak% force following text to next flow frame

\section*{Sphinx of black quartz}% demonstrate relative positioning of text in next frame

Peter Piper picked a pickled pepper.

\end{document}

which produces:

demo with text over tikzpicture standing in for missing background image, with text positioned very roughly as shown in target image added to updated question

Note the difference between \paperwidth and \textwidth. Unless you virtually zero the left/right margins, one fifth of the \textwidth is not enough to contain a 4cm wide image. So assuming you want something which looks roughly like the image you posted and that you don't wish to alter that image, I am guessing you want the left flow frame to be wider. I've kept the proportions the same and set the margins based on the resulting widths. So the margins are now very small. If this isn't what you want, you could increase the proportion of the page width taken by the left flow frame relative to the main one, or set the left flow frame to an absolute width (e.g. 4cm or whatever) and calculate the width of the main flow frame accordingly.

If the text should be higher up, increase the number of \vfill commands following the minipage, tweak the position of the minipage or just set the amount of vspace before the minipage to whatever you like.

Share:
1,232
Ghoul Fool
Author by

Ghoul Fool

Updated on August 01, 2022

Comments

  • Ghoul Fool
    Ghoul Fool over 1 year

    enter image description hereI'm new to Latex! I've have successfully managed to get my text in the right format, but am having problems positioning a single graphic where it needs to go. Essentially it should be on the left hand side of the page with the left frame text on top of it.

    However it's not quite working out. Just in case you need to know, symbol_strip is an image that's 4 x 20cm; I've commented it out as it'll just appear in the wrong place.

    % Left frame
    \begin{figure}
    \hfill
    % \includegraphics{symbol_strip.jpg}
    \vspace{-2cm}
    \end{figure}
    \begin{flushright}
    
    Tractor beat trailer give backwoods hee-haw gold frogskin plumb nugget. Liniment fancy rightly work chicken what cipherin' how ya. Heapin' backwoods her hospitality em got creosote overalls rodeo up. Townfolk soap out.
    
    \end{flushright}\normalsize
    \framebreak
    

    And, yes, I'm using Hillbilly as my Lorem ipsum is rusty ;)

    I also tried using the example here syntax similar to \centering for right and left? by wrapping figure around flushright, only this time the text disappeared. Confused.

    \documentclass[a4paper,11pt,final]{memoir}
    
    \pagestyle{empty}
    
    \usepackage{flowfram}
    \usepackage{graphicx}  
    
    % left frame
    \newflowframe{0.2\textwidth}{\textheight}{0pt}{0pt}[left]
      \newlength{\LeftMainSep}
      \setlength{\LeftMainSep}{0.2\textwidth}
      \addtolength{\LeftMainSep}{2\columnsep}
    % right frame
    \newflowframe{0.7\textwidth}{\textheight}{\LeftMainSep}{0pt}[main01]
    
    
    \begin{document}
    
    \begin{figure}
    \begin{flushright}
    \includegraphics{symbol_strip.jpg}
    \vspace{-2cm}
     Tractor beat trailer give backwoods hee-haw gold frogskin plumb nugget. Liniment fancy rightly work chicken what cipherin' how ya. Heapin' backwoods her hospitality em got creosote overalls rodeo up. Townfolk soap out.
    \end{flushright}
    \end{figure}
    
    \end{document}
    

    I've included an image as well. The blue dagger like part is the image in question.

  • Ghoul Fool
    Ghoul Fool almost 10 years
    Thank you for your help. I realise now that "text printed on top of the picture" is not very helpful, and I'm not sure if talking about Z-order would apply to Latex, or just confuse matters. I've added an image which should make it easier to show what I'm after.
  • cfr
    cfr almost 10 years
    OK. I don't know if Z-order applies to LaTeX but it means nothing to me. (This doesn't mean it won't mean plenty to others, though.) The picture helps, though. I've edited my answer to get closer to what you are looking for. I think your dimensions are not going to get you what you want unless you plan to set your margins to something close to zero. Rather than do that, I've assumed you mean \paperwidth rather than \textwidth.
  • cfr
    cfr almost 10 years
    @GhoulFool Actually, that does get you very small margins. However, I've also indicated alternative ways of accommodating the 4cm image by increasing the proportion of the page width taken by the image in a couple of different ways instead. Hope something is helpful.